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

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

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test cleanup Created 7 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 | Annotate | Revision Log
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.h" 8 #include "base/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"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/history/history_types.h" 14 #include "chrome/browser/bookmarks/imported_bookmark_entry.h"
15 #include "chrome/browser/favicon/imported_favicon_usage.h"
15 #include "chrome/browser/importer/external_process_importer_host.h" 16 #include "chrome/browser/importer/external_process_importer_host.h"
16 #include "chrome/browser/importer/firefox_importer_unittest_utils.h" 17 #include "chrome/browser/importer/firefox_importer_unittest_utils.h"
17 #include "chrome/browser/importer/importer_data_types.h" 18 #include "chrome/browser/importer/importer_data_types.h"
18 #include "chrome/browser/importer/importer_host.h" 19 #include "chrome/browser/importer/importer_host.h"
19 #include "chrome/browser/importer/importer_progress_observer.h" 20 #include "chrome/browser/importer/importer_progress_observer.h"
20 #include "chrome/browser/importer/importer_unittest_utils.h" 21 #include "chrome/browser/importer/importer_unittest_utils.h"
21 #include "chrome/browser/search_engines/template_url.h" 22 #include "chrome/browser/search_engines/template_url.h"
22 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
23 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
24 #include "chrome/test/base/in_process_browser_test.h" 25 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 168
168 virtual void AddHistoryPage(const history::URLRows& page, 169 virtual void AddHistoryPage(const history::URLRows& page,
169 history::VisitSource visit_source) OVERRIDE { 170 history::VisitSource visit_source) OVERRIDE {
170 ASSERT_EQ(1U, page.size()); 171 ASSERT_EQ(1U, page.size());
171 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec()); 172 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec());
172 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title()); 173 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title());
173 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 174 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
174 ++history_count_; 175 ++history_count_;
175 } 176 }
176 177
177 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, 178 virtual void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
178 const string16& top_level_folder_name) OVERRIDE { 179 const string16& top_level_folder_name) OVERRIDE {
179 ASSERT_LE(bookmark_count_ + bookmarks.size(), 180 ASSERT_LE(bookmark_count_ + bookmarks.size(),
180 arraysize(kFirefox2Bookmarks)); 181 arraysize(kFirefox2Bookmarks));
181 // Importer should import the FF favorites the same as the list, in the same 182 // Importer should import the FF favorites the same as the list, in the same
182 // order. 183 // order.
183 for (size_t i = 0; i < bookmarks.size(); ++i) { 184 for (size_t i = 0; i < bookmarks.size(); ++i) {
184 EXPECT_NO_FATAL_FAILURE( 185 EXPECT_NO_FATAL_FAILURE(
185 TestEqualBookmarkEntry(bookmarks[i], 186 TestEqualBookmarkEntry(bookmarks[i],
186 kFirefox2Bookmarks[bookmark_count_])) << i; 187 kFirefox2Bookmarks[bookmark_count_])) << i;
187 ++bookmark_count_; 188 ++bookmark_count_;
(...skipping 14 matching lines...) Expand all
202 found = true; 203 found = true;
203 break; 204 break;
204 } 205 }
205 } 206 }
206 EXPECT_TRUE(found); 207 EXPECT_TRUE(found);
207 ++keyword_count_; 208 ++keyword_count_;
208 } 209 }
209 } 210 }
210 211
211 virtual void AddFavicons( 212 virtual void AddFavicons(
212 const std::vector<history::ImportedFaviconUsage>& favicons) OVERRIDE { 213 const std::vector<ImportedFaviconUsage>& favicons) OVERRIDE {
213 } 214 }
214 215
215 private: 216 private:
216 virtual ~FirefoxObserver() {} 217 virtual ~FirefoxObserver() {}
217 218
218 size_t bookmark_count_; 219 size_t bookmark_count_;
219 size_t history_count_; 220 size_t history_count_;
220 size_t password_count_; 221 size_t password_count_;
221 size_t keyword_count_; 222 size_t keyword_count_;
222 }; 223 };
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title()); 324 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title());
324 EXPECT_EQ("http://www.google.com/", page[1].url().spec()); 325 EXPECT_EQ("http://www.google.com/", page[1].url().spec());
325 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title()); 326 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title());
326 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/" 327 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/"
327 "form1-POST.html", page[2].url().spec()); 328 "form1-POST.html", page[2].url().spec());
328 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title()); 329 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title());
329 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 330 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
330 ++history_count_; 331 ++history_count_;
331 } 332 }
332 333
333 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, 334 virtual void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
334 const string16& top_level_folder_name) OVERRIDE { 335 const string16& top_level_folder_name) OVERRIDE {
335 336
336 ASSERT_LE(bookmark_count_ + bookmarks.size(), 337 ASSERT_LE(bookmark_count_ + bookmarks.size(),
337 arraysize(kFirefox3Bookmarks)); 338 arraysize(kFirefox3Bookmarks));
338 // Importer should import the FF favorites the same as the list, in the same 339 // Importer should import the FF favorites the same as the list, in the same
339 // order. 340 // order.
340 for (size_t i = 0; i < bookmarks.size(); ++i) { 341 for (size_t i = 0; i < bookmarks.size(); ++i) {
341 EXPECT_NO_FATAL_FAILURE( 342 EXPECT_NO_FATAL_FAILURE(
342 TestEqualBookmarkEntry(bookmarks[i], 343 TestEqualBookmarkEntry(bookmarks[i],
343 kFirefox3Bookmarks[bookmark_count_])) << i; 344 kFirefox3Bookmarks[bookmark_count_])) << i;
(...skipping 15 matching lines...) Expand all
359 found = true; 360 found = true;
360 break; 361 break;
361 } 362 }
362 } 363 }
363 EXPECT_TRUE(found); 364 EXPECT_TRUE(found);
364 ++keyword_count_; 365 ++keyword_count_;
365 } 366 }
366 } 367 }
367 368
368 virtual void AddFavicons( 369 virtual void AddFavicons(
369 const std::vector<history::ImportedFaviconUsage>& favicons) OVERRIDE { 370 const std::vector<ImportedFaviconUsage>& favicons) OVERRIDE {
370 } 371 }
371 372
372 private: 373 private:
373 virtual ~Firefox3Observer() {} 374 virtual ~Firefox3Observer() {}
374 375
375 size_t bookmark_count_; 376 size_t bookmark_count_;
376 size_t history_count_; 377 size_t history_count_;
377 size_t password_count_; 378 size_t password_count_;
378 size_t keyword_count_; 379 size_t keyword_count_;
379 bool import_search_engines_; 380 bool import_search_engines_;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 512 }
512 513
513 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, 514 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest,
514 MAYBE_IMPORTER(Firefox35Importer)) { 515 MAYBE_IMPORTER(Firefox35Importer)) {
515 bool import_search_engines = false; 516 bool import_search_engines = false;
516 scoped_refptr<Firefox3Observer> observer( 517 scoped_refptr<Firefox3Observer> observer(
517 new Firefox3Observer(import_search_engines)); 518 new Firefox3Observer(import_search_engines));
518 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), 519 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(),
519 observer.get(), import_search_engines); 520 observer.get(), import_search_engines);
520 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698