Bug 1253340 - Pre: close the upgraded DB in testBrowserDatabaseHelper r=mcomella
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 03 Mar 2016 21:25:45 -0800
changeset 287034 a935aa952e169149ac8a9525feadcd9cc930ddec
parent 287033 49283c87f0e92e8cc5d93fbcae1fdb83f3448823
child 287035 46296f1ef6a702846fb043f84c11d77cdc12532b
push id18048
push userahunt@mozilla.com
push dateTue, 08 Mar 2016 03:09:35 +0000
treeherderfx-team@46296f1ef6a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1253340
milestone47.0a1
Bug 1253340 - Pre: close the upgraded DB in testBrowserDatabaseHelper r=mcomella Otherwise we'll receive "android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here" on shutdown. MozReview-Commit-ID: Dq0ikutJDNd
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testBrowserDatabaseHelperUpgrades.java
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testBrowserDatabaseHelperUpgrades.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testBrowserDatabaseHelperUpgrades.java
@@ -85,18 +85,23 @@ public class testBrowserDatabaseHelperUp
                 fAssertEquals("Input DB isn't the expected version",
                               i, db.getVersion());
             } finally {
                 db.close();
             }
 
             final BrowserDatabaseHelper dbHelperToUpgrade = new BrowserDatabaseHelper(getActivity(), tempDbPath);
             // Ideally, we'd test upgrading version i to version i + 1 but this method does not permit that. Alas!
-            fAssertEquals("DB helper should upgrade to latest version",
-                    BrowserDatabaseHelper.DATABASE_VERSION, dbHelperToUpgrade.getWritableDatabase().getVersion());
+            final SQLiteDatabase upgradedDb = dbHelperToUpgrade.getWritableDatabase();
+            try {
+                fAssertEquals("DB helper should upgrade to latest version",
+                              BrowserDatabaseHelper.DATABASE_VERSION, upgradedDb.getVersion());
+            } finally {
+                upgradedDb.close();
+            }
         }
     }
 
     /**
      * Copies the database from the assets directory to a temporary test file.
      *
      * @param version version of the database to copy.
      * @return the String path to the new copy of the database