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

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: Restored kFirefoxKeywords and updated logic to import installed search engines along with default o… Created 6 years, 7 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 }; 60 };
61 61
62 const PasswordInfo kFirefoxPasswords[] = { 62 const PasswordInfo kFirefoxPasswords[] = {
63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", 63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/",
64 L"loginuser", L"abc", L"loginpass", L"123", false}, 64 L"loginuser", L"abc", L"loginpass", L"123", false},
65 {"http://localhost:8080/", "", "http://localhost:8080/localhost", 65 {"http://localhost:8080/", "", "http://localhost:8080/localhost",
66 L"", L"http", L"", L"Http1+1abcdefg", false}, 66 L"", L"http", L"", L"Http1+1abcdefg", false},
67 }; 67 };
68 68
69 const KeywordInfo kFirefoxKeywords[] = { 69 const KeywordInfo kFirefoxKeywords[] = {
70 { L"amazon.com", 70 {L"amazon.com",
71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords=" 71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords="
72 "{searchTerms}&mode=blended" }, 72 "{searchTerms}&mode=blended"},
73 { L"answers.com", 73 {L"answers.com",
74 "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" }, 74 "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13"},
75 { L"search.creativecommons.org", 75 {L"search.creativecommons.org",
76 "http://search.creativecommons.org/?q={searchTerms}" }, 76 "http://search.creativecommons.org/?q={searchTerms}"},
77 { L"search.ebay.com", 77 {L"search.ebay.com",
78 "http://search.ebay.com/search/search.dll?query={searchTerms}&" 78 "http://search.ebay.com/search/search.dll?query={searchTerms}&"
79 "MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&" 79 "MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&"
80 "maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" }, 80 "maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort"},
81 { L"google.com", 81 {L"google.com",
82 "http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" }, 82 "http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t"},
83 { L"en.wikipedia.org", 83 {L"en.wikipedia.org",
84 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}" }, 84 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}"},
85 { L"search.yahoo.com", 85 {L"search.yahoo.com",
86 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" }, 86 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8"},
87 { L"flickr.com", 87 {L"flickr.com", "http://www.flickr.com/photos/tags/?q={searchTerms}"},
88 "http://www.flickr.com/photos/tags/?q={searchTerms}" }, 88 {L"imdb.com", "http://www.imdb.com/find?q={searchTerms}"},
89 { L"imdb.com", 89 {L"webster.com",
90 "http://www.imdb.com/find?q={searchTerms}" }, 90 "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}"},
91 { L"webster.com", 91 // Search keywords.
92 "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" }, 92 {L"\x4E2D\x6587", "http://www.google.com/"},
93 // Search keywords.
94 { L"\x4E2D\x6587", "http://www.google.com/" },
95 }; 93 };
96 94
97 class FirefoxObserver : public ProfileWriter, 95 class FirefoxObserver : public ProfileWriter,
98 public importer::ImporterProgressObserver { 96 public importer::ImporterProgressObserver {
99 public: 97 public:
100 FirefoxObserver() 98 FirefoxObserver()
101 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0), 99 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0),
102 password_count_(0), keyword_count_(0), import_search_engines_(true) { 100 password_count_(0), keyword_count_(0), import_search_engines_(true) {
103 } 101 }
104 102
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 base::DeleteFile(test_path, true); 217 base::DeleteFile(test_path, true);
220 base::CreateDirectory(test_path); 218 base::CreateDirectory(test_path);
221 profile_path_ = test_path.AppendASCII("profile"); 219 profile_path_ = test_path.AppendASCII("profile");
222 app_path_ = test_path.AppendASCII("app"); 220 app_path_ = test_path.AppendASCII("app");
223 base::CreateDirectory(app_path_); 221 base::CreateDirectory(app_path_);
224 222
225 // This will launch the browser test and thus needs to happen last. 223 // This will launch the browser test and thus needs to happen last.
226 InProcessBrowserTest::SetUp(); 224 InProcessBrowserTest::SetUp();
227 } 225 }
228 226
229 void Firefox3xImporterBrowserTest( 227 void FirefoxImporterBrowserTest(std::string profile_dir,
230 std::string profile_dir, 228 importer::ImporterProgressObserver* observer,
231 importer::ImporterProgressObserver* observer, 229 ProfileWriter* writer,
232 ProfileWriter* writer, 230 bool import_search_plugins) {
233 bool import_search_plugins) {
234 base::FilePath data_path; 231 base::FilePath data_path;
235 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 232 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
236 data_path = data_path.AppendASCII(profile_dir); 233 data_path = data_path.AppendASCII(profile_dir);
237 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true)); 234 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, true));
238 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 235 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
239 data_path = data_path.AppendASCII("firefox3_nss"); 236 data_path = data_path.AppendASCII("firefox3_nss");
240 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); 237 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false));
241 238
242 base::FilePath search_engine_path = app_path_; 239 base::FilePath search_engine_path = app_path_;
243 search_engine_path = search_engine_path.AppendASCII("searchplugins"); 240 search_engine_path = search_engine_path.AppendASCII("searchplugins");
244 base::CreateDirectory(search_engine_path); 241 base::CreateDirectory(search_engine_path);
245 if (import_search_plugins) { 242 if (import_search_plugins) {
246 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 243 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
247 data_path = data_path.AppendASCII("firefox3_searchplugins");
248 if (!base::PathExists(data_path)) {
249 // TODO(maruel): Create search test data that we can open source!
250 LOG(ERROR) << L"Missing internal test data";
251 return;
252 }
253 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); 244 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false));
254 } 245 }
255 246
256 importer::SourceProfile source_profile; 247 importer::SourceProfile source_profile;
257 source_profile.importer_type = importer::TYPE_FIREFOX; 248 source_profile.importer_type = importer::TYPE_FIREFOX;
258 source_profile.app_path = app_path_; 249 source_profile.app_path = app_path_;
259 source_profile.source_path = profile_path_; 250 source_profile.source_path = profile_path_;
260 source_profile.locale = "en-US"; 251 source_profile.locale = "en-US";
261 252
262 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; 253 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES;
(...skipping 11 matching lines...) Expand all
274 } 265 }
275 266
276 base::ScopedTempDir temp_dir_; 267 base::ScopedTempDir temp_dir_;
277 base::FilePath profile_path_; 268 base::FilePath profile_path_;
278 base::FilePath app_path_; 269 base::FilePath app_path_;
279 }; 270 };
280 271
281 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 272 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
282 MAYBE_IMPORTER(Firefox30Importer)) { 273 MAYBE_IMPORTER(Firefox30Importer)) {
283 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); 274 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver());
284 Firefox3xImporterBrowserTest("firefox3_profile", observer.get(), 275 FirefoxImporterBrowserTest(
285 observer.get(), true); 276 "firefox3_profile", observer.get(), observer.get(), true);
286 } 277 }
287 278
288 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 279 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
289 MAYBE_IMPORTER(Firefox35Importer)) { 280 MAYBE_IMPORTER(Firefox35Importer)) {
290 bool import_search_engines = false; 281 bool import_search_engines = false;
291 scoped_refptr<FirefoxObserver> observer( 282 scoped_refptr<FirefoxObserver> observer(
292 new FirefoxObserver(import_search_engines)); 283 new FirefoxObserver(import_search_engines));
293 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), 284 FirefoxImporterBrowserTest("firefox35_profile",
294 observer.get(), import_search_engines); 285 observer.get(),
286 observer.get(),
287 import_search_engines);
295 } 288 }
289
290 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, FirefoxImporter) {
291 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver());
292 FirefoxImporterBrowserTest(
293 "firefox_profile", observer.get(), observer.get(), true);
294 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/firefox_profile/README » ('j') | chrome/test/data/firefox_profile/README » ('J')

Powered by Google App Engine
This is Rietveld 408576698