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

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

Issue 13935005: Remove explicit thread manipulation from WebDB migration test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | 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/file_util.h" 7 #include "base/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.h" 10 #include "base/message_loop.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/webdata/web_intents_table.h" 21 #include "chrome/browser/webdata/web_intents_table.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/autofill/browser/autofill_country.h" 23 #include "components/autofill/browser/autofill_country.h"
24 #include "components/autofill/browser/autofill_profile.h" 24 #include "components/autofill/browser/autofill_profile.h"
25 #include "components/autofill/browser/autofill_type.h" 25 #include "components/autofill/browser/autofill_type.h"
26 #include "components/autofill/browser/credit_card.h" 26 #include "components/autofill/browser/credit_card.h"
27 #include "components/autofill/browser/webdata/autofill_change.h" 27 #include "components/autofill/browser/webdata/autofill_change.h"
28 #include "components/autofill/browser/webdata/autofill_entry.h" 28 #include "components/autofill/browser/webdata/autofill_entry.h"
29 #include "components/autofill/browser/webdata/autofill_table.h" 29 #include "components/autofill/browser/webdata/autofill_table.h"
30 #include "components/webdata/common/web_database.h" 30 #include "components/webdata/common/web_database.h"
31 #include "content/public/test/test_browser_thread.h"
32 #include "sql/statement.h" 31 #include "sql/statement.h"
33 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
34 33
35 using autofill::AutofillProfile; 34 using autofill::AutofillProfile;
36 using autofill::AutofillTable; 35 using autofill::AutofillTable;
37 using autofill::CreditCard; 36 using autofill::CreditCard;
38 using base::Time; 37 using base::Time;
39 using content::BrowserThread;
40 38
41 namespace { 39 namespace {
42 40
43 void AutofillProfile31FromStatement(const sql::Statement& s, 41 void AutofillProfile31FromStatement(const sql::Statement& s,
44 AutofillProfile* profile, 42 AutofillProfile* profile,
45 base::string16* label, 43 base::string16* label,
46 int* unique_id, 44 int* unique_id,
47 int64* date_modified) { 45 int64* date_modified) {
48 DCHECK(profile); 46 DCHECK(profile);
49 DCHECK(label); 47 DCHECK(label);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 153 }
156 154
157 } // anonymous namespace 155 } // anonymous namespace
158 156
159 // The WebDatabaseMigrationTest encapsulates testing of database migrations. 157 // The WebDatabaseMigrationTest encapsulates testing of database migrations.
160 // Specifically, these tests are intended to exercise any schema changes in 158 // Specifically, these tests are intended to exercise any schema changes in
161 // the WebDatabase and data migrations that occur in 159 // the WebDatabase and data migrations that occur in
162 // |WebDatabase::MigrateOldVersionsAsNeeded()|. 160 // |WebDatabase::MigrateOldVersionsAsNeeded()|.
163 class WebDatabaseMigrationTest : public testing::Test { 161 class WebDatabaseMigrationTest : public testing::Test {
164 public: 162 public:
165 // In order to access the application locale -- which the tested functions do 163 WebDatabaseMigrationTest() {}
166 // internally -- this test must run on the UI thread.
167 // TODO(isherman): The WebDatabase code should probably verify that it is
168 // running on the DB thread. Once that verification is added, this code will
169 // need to be updated to create both threads.
170 WebDatabaseMigrationTest()
171 : ui_thread_(BrowserThread::UI, &message_loop_for_ui_) {}
172 virtual ~WebDatabaseMigrationTest() {} 164 virtual ~WebDatabaseMigrationTest() {}
173 165
174 virtual void SetUp() { 166 virtual void SetUp() {
175 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 167 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
176 } 168 }
177 169
178 // Load the database via the WebDatabase class and migrate the database to 170 // Load the database via the WebDatabase class and migrate the database to
179 // the current version. 171 // the current version.
180 void DoMigration() { 172 void DoMigration() {
181 // TODO(joi): This whole unit test file needs to stay in //chrome 173 // TODO(joi): This whole unit test file needs to stay in //chrome
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // The sql files located in "chrome/test/data/web_database" were generated by 228 // The sql files located in "chrome/test/data/web_database" were generated by
237 // launching the Chromium application prior to schema change, then using the 229 // launching the Chromium application prior to schema change, then using the
238 // sqlite3 command-line application to dump the contents of the "Web Data" 230 // sqlite3 command-line application to dump the contents of the "Web Data"
239 // database. 231 // database.
240 // Like this: 232 // Like this:
241 // > .output version_nn.sql 233 // > .output version_nn.sql
242 // > .dump 234 // > .dump
243 void LoadDatabase(const base::FilePath::StringType& file); 235 void LoadDatabase(const base::FilePath::StringType& file);
244 236
245 private: 237 private:
246 MessageLoopForUI message_loop_for_ui_;
247 content::TestBrowserThread ui_thread_;
248 base::ScopedTempDir temp_dir_; 238 base::ScopedTempDir temp_dir_;
249 239
250 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 240 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
251 }; 241 };
252 242
253 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 49; 243 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 49;
254 244
255 void WebDatabaseMigrationTest::LoadDatabase( 245 void WebDatabaseMigrationTest::LoadDatabase(
256 const base::FilePath::StringType& file) { 246 const base::FilePath::StringType& file) {
257 std::string contents; 247 std::string contents;
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); 1980 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1991 1981
1992 // Check version. 1982 // Check version.
1993 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); 1983 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
1994 1984
1995 // A new column should have been created. 1985 // A new column should have been created.
1996 EXPECT_TRUE(connection.DoesColumnExist("keywords", 1986 EXPECT_TRUE(connection.DoesColumnExist("keywords",
1997 "search_terms_replacement_key")); 1987 "search_terms_replacement_key"));
1998 } 1988 }
1999 } 1989 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698