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

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

Issue 616763002: Importing certain bookmarks from firefox and HTML file as search engines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handled potential NULL pointer exception that could have resulted from CreateTemplateURL. Created 6 years 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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}"}, 91 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}"},
92 {L"search.yahoo.com", L"search.yahoo.com", 92 {L"search.yahoo.com", L"search.yahoo.com",
93 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8"}, 93 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8"},
94 {L"flickr.com", L"flickr.com", 94 {L"flickr.com", L"flickr.com",
95 "http://www.flickr.com/photos/tags/?q={searchTerms}"}, 95 "http://www.flickr.com/photos/tags/?q={searchTerms}"},
96 {L"imdb.com", L"imdb.com", "http://www.imdb.com/find?q={searchTerms}"}, 96 {L"imdb.com", L"imdb.com", "http://www.imdb.com/find?q={searchTerms}"},
97 {L"webster.com", L"webster.com", 97 {L"webster.com", L"webster.com",
98 "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}"}, 98 "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}"},
99 // Search keywords. 99 // Search keywords.
100 {L"\x4E2D\x6587", L"\x4E2D\x6587", "http://www.google.com/"}, 100 {L"\x4E2D\x6587", L"\x4E2D\x6587", "http://www.google.com/"},
101 {L"keyword", L"keyword", "http://example.{searchTerms}.com/"},
102 // CreateTemplateURL will return NULL for the following bookmark.
Peter Kasting 2014/12/09 23:10:18 Nit: Since "CreateTemplateURL" doesn't otherwise a
Tapu Ghose 2014/12/10 04:41:55 Done.
103 // Consequently, it won't be imported as search engine.
Peter Kasting 2014/12/09 23:10:18 Nit: as -> as a
Tapu Ghose 2014/12/10 04:41:55 Done. Realized that we may not have any cases tha
Peter Kasting 2014/12/10 17:41:16 We should probably still have the test, as we don'
Tapu Ghose 2014/12/11 03:12:21 Acknowledged.
104 {L"", L"", "http://%x.example.{searchTerms}.com/"},
101 }; 105 };
102 106
103 const AutofillFormDataInfo kFirefoxAutofillEntries[] = { 107 const AutofillFormDataInfo kFirefoxAutofillEntries[] = {
104 {"name", "John"}, 108 {"name", "John"},
105 {"address", "#123 Cherry Ave"}, 109 {"address", "#123 Cherry Ave"},
106 {"city", "Mountain View"}, 110 {"city", "Mountain View"},
107 {"zip", "94043"}, 111 {"zip", "94043"},
108 {"n300", "+1 (408) 871-4567"}, 112 {"n300", "+1 (408) 871-4567"},
109 {"name", "john"}, 113 {"name", "john"},
110 {"name", "aguantó"}, 114 {"name", "aguantó"},
(...skipping 17 matching lines...) Expand all
128 132
129 // importer::ImporterProgressObserver: 133 // importer::ImporterProgressObserver:
130 void ImportStarted() override {} 134 void ImportStarted() override {}
131 void ImportItemStarted(importer::ImportItem item) override {} 135 void ImportItemStarted(importer::ImportItem item) override {}
132 void ImportItemEnded(importer::ImportItem item) override {} 136 void ImportItemEnded(importer::ImportItem item) override {}
133 void ImportEnded() override { 137 void ImportEnded() override {
134 base::MessageLoop::current()->Quit(); 138 base::MessageLoop::current()->Quit();
135 EXPECT_EQ(arraysize(kFirefoxBookmarks), bookmark_count_); 139 EXPECT_EQ(arraysize(kFirefoxBookmarks), bookmark_count_);
136 EXPECT_EQ(1U, history_count_); 140 EXPECT_EQ(1U, history_count_);
137 EXPECT_EQ(arraysize(kFirefoxPasswords), password_count_); 141 EXPECT_EQ(arraysize(kFirefoxPasswords), password_count_);
138 EXPECT_EQ(arraysize(kFirefoxKeywords), keyword_count_); 142 // The following test case from |kFirefoxKeywords| won't be imported:
143 // "http://%x.example.{searchTerms}.com/"}.
144 // Hence, value of |keyword_count_| should be lower than size of
145 // |kFirefoxKeywords| by 1.
146 EXPECT_EQ(arraysize(kFirefoxKeywords) - 1, keyword_count_);
139 } 147 }
140 148
141 bool BookmarkModelIsLoaded() const override { 149 bool BookmarkModelIsLoaded() const override {
142 // Profile is ready for writing. 150 // Profile is ready for writing.
143 return true; 151 return true;
144 } 152 }
145 153
146 bool TemplateURLServiceIsLoaded() const override { return true; } 154 bool TemplateURLServiceIsLoaded() const override { return true; }
147 155
148 void AddPasswordForm(const autofill::PasswordForm& form) override { 156 void AddPasswordForm(const autofill::PasswordForm& form) override {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver(false)); 334 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver(false));
327 FirefoxImporterBrowserTest( 335 FirefoxImporterBrowserTest(
328 "firefox35_profile", observer.get(), observer.get()); 336 "firefox35_profile", observer.get(), observer.get());
329 } 337 }
330 338
331 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 339 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
332 MAYBE_IMPORTER(FirefoxImporter)) { 340 MAYBE_IMPORTER(FirefoxImporter)) {
333 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver(true)); 341 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver(true));
334 FirefoxImporterBrowserTest("firefox_profile", observer.get(), observer.get()); 342 FirefoxImporterBrowserTest("firefox_profile", observer.get(), observer.get());
335 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698