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

Side by Side Diff: chrome/browser/importer/firefox_importer_browsertest.cc

Issue 247223003: Parsed search.json for importing search engine settings from FireFox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed text alignments Created 6 years, 6 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
OLDNEW
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
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(std::string profile_dir,
229 std::string profile_dir, 229 importer::ImporterProgressObserver* observer,
230 importer::ImporterProgressObserver* observer, 230 ProfileWriter* writer,
231 ProfileWriter* writer, 231 bool import_search_plugins) {
232 bool import_search_plugins) {
233 base::FilePath data_path; 232 base::FilePath data_path;
234 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 233 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
235 data_path = data_path.AppendASCII(profile_dir); 234 data_path = data_path.AppendASCII(profile_dir);
236 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true)); 235 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true));
237 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 236 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
238 data_path = data_path.AppendASCII("firefox3_nss"); 237 data_path = data_path.AppendASCII("firefox3_nss");
239 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); 238 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false));
240 239
241 base::FilePath search_engine_path = app_path_; 240 base::FilePath search_engine_path = app_path_;
242 search_engine_path = search_engine_path.AppendASCII("searchplugins"); 241 search_engine_path = search_engine_path.AppendASCII("searchplugins");
243 base::CreateDirectory(search_engine_path); 242 base::CreateDirectory(search_engine_path);
244 if (import_search_plugins) { 243 if (import_search_plugins) {
245 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 244 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)); 245 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false));
Ilya Sherman 2014/06/06 04:15:42 I'm noticing that this code currently tries to cop
Tapu Ghose 2014/06/15 04:19:49 Updated test code for copying the files properly.
253 } 246 }
254 247
255 importer::SourceProfile source_profile; 248 importer::SourceProfile source_profile;
256 source_profile.importer_type = importer::TYPE_FIREFOX; 249 source_profile.importer_type = importer::TYPE_FIREFOX;
257 source_profile.app_path = app_path_; 250 source_profile.app_path = app_path_;
258 source_profile.source_path = profile_path_; 251 source_profile.source_path = profile_path_;
259 source_profile.locale = "en-US"; 252 source_profile.locale = "en-US";
260 253
261 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; 254 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES;
262 if (import_search_plugins) 255 if (import_search_plugins)
(...skipping 10 matching lines...) Expand all
273 } 266 }
274 267
275 base::ScopedTempDir temp_dir_; 268 base::ScopedTempDir temp_dir_;
276 base::FilePath profile_path_; 269 base::FilePath profile_path_;
277 base::FilePath app_path_; 270 base::FilePath app_path_;
278 }; 271 };
279 272
280 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 273 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
281 MAYBE_IMPORTER(Firefox30Importer)) { 274 MAYBE_IMPORTER(Firefox30Importer)) {
282 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); 275 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver());
283 Firefox3xImporterBrowserTest("firefox3_profile", observer.get(), 276 FirefoxImporterBrowserTest(
284 observer.get(), true); 277 "firefox3_profile", observer.get(), observer.get(), true);
285 } 278 }
286 279
287 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 280 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
288 MAYBE_IMPORTER(Firefox35Importer)) { 281 MAYBE_IMPORTER(Firefox35Importer)) {
289 bool import_search_engines = false; 282 bool import_search_engines = false;
290 scoped_refptr<FirefoxObserver> observer( 283 scoped_refptr<FirefoxObserver> observer(
291 new FirefoxObserver(import_search_engines)); 284 new FirefoxObserver(import_search_engines));
292 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), 285 FirefoxImporterBrowserTest("firefox35_profile",
293 observer.get(), import_search_engines); 286 observer.get(),
287 observer.get(),
288 import_search_engines);
294 } 289 }
290
291 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, FirefoxImporter) {
292 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver());
293 FirefoxImporterBrowserTest(
294 "firefox_profile", observer.get(), observer.get(), true);
295 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/firefox3_profile/README » ('j') | chrome/test/data/firefox3_profile/README » ('J')

Powered by Google App Engine
This is Rietveld 408576698