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

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

Issue 8355025: Fix an Autofill crash caused by accessing the g_browser_process on the DB thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix more tests? Created 9 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
« no previous file with comments | « chrome/browser/webdata/web_data_service.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h"
8 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
9 #include "base/stl_util.h" 10 #include "base/stl_util.h"
10 #include "base/string16.h" 11 #include "base/string16.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/autofill/autofill_profile.h" 16 #include "chrome/browser/autofill/autofill_profile.h"
16 #include "chrome/browser/autofill/autofill_type.h" 17 #include "chrome/browser/autofill/autofill_type.h"
17 #include "chrome/browser/autofill/credit_card.h" 18 #include "chrome/browser/autofill/credit_card.h"
18 #include "chrome/browser/webdata/autofill_change.h" 19 #include "chrome/browser/webdata/autofill_change.h"
19 #include "chrome/browser/webdata/autofill_entry.h" 20 #include "chrome/browser/webdata/autofill_entry.h"
20 #include "chrome/browser/webdata/web_database.h" 21 #include "chrome/browser/webdata/web_database.h"
22 #include "content/browser/browser_thread.h"
21 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/guid.h" 24 #include "chrome/common/guid.h"
23 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
24 #include "sql/statement.h" 26 #include "sql/statement.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 28
27 using base::Time; 29 using base::Time;
28 30
29 namespace { 31 namespace {
30 32
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 123 }
122 124
123 } // anonymous namespace 125 } // anonymous namespace
124 126
125 // The WebDatabaseMigrationTest encapsulates testing of database migrations. 127 // The WebDatabaseMigrationTest encapsulates testing of database migrations.
126 // Specifically, these tests are intended to exercise any schema changes in 128 // Specifically, these tests are intended to exercise any schema changes in
127 // the WebDatabase and data migrations that occur in 129 // the WebDatabase and data migrations that occur in
128 // |WebDatabase::MigrateOldVersionsAsNeeded()|. 130 // |WebDatabase::MigrateOldVersionsAsNeeded()|.
129 class WebDatabaseMigrationTest : public testing::Test { 131 class WebDatabaseMigrationTest : public testing::Test {
130 public: 132 public:
131 WebDatabaseMigrationTest() {} 133 // In order to access the application locale -- which the tested functions do
134 // internally -- this test must run on the UI thread.
135 // TODO(isherman): The WebDatabase code should probably verify that it is
136 // running on the DB thread. Once that verification is added, this code will
137 // need to be updated to create both threads.
138 WebDatabaseMigrationTest()
139 : ui_thread_(BrowserThread::UI, &message_loop_for_ui_) {}
132 virtual ~WebDatabaseMigrationTest() {} 140 virtual ~WebDatabaseMigrationTest() {}
133 141
134 virtual void SetUp() { 142 virtual void SetUp() {
135 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 143 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
136 } 144 }
137 145
138 protected: 146 protected:
139 // Current tested version number. When adding a migration in 147 // Current tested version number. When adding a migration in
140 // |WebDatabase::MigrateOldVersionsAsNeeded()| and changing the version number 148 // |WebDatabase::MigrateOldVersionsAsNeeded()| and changing the version number
141 // |kCurrentVersionNumber| this value should change to reflect the new version 149 // |kCurrentVersionNumber| this value should change to reflect the new version
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // database. 181 // database.
174 // Like this: 182 // Like this:
175 // > .output version_nn.sql 183 // > .output version_nn.sql
176 // > .dump 184 // > .dump
177 void LoadDatabase(const FilePath::StringType& file); 185 void LoadDatabase(const FilePath::StringType& file);
178 186
179 // Assertion testing for migrating from version 27 and 28. 187 // Assertion testing for migrating from version 27 and 28.
180 void MigrateVersion28Assertions(); 188 void MigrateVersion28Assertions();
181 189
182 private: 190 private:
191 MessageLoopForUI message_loop_for_ui_;
192 BrowserThread ui_thread_;
183 ScopedTempDir temp_dir_; 193 ScopedTempDir temp_dir_;
184 194
185 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 195 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
186 }; 196 };
187 197
188 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 40; 198 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 40;
189 199
190 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { 200 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
191 std::string contents; 201 std::string contents;
192 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents)); 202 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents));
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 &default_search_provider_id_backup)); 1569 &default_search_provider_id_backup));
1560 EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup); 1570 EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup);
1561 1571
1562 std::string default_search_provider_id_backup_signature; 1572 std::string default_search_provider_id_backup_signature;
1563 EXPECT_TRUE(meta_table.GetValue( 1573 EXPECT_TRUE(meta_table.GetValue(
1564 "Default Search Provider ID Backup Signature", 1574 "Default Search Provider ID Backup Signature",
1565 &default_search_provider_id_backup_signature)); 1575 &default_search_provider_id_backup_signature));
1566 } 1576 }
1567 } 1577 }
1568 1578
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698