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

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

Issue 2498053002: Add field to monitor last visited time for each search engine (Closed)
Patch Set: Update Nit comment. Created 4 years 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/macros.h" 10 #include "base/macros.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // > .output version_nn.sql 123 // > .output version_nn.sql
124 // > .dump 124 // > .dump
125 void LoadDatabase(const base::FilePath::StringType& file); 125 void LoadDatabase(const base::FilePath::StringType& file);
126 126
127 private: 127 private:
128 base::ScopedTempDir temp_dir_; 128 base::ScopedTempDir temp_dir_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 130 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
131 }; 131 };
132 132
133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 68; 133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 69;
134 134
135 void WebDatabaseMigrationTest::LoadDatabase( 135 void WebDatabaseMigrationTest::LoadDatabase(
136 const base::FilePath::StringType& file) { 136 const base::FilePath::StringType& file) {
137 std::string contents; 137 std::string contents;
138 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); 138 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents));
139 139
140 sql::Connection connection; 140 sql::Connection connection;
141 ASSERT_TRUE(connection.Open(GetDatabasePath())); 141 ASSERT_TRUE(connection.Open(GetDatabasePath()));
142 ASSERT_TRUE(connection.Execute(contents.data())); 142 ASSERT_TRUE(connection.Execute(contents.data()));
143 } 143 }
(...skipping 13 matching lines...) Expand all
157 // version_nn.sql file. 157 // version_nn.sql file.
158 if (i == 52) 158 if (i == 52)
159 continue; 159 continue;
160 160
161 connection.Raze(); 161 connection.Raze();
162 const base::FilePath& file_name = base::FilePath::FromUTF8Unsafe( 162 const base::FilePath& file_name = base::FilePath::FromUTF8Unsafe(
163 "version_" + base::IntToString(i) + ".sql"); 163 "version_" + base::IntToString(i) + ".sql");
164 ASSERT_NO_FATAL_FAILURE(LoadDatabase(file_name.value())) 164 ASSERT_NO_FATAL_FAILURE(LoadDatabase(file_name.value()))
165 << "Failed to load " << file_name.MaybeAsASCII(); 165 << "Failed to load " << file_name.MaybeAsASCII();
166 DoMigration(); 166 DoMigration();
167
167 EXPECT_EQ(expected_schema, RemoveQuotes(connection.GetSchema())) 168 EXPECT_EQ(expected_schema, RemoveQuotes(connection.GetSchema()))
168 << "For version " << i; 169 << "For version " << i;
169 } 170 }
170 } 171 }
171 172
172 // Tests that the all migrations from an empty database succeed. 173 // Tests that the all migrations from an empty database succeed.
173 TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) { 174 TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) {
174 DoMigration(); 175 DoMigration();
175 176
176 // Verify post-conditions. These are expectations for current version of the 177 // Verify post-conditions. These are expectations for current version of the
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 "billing_address_id")); 1064 "billing_address_id"));
1064 1065
1065 sql::Statement read_masked(connection.GetUniqueStatement( 1066 sql::Statement read_masked(connection.GetUniqueStatement(
1066 "SELECT name_on_card, billing_address_id FROM masked_credit_cards")); 1067 "SELECT name_on_card, billing_address_id FROM masked_credit_cards"));
1067 ASSERT_TRUE(read_masked.Step()); 1068 ASSERT_TRUE(read_masked.Step());
1068 EXPECT_EQ("Alice", read_masked.ColumnString(0)); 1069 EXPECT_EQ("Alice", read_masked.ColumnString(0));
1069 EXPECT_TRUE(read_masked.ColumnString(1).empty()); 1070 EXPECT_TRUE(read_masked.ColumnString(1).empty());
1070 } 1071 }
1071 } 1072 }
1072 1073
1073 // Tests delete show_in_default_list column in keywords table. 1074 // Tests deletion of show_in_default_list column in keywords table.
1074 TEST_F(WebDatabaseMigrationTest, MigrateVersion67ToCurrent) { 1075 TEST_F(WebDatabaseMigrationTest, MigrateVersion67ToCurrent) {
1075 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_67.sql"))); 1076 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_67.sql")));
1076 1077
1077 // Verify pre-conditions. 1078 // Verify pre-conditions.
1078 { 1079 {
1079 sql::Connection connection; 1080 sql::Connection connection;
1080 ASSERT_TRUE(connection.Open(GetDatabasePath())); 1081 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1081 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); 1082 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1082 1083
1083 sql::MetaTable meta_table; 1084 sql::MetaTable meta_table;
(...skipping 10 matching lines...) Expand all
1094 ASSERT_TRUE(connection.Open(GetDatabasePath())); 1095 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1095 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); 1096 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1096 1097
1097 // Check version. 1098 // Check version.
1098 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); 1099 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
1099 1100
1100 EXPECT_FALSE( 1101 EXPECT_FALSE(
1101 connection.DoesColumnExist("keywords", "show_in_default_list")); 1102 connection.DoesColumnExist("keywords", "show_in_default_list"));
1102 } 1103 }
1103 } 1104 }
1105
1106 // Tests addition of last_visited column in keywords table.
1107 TEST_F(WebDatabaseMigrationTest, MigrateVersion68ToCurrent) {
1108 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_68.sql")));
1109
1110 // Verify pre-conditions.
1111 {
1112 sql::Connection connection;
1113 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1114 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1115
1116 sql::MetaTable meta_table;
1117 ASSERT_TRUE(meta_table.Init(&connection, 68, 68));
1118
1119 EXPECT_FALSE(connection.DoesColumnExist("keywords", "last_visited"));
1120 }
1121
1122 DoMigration();
1123
1124 // Verify post-conditions.
1125 {
1126 sql::Connection connection;
1127 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1128 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1129
1130 // Check version.
1131 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
1132
1133 EXPECT_TRUE(
1134 connection.DoesColumnExist("keywords", "last_visited"));
1135 }
1136 }
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