Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/history/shortcuts_database_unittest.cc

Issue 134853004: Migrate old Shortcuts DB data to conform to new type values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Peter's comments - 2 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // The other three columns have default values. 292 // The other three columns have default values.
293 EXPECT_EQ(content::PAGE_TRANSITION_TYPED, 293 EXPECT_EQ(content::PAGE_TRANSITION_TYPED,
294 static_cast<content::PageTransition>(statement.ColumnInt(2))); 294 static_cast<content::PageTransition>(statement.ColumnInt(2)));
295 EXPECT_EQ(AutocompleteMatchType::HISTORY_TITLE, 295 EXPECT_EQ(AutocompleteMatchType::HISTORY_TITLE,
296 static_cast<AutocompleteMatch::Type>(statement.ColumnInt(3))); 296 static_cast<AutocompleteMatch::Type>(statement.ColumnInt(3)));
297 EXPECT_TRUE(statement.ColumnString(4).empty()); 297 EXPECT_TRUE(statement.ColumnString(4).empty());
298 } 298 }
299 EXPECT_TRUE(statement.Succeeded()); 299 EXPECT_TRUE(statement.Succeeded());
300 } 300 }
301 301
302 TEST(ShortcutsDatabaseMigrationTest, MigrateV2ToV3) {
Peter Kasting 2014/02/12 00:27:50 Nit: Hmm, I see we're using "v2" and "v3" here bec
Anuj 2014/02/12 23:54:40 I think we are caught in a no good-names situation
303 // Open the v1 test file and use it to create a test database in a temp dir.
304 base::FilePath sql_path;
305 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &sql_path));
306 sql_path = sql_path.AppendASCII("History").AppendASCII("Shortcuts.v2.sql");
307 base::ScopedTempDir temp_dir;
308 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
309 base::FilePath db_path(temp_dir.path().AppendASCII("TestShortcuts.db"));
310 ASSERT_TRUE(sql::test::CreateDatabaseFromSQL(db_path, sql_path));
311
312 // Create a ShortcutsDatabase from the test database, which will migrate the
313 // test database to the current version.
314 {
315 scoped_refptr<ShortcutsDatabase> db(new ShortcutsDatabase(db_path));
316 db->Init();
317 }
318
319 // Check the values in each of the new columns.
Peter Kasting 2014/02/12 00:27:50 Nit: Maybe "Check that all the old type values got
Anuj 2014/02/12 23:54:40 Done.
320 sql::Connection connection;
321 ASSERT_TRUE(connection.Open(db_path));
322 sql::Statement statement(connection.GetUniqueStatement(
323 "SELECT count(1) FROM omni_box_shortcuts WHERE type in (9, 10, 11, 12)"));
324 ASSERT_TRUE(statement.is_valid());
325 while (statement.Step()) {
Peter Kasting 2014/02/12 00:27:50 Nit: {} not necessary
Anuj 2014/02/12 23:54:40 Done.
326 EXPECT_EQ(0, statement.ColumnInt(0));
327 }
328 EXPECT_TRUE(statement.Succeeded());
329 }
330
302 } // namespace history 331 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698