Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Fix top sites instrumentation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Amejia481 committed Jun 1, 2020
1 parent 2ac91e3 commit 726daec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class TopSiteStorageTest {
execSQL(
"INSERT INTO " +
"top_sites " +
"(title, url, isDefault, created_at) " +
"(title, url, is_default, created_at) " +
"VALUES " +
"('Firefox','firefox.com',1,5)," +
"('Monitor','https://monitor.firefox.com/',0,5)"
Expand All @@ -154,29 +154,29 @@ class TopSiteStorageTest {
dbVersion2.query("SELECT * FROM top_sites").use { cursor ->
assertEquals(5, cursor.columnCount)

// Check isDefault for Mozilla
// Check is_default for Mozilla
cursor.moveToFirst()
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Top Articles
// Check is_default for Top Articles
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Wikipedia
// Check is_default for Wikipedia
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for YouTube
// Check is_default for YouTube
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Firefox
// Check is_default for Firefox
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Monitor
// Check is_default for Monitor
cursor.moveToNext()
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ internal abstract class TopSiteDatabase : RoomDatabase() {
internal object Migrations {
val migration_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
// Add the new isDefault column and set isDefault to 0 (false) for every entry.
// Add the new is_default column and set is_default to 0 (false) for every entry.
database.execSQL(
"ALTER TABLE top_sites ADD COLUMN isDefault INTEGER NOT NULL DEFAULT 0"
"ALTER TABLE top_sites ADD COLUMN is_default INTEGER NOT NULL DEFAULT 0"
)

// Prior to version 2, pocket top sites, wikipedia and youtube were added as default
// sites in Fenix. Look for these entries and set isDefault to 1 (true).
// sites in Fenix. Look for these entries and set is_default to 1 (true).
database.execSQL(
"UPDATE top_sites " +
"SET isDefault = 1 " +
"SET is_default = 1 " +
"WHERE url IN " +
"('https://getpocket.com/fenix-top-articles', " +
"'https://www.wikipedia.org/', " +
Expand Down

0 comments on commit 726daec

Please sign in to comment.