Created
September 1, 2011 03:13
Revisions
-
nking revised this gist
Sep 1, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,8 +17,8 @@ expected db location: /data/data/your.android.package.name/files/yourprojectname_version.db Then in your test class which extends ProviderTestCase2<CProvider>, have a test method to assert that yourprojectname_version.db is updated in your ContentProvider (method onUpgrade) and assert your methods... String dbPath = "/data/data/your.android.package.name/files/yourprojectname_version.db"; -
nking revised this gist
Sep 1, 2011 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,8 @@ If you want to test upgrades of your database schemas against new releases that included database version changes: To save your database, adb shell pull /data/data/your.android.package.name/databases/yourprojectname.db \ /yourprojectcvsdir/databases/yourprojectname_version.db If you're using a ContentProvider such as given by the Android example http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NotePadProvider.html @@ -12,7 +13,8 @@ below, the extended SQLiteOpenHelper is in a separate class. Before you test your ContentProvider, run a target to install the older version database in the adb virtual shell with a location that doesn't conflict with the expected db location: adb shell push /yourprojectcvsdir/databases/yourprojectname_version.db \ /data/data/your.android.package.name/files/yourprojectname_version.db Then in your test class which extends ProviderTestCase2<CProvider>, have a test method to start asserting that using yourprojectname_version.db with your content -
nking revised this gist
Sep 1, 2011 . 1 changed file with 14 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,25 @@ If you want to test upgrades of your database schemas against new releases that have included database version changes: To save your database, adb shell pull /data/data/your.android.package.name/databases/yourprojectname.db /yourprojectcvsdir/databases/yourprojectname_version.db If you're using a ContentProvider such as given by the Android example http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NotePadProvider.html make the methods accepting SQLiteDatabase arguments accessible. In the example below, the extended SQLiteOpenHelper is in a separate class. Before you test your ContentProvider, run a target to install the older version database in the adb virtual shell with a location that doesn't conflict with the expected db location: adb shell push /yourprojectcvsdir/databases/yourprojectname_version.db /data/data/your.android.package.name/files/yourprojectname_version.db Then in your test class which extends ProviderTestCase2<CProvider>, have a test method to start asserting that using yourprojectname_version.db with your content provider succeeds and assert your methods. String dbPath = "/data/data/your.android.package.name/files/yourprojectname_version.db"; SQLiteDatabase db = null; @@ -28,7 +31,8 @@ to start asserting that using yourprojectname_version.db with your content provi CProvider cProvider = getProvider(); // a wrapper to method that iterates over cursor to populate objects, for example Collection<YourObjects> list = cProvider.getObjects(db); assertNotNull(list); -
nking created this gist
Sep 1, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ If you want to test upgrades of your database schemas against new releases that have included database version changes: To save your database, adb shell pull /data/data/your.android.package.name/databases/yourprojectname.db /yourprojectcvsdir/databases/yourprojectname_version.db If you're using a ContentProvider such as given by the Android example http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NotePadProvider.html make the methods accepting SQLiteDatabase arguments accessible. In the example below, the extended SQLiteOpenHelper is in a separate class. Before you test your ContentProvider, run a target to install the older version database in the adb virtual shell with a location that doesn't conflict with the expected db location: adb shell push /yourprojectcvsdir/databases/yourprojectname_version.db /data/data/your.android.package.name/files/yourprojectname_version.db Then in your test class which extends ProviderTestCase2<CProvider>, have a test method to start asserting that using yourprojectname_version.db with your content provider succeeds and assert your methods. String dbPath = "/data/data/your.android.package.name/files/yourprojectname_version.db"; SQLiteDatabase db = null; try { ProviderDBHelper dbHelper = new ProviderDBHelper(getContext(), dbPath, version); db = dbHelper.getWritableDatabase(); CProvider cProvider = getProvider(); Collection<YourObjects> list = cProvider.getObjects(db); // a wrapper to method that iterates over cursor to populate objects, for example assertNotNull(list); assertTrue(list.size() > 0); } catch (Throwable t) { fail(t.getMessage()); }