Bug 1247469 - Fix testFilterOpenTab; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 07 Apr 2016 01:11:28 -0400
changeset 348368 1c0b058b86beb6c7543f0d13073d747243e792a1
parent 348367 4b76e05f7ecf45a4a6877517f27c3d4d067802cd
child 348369 b2581d348367fcad75830e693d8086bff16de572
child 348506 b6683e141c47c022598c0caac3ea8ba8c6236d42
push id14826
push userbenj@benj.me
push dateThu, 07 Apr 2016 11:56:36 +0000
reviewersme
bugs1247469, 1259653
milestone48.0a1
Bug 1247469 - Fix testFilterOpenTab; r=me As a follow-up to bug 1259653, fix a few places where we still treat empty-name profiles as the default profile. That should fix the testFilterOpenTab perma-failure.
mobile/android/base/java/org/mozilla/gecko/db/DBUtils.java
mobile/android/base/java/org/mozilla/gecko/db/PerProfileDatabases.java
mobile/android/base/java/org/mozilla/gecko/db/SQLiteBridgeContentProvider.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testFilterOpenTab.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/DBUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/DBUtils.java
@@ -243,17 +243,17 @@ public class DBUtils {
         return builder.toString();
     }
 
     public static Uri appendProfile(final String profile, final Uri uri) {
         return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE, profile).build();
     }
 
     public static Uri appendProfileWithDefault(final String profile, final Uri uri) {
-        if (TextUtils.isEmpty(profile)) {
+        if (profile == null) {
             return appendProfile(GeckoProfile.DEFAULT_PROFILE, uri);
         }
         return appendProfile(profile, uri);
     }
 
     /**
      * Use the following when no conflict action is specified.
      */
--- a/mobile/android/base/java/org/mozilla/gecko/db/PerProfileDatabases.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/PerProfileDatabases.java
@@ -57,17 +57,17 @@ public class PerProfileDatabases<T exten
     }
 
     public T getDatabaseHelperForProfile(String profile) {
         return getDatabaseHelperForProfile(profile, false);
     }
 
     public T getDatabaseHelperForProfile(String profile, boolean isTest) {
         // Always fall back to default profile if none has been provided.
-        if (TextUtils.isEmpty(profile)) {
+        if (profile == null) {
             profile = GeckoProfile.get(mContext).getName();
         }
 
         synchronized (this) {
             if (mStorages.containsKey(profile)) {
                 return mStorages.get(profile);
             }
 
--- a/mobile/android/base/java/org/mozilla/gecko/db/SQLiteBridgeContentProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/SQLiteBridgeContentProvider.java
@@ -182,17 +182,17 @@ public abstract class SQLiteBridgeConten
      * Returns a SQLiteBridge object according to the specified profile id and to the name of db related to the
      * current provider instance.
      * @param profile
      *          the id of the profile to be used to retrieve the related SQLiteBridge
      * @return the <code>SQLiteBridge</code> related to the specified profile id or <code>null</code> if it was 
      *         not possible to retrieve a valid SQLiteBridge
      */
     private SQLiteBridge getDatabaseForProfile(String profile) {
-        if (TextUtils.isEmpty(profile)) {
+        if (profile == null) {
             profile = GeckoProfile.get(mContext).getName();
             Log.d(mLogTag, "No profile provided, using '" + profile + "'");
         }
 
         final String dbName = getDBName();
         String mapKey = profile + "/" + dbName;
 
         SQLiteBridge db = null;
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testFilterOpenTab.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testFilterOpenTab.java
@@ -64,16 +64,18 @@ public class testFilterOpenTab extends C
 
     @Override
     public void setUp() throws Exception {
         super.setUp(sTabProviderCallable, BrowserContract.TABS_AUTHORITY, "tabs.db");
         mTests.add(new TestInsertLocalTabs());
     }
 
     public void testFilterOpenTab() throws Exception {
+        blockForGeckoReady();
+
         for (int i = 0; i < mTests.size(); i++) {
             Runnable test = mTests.get(i);
 
             setTestName(test.getClass().getSimpleName());
             test.run();
         }
     }