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

Side by Side Diff: chrome/browser/webdata/web_database_migration_unittest.cc

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed need for espv=1 for search term extraction. Created 8 years, 2 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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 void LoadDatabase(const FilePath::StringType& file); 188 void LoadDatabase(const FilePath::StringType& file);
189 189
190 private: 190 private:
191 MessageLoopForUI message_loop_for_ui_; 191 MessageLoopForUI message_loop_for_ui_;
192 content::TestBrowserThread ui_thread_; 192 content::TestBrowserThread ui_thread_;
193 ScopedTempDir temp_dir_; 193 ScopedTempDir temp_dir_;
194 194
195 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 195 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
196 }; 196 };
197 197
198 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 46; 198 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 47;
199 199
200 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { 200 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
201 std::string contents; 201 std::string contents;
202 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents)); 202 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents));
203 203
204 sql::Connection connection; 204 sql::Connection connection;
205 ASSERT_TRUE(connection.Open(GetDatabasePath())); 205 ASSERT_TRUE(connection.Open(GetDatabasePath()));
206 ASSERT_TRUE(connection.Execute(contents.data())); 206 ASSERT_TRUE(connection.Execute(contents.data()));
207 } 207 }
208 208
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 { 2202 {
2203 sql::Connection connection; 2203 sql::Connection connection;
2204 ASSERT_TRUE(connection.Open(GetDatabasePath())); 2204 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2205 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); 2205 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2206 2206
2207 // Check version. 2207 // Check version.
2208 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); 2208 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2209 EXPECT_LE(45, VersionFromConnection(&connection)); 2209 EXPECT_LE(45, VersionFromConnection(&connection));
2210 } 2210 }
2211 } 2211 }
2212
2213 // Check that current version is forced to compatible version before migration,
2214 // if the former is smaller.
Peter Kasting 2012/10/02 21:47:59 This comment is wrong
beaudoin 2012/10/03 22:46:52 Done.
Peter Kasting 2012/10/04 19:32:43 You fixed the wrong comment. The one that used to
beaudoin 2012/10/04 23:10:44 Note to self: Next time go to bed instead of tryin
2215 TEST_F(WebDatabaseMigrationTest, MigrateVersion46ToCurrent) {
2216 ASSERT_NO_FATAL_FAILURE(
2217 LoadDatabase(FILE_PATH_LITERAL("version_46.sql")));
2218
2219 // Verify pre-conditions. These are expectations for version 46 of the
2220 // database.
2221 {
2222 sql::Connection connection;
2223 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2224 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2225
2226 sql::MetaTable meta_table;
2227 ASSERT_TRUE(meta_table.Init(&connection, 46, 46));
2228
2229 ASSERT_FALSE(connection.DoesColumnExist("keywords", "alternate_urls"));
2230 ASSERT_FALSE(connection.DoesColumnExist("keywords_backup",
2231 "alternate_urls"));
2232 }
2233
2234 // Load the database via the WebDatabase class and migrate the database to
2235 // the current version.
2236 {
2237 WebDatabase db;
2238 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
2239 ASSERT_FALSE(db.GetKeywordTable()->DidDefaultSearchProviderChange());
2240 }
2241
2242 // Verify post-conditions. These are expectations for current version of the
2243 // database.
2244 {
2245 sql::Connection connection;
2246 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2247 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2248
2249 // Check version.
2250 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2251
2252 // A new column should have been created.
2253 EXPECT_TRUE(connection.DoesColumnExist("keywords", "alternate_urls"));
2254 ASSERT_TRUE(connection.DoesColumnExist("keywords_backup",
2255 "alternate_urls"));
2256 }
2257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698