Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 base::DeleteFile(test_path, true); | 218 base::DeleteFile(test_path, true); |
| 219 base::CreateDirectory(test_path); | 219 base::CreateDirectory(test_path); |
| 220 profile_path_ = test_path.AppendASCII("profile"); | 220 profile_path_ = test_path.AppendASCII("profile"); |
| 221 app_path_ = test_path.AppendASCII("app"); | 221 app_path_ = test_path.AppendASCII("app"); |
| 222 base::CreateDirectory(app_path_); | 222 base::CreateDirectory(app_path_); |
| 223 | 223 |
| 224 // This will launch the browser test and thus needs to happen last. | 224 // This will launch the browser test and thus needs to happen last. |
| 225 InProcessBrowserTest::SetUp(); | 225 InProcessBrowserTest::SetUp(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void Firefox3xImporterBrowserTest( | 228 void FirefoxImporterBrowserTest( |
| 229 std::string profile_dir, | 229 std::string profile_dir, |
| 230 importer::ImporterProgressObserver* observer, | 230 importer::ImporterProgressObserver* observer, |
| 231 ProfileWriter* writer, | 231 ProfileWriter* writer, |
| 232 bool import_search_plugins) { | 232 bool import_search_plugins) { |
| 233 base::FilePath data_path; | 233 base::FilePath data_path; |
| 234 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 234 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
| 235 data_path = data_path.AppendASCII(profile_dir); | 235 data_path = data_path.AppendASCII(profile_dir); |
| 236 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true)); | 236 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true)); |
| 237 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 237 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
| 238 data_path = data_path.AppendASCII("firefox3_nss"); | 238 data_path = data_path.AppendASCII("firefox3_nss"); |
| 239 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); | 239 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); |
| 240 | 240 |
| 241 base::FilePath search_engine_path = app_path_; | 241 base::FilePath search_engine_path = app_path_; |
| 242 search_engine_path = search_engine_path.AppendASCII("searchplugins"); | 242 search_engine_path = search_engine_path.AppendASCII("searchplugins"); |
| 243 base::CreateDirectory(search_engine_path); | 243 base::CreateDirectory(search_engine_path); |
| 244 if (import_search_plugins) { | 244 if (import_search_plugins) { |
| 245 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 245 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
| 246 data_path = data_path.AppendASCII("firefox3_searchplugins"); | |
| 247 if (!base::PathExists(data_path)) { | |
| 248 // TODO(maruel): Create search test data that we can open source! | |
| 249 LOG(ERROR) << "Missing internal test data"; | |
| 250 return; | |
| 251 } | |
| 252 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); | 246 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); |
| 253 } | 247 } |
| 254 | 248 |
| 255 importer::SourceProfile source_profile; | 249 importer::SourceProfile source_profile; |
| 256 source_profile.importer_type = importer::TYPE_FIREFOX; | 250 source_profile.importer_type = importer::TYPE_FIREFOX; |
| 257 source_profile.app_path = app_path_; | 251 source_profile.app_path = app_path_; |
| 258 source_profile.source_path = profile_path_; | 252 source_profile.source_path = profile_path_; |
| 259 source_profile.locale = "en-US"; | 253 source_profile.locale = "en-US"; |
| 260 | 254 |
| 261 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; | 255 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 273 } | 267 } |
| 274 | 268 |
| 275 base::ScopedTempDir temp_dir_; | 269 base::ScopedTempDir temp_dir_; |
| 276 base::FilePath profile_path_; | 270 base::FilePath profile_path_; |
| 277 base::FilePath app_path_; | 271 base::FilePath app_path_; |
| 278 }; | 272 }; |
| 279 | 273 |
| 280 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, | 274 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, |
| 281 MAYBE_IMPORTER(Firefox30Importer)) { | 275 MAYBE_IMPORTER(Firefox30Importer)) { |
| 282 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); | 276 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); |
| 283 Firefox3xImporterBrowserTest("firefox3_profile", observer.get(), | 277 FirefoxImporterBrowserTest("firefox3_profile", observer.get(), |
| 284 observer.get(), true); | 278 observer.get(), true); |
|
Ilya Sherman
2014/05/29 07:21:58
nit: Please fix the alignment of the text on this
| |
| 285 } | 279 } |
| 286 | 280 |
| 287 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, | 281 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, |
| 288 MAYBE_IMPORTER(Firefox35Importer)) { | 282 MAYBE_IMPORTER(Firefox35Importer)) { |
| 289 bool import_search_engines = false; | 283 bool import_search_engines = false; |
| 290 scoped_refptr<FirefoxObserver> observer( | 284 scoped_refptr<FirefoxObserver> observer( |
| 291 new FirefoxObserver(import_search_engines)); | 285 new FirefoxObserver(import_search_engines)); |
| 292 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), | 286 FirefoxImporterBrowserTest("firefox35_profile", observer.get(), |
| 293 observer.get(), import_search_engines); | 287 observer.get(), import_search_engines); |
| 294 } | 288 } |
| 289 | |
| 290 | |
| 291 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, FirefoxImporter) { | |
| 292 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); | |
| 293 FirefoxImporterBrowserTest("firefox_profile", observer.get(), | |
| 294 observer.get(), true); | |
| 295 } | |
| OLD | NEW |