Bug 1253340 - Pre: assert that we have the correct input database version in testBrowserDatabaseHelperUpgrades r=mcomella

This should help us spot if we ever upload a misnamed test DB.

MozReview-Commit-ID: B0vJuEeyrS8

--HG--
extra : rebase_source : 8d050c54a7ccbf6df95f7d101cc691a99f5d7d7f
This commit is contained in:
Andrzej Hunt 2016-03-03 10:21:58 -08:00
Родитель 4fbcf8548f
Коммит 20f248b3a0
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,7 @@ package org.mozilla.gecko.tests;
import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import org.mozilla.gecko.db.BrowserDatabaseHelper;
@ -78,6 +79,15 @@ public class testBrowserDatabaseHelperUpgrades extends UITest {
for (int i = TEST_FROM_VERSION; i < BrowserDatabaseHelper.DATABASE_VERSION; ++i) {
Log.d(LOGTAG, "Testing upgrade from version: " + i);
final String tempDbPath = copyDatabase(i);
final SQLiteDatabase db = SQLiteDatabase.openDatabase(tempDbPath, null, 0);
try {
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",