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

Side by Side Diff: components/webdata/common/web_database_migration_unittest.cc

Issue 684493002: Don't persist and sync omnibox extension keywords. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 1 month 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
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // > .output version_nn.sql 241 // > .output version_nn.sql
242 // > .dump 242 // > .dump
243 void LoadDatabase(const base::FilePath::StringType& file); 243 void LoadDatabase(const base::FilePath::StringType& file);
244 244
245 private: 245 private:
246 base::ScopedTempDir temp_dir_; 246 base::ScopedTempDir temp_dir_;
247 247
248 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 248 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
249 }; 249 };
250 250
251 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 58; 251 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 59;
252 252
253 void WebDatabaseMigrationTest::LoadDatabase( 253 void WebDatabaseMigrationTest::LoadDatabase(
254 const base::FilePath::StringType& file) { 254 const base::FilePath::StringType& file) {
255 std::string contents; 255 std::string contents;
256 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); 256 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents));
257 257
258 sql::Connection connection; 258 sql::Connection connection;
259 ASSERT_TRUE(connection.Open(GetDatabasePath())); 259 ASSERT_TRUE(connection.Open(GetDatabasePath()));
260 ASSERT_TRUE(connection.Execute(contents.data())); 260 ASSERT_TRUE(connection.Execute(contents.data()));
261 } 261 }
(...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 2712
2713 // Check version. 2713 // Check version.
2714 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); 2714 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2715 2715
2716 EXPECT_FALSE(connection.DoesTableExist("web_apps")); 2716 EXPECT_FALSE(connection.DoesTableExist("web_apps"));
2717 EXPECT_FALSE(connection.DoesTableExist("web_app_icons")); 2717 EXPECT_FALSE(connection.DoesTableExist("web_app_icons"));
2718 EXPECT_FALSE(connection.DoesTableExist("web_intents")); 2718 EXPECT_FALSE(connection.DoesTableExist("web_intents"));
2719 EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults")); 2719 EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults"));
2720 } 2720 }
2721 } 2721 }
2722
2723 // Tests that migrating from version 58 to version 59 drops the omnibox
2724 // extension keywords.
2725 TEST_F(WebDatabaseMigrationTest, MigrateVersion58ToCurrent) {
2726 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_58.sql")));
2727
2728 const char query_extensions[] = "SELECT * FROM keywords "
2729 "WHERE url='chrome-extension://iphchnegaodmijmkdlbhbanjhfphhikp/"
2730 "?q={searchTerms}'";
2731 // Verify pre-conditions.
2732 {
2733 sql::Connection connection;
2734 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2735 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2736
2737 sql::MetaTable meta_table;
2738 ASSERT_TRUE(meta_table.Init(&connection, 58, 58));
2739
2740 sql::Statement s(connection.GetUniqueStatement(query_extensions));
2741 ASSERT_TRUE(s.is_valid());
2742 int count = 0;
2743 while (s.Step()) {
2744 ++count;
2745 }
2746 EXPECT_EQ(1, count);
2747 }
2748
2749 DoMigration();
2750
2751 // Verify post-conditions.
2752 {
2753 sql::Connection connection;
2754 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2755 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2756
2757 // Check version.
2758 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2759
2760 sql::Statement s(connection.GetUniqueStatement(query_extensions));
2761 ASSERT_TRUE(s.is_valid());
2762 int count = 0;
2763 while (s.Step()) {
2764 ++count;
2765 }
2766 EXPECT_EQ(0, count);
2767
2768 s.Assign(connection.GetUniqueStatement("SELECT * FROM keywords "
2769 "WHERE short_name='Google'"));
2770 ASSERT_TRUE(s.is_valid());
2771 count = 0;
2772 while (s.Step()) {
2773 ++count;
2774 }
2775 EXPECT_EQ(1, count);
2776 }
2777 }
OLDNEW
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698