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

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

Issue 6979007: Many fixes to bookmark importing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Happy tests =) Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 // The order of these includes is important. 8 // The order of these includes is important.
9 #include <windows.h> 9 #include <windows.h>
10 #include <unknwn.h> 10 #include <unknwn.h>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 if (equal) 147 if (equal)
148 return true; 148 return true;
149 } 149 }
150 } 150 }
151 return false; 151 return false;
152 } 152 }
153 153
154 #if defined(OS_WIN) 154 #if defined(OS_WIN)
155 static const BookmarkList kIEBookmarks[] = { 155 static const BookmarkList kIEBookmarks[] = {
156 {true, 0, {}, 156 {true, 1, {L"Links"},
157 L"TheLink", 157 L"TheLink",
158 "http://www.links-thelink.com/"}, 158 "http://www.links-thelink.com/"},
159 {true, 1, {L"SubFolderOfLinks"}, 159 {true, 2, {L"Links", L"SubFolderOfLinks"},
160 L"SubLink", 160 L"SubLink",
161 "http://www.links-sublink.com/"}, 161 "http://www.links-sublink.com/"},
162 {false, 0, {}, 162 {false, 0, {},
163 L"Google Home Page", 163 L"Google Home Page",
164 "http://www.google.com/"}, 164 "http://www.google.com/"},
165 {false, 0, {}, 165 {false, 0, {},
166 L"TheLink", 166 L"TheLink",
167 "http://www.links-thelink.com/"}, 167 "http://www.links-thelink.com/"},
168 {false, 1, {L"SubFolder"}, 168 {false, 1, {L"SubFolder"},
169 L"Title", 169 L"Title",
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 history::VisitSource visit_source) { 231 history::VisitSource visit_source) {
232 // Importer should read the specified URL. 232 // Importer should read the specified URL.
233 for (size_t i = 0; i < page.size(); ++i) { 233 for (size_t i = 0; i < page.size(); ++i) {
234 if (page[i].title() == kIEIdentifyTitle && 234 if (page[i].title() == kIEIdentifyTitle &&
235 page[i].url() == GURL(kIEIdentifyUrl)) 235 page[i].url() == GURL(kIEIdentifyUrl))
236 ++history_count_; 236 ++history_count_;
237 } 237 }
238 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); 238 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source);
239 } 239 }
240 240
241 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark, 241 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
242 const string16& first_folder_name, 242 const string16& top_level_folder_name) OVERRIDE {
243 int options) OVERRIDE {
244 // Importer should import the IE Favorites folder the same as the list. 243 // Importer should import the IE Favorites folder the same as the list.
245 for (size_t i = 0; i < bookmark.size(); ++i) { 244 for (size_t i = 0; i < bookmarks.size(); ++i) {
246 if (FindBookmarkEntry(bookmark[i], kIEBookmarks, 245 if (FindBookmarkEntry(bookmarks[i], kIEBookmarks,
247 arraysize(kIEBookmarks))) 246 arraysize(kIEBookmarks)))
248 ++bookmark_count_; 247 ++bookmark_count_;
249 } 248 }
250 } 249 }
251 250
252 virtual void AddKeyword(std::vector<TemplateURL*> template_url, 251 virtual void AddKeyword(std::vector<TemplateURL*> template_url,
253 int default_keyword_index) { 252 int default_keyword_index) {
254 // TODO(jcampan): bug 1169230: we should test keyword importing for IE. 253 // TODO(jcampan): bug 1169230: we should test keyword importing for IE.
255 // In order to do that we'll probably need to mock the Windows registry. 254 // In order to do that we'll probably need to mock the Windows registry.
256 NOTREACHED(); 255 NOTREACHED();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EXPECT_EQ(L"abcdefghijkl", password); 457 EXPECT_EQ(L"abcdefghijkl", password);
459 458
460 ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &username, 459 ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &username,
461 &password)); 460 &password));
462 EXPECT_EQ(L"abcdefghi", username); 461 EXPECT_EQ(L"abcdefghi", username);
463 EXPECT_EQ(L"abcdefg", password); 462 EXPECT_EQ(L"abcdefg", password);
464 } 463 }
465 #endif // defined(OS_WIN) 464 #endif // defined(OS_WIN)
466 465
467 static const BookmarkList kFirefox2Bookmarks[] = { 466 static const BookmarkList kFirefox2Bookmarks[] = {
468 {true, 1, {L"Folder"}, 467 {true, 2, {L"Bookmarks Toolbar Folder", L"Folder"},
469 L"On Toolbar's Subfolder", 468 L"On Toolbar's Subfolder",
470 "http://on.toolbar/bookmark/folder"}, 469 "http://on.toolbar/bookmark/folder"},
471 {true, 0, {}, 470 {true, 1, {L"Bookmarks Toolbar Folder"},
472 L"On Bookmark Toolbar", 471 L"On Bookmark Toolbar",
473 "http://on.toolbar/bookmark"}, 472 "http://on.toolbar/bookmark"},
474 {false, 1, {L"Folder"}, 473 {false, 1, {L"Folder"},
475 L"New Bookmark", 474 L"New Bookmark",
476 "http://domain/"}, 475 "http://domain/"},
477 {false, 0, {}, 476 {false, 0, {},
478 L"<Name>", 477 L"<Name>",
479 "http://domain.com/q?a=%22er%22&b=%3C%20%20%3E"}, 478 "http://domain.com/q?a=%22er%22&b=%3C%20%20%3E"},
480 {false, 0, {}, 479 {false, 0, {},
481 L"Google Home Page", 480 L"Google Home Page",
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 596
598 virtual void AddHistoryPage(const std::vector<history::URLRow>& page, 597 virtual void AddHistoryPage(const std::vector<history::URLRow>& page,
599 history::VisitSource visit_source) { 598 history::VisitSource visit_source) {
600 ASSERT_EQ(1U, page.size()); 599 ASSERT_EQ(1U, page.size());
601 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec()); 600 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec());
602 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title()); 601 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title());
603 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 602 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
604 ++history_count_; 603 ++history_count_;
605 } 604 }
606 605
607 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark, 606 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
608 const string16& first_folder_name, 607 const string16& top_level_folder_name) OVERRIDE {
609 int options) OVERRIDE { 608 for (size_t i = 0; i < bookmarks.size(); ++i) {
610 for (size_t i = 0; i < bookmark.size(); ++i) { 609 if (FindBookmarkEntry(bookmarks[i], kFirefox2Bookmarks,
611 if (FindBookmarkEntry(bookmark[i], kFirefox2Bookmarks,
612 arraysize(kFirefox2Bookmarks))) 610 arraysize(kFirefox2Bookmarks)))
613 ++bookmark_count_; 611 ++bookmark_count_;
614 } 612 }
615 } 613 }
616 614
617 virtual void AddKeywords(const std::vector<TemplateURL*>& template_urls, 615 virtual void AddKeywords(const std::vector<TemplateURL*>& template_urls,
618 int default_keyword_index, 616 int default_keyword_index,
619 bool unique_on_host_and_path) { 617 bool unique_on_host_and_path) {
620 for (size_t i = 0; i < template_urls.size(); ++i) { 618 for (size_t i = 0; i < template_urls.size(); ++i) {
621 // The order might not be deterministic, look in the expected list for 619 // The order might not be deterministic, look in the expected list for
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 source_profile, 692 source_profile,
695 static_cast<Profile*>(NULL), 693 static_cast<Profile*>(NULL),
696 importer::HISTORY | importer::PASSWORDS | 694 importer::HISTORY | importer::PASSWORDS |
697 importer::FAVORITES | importer::SEARCH_ENGINES, 695 importer::FAVORITES | importer::SEARCH_ENGINES,
698 make_scoped_refptr(observer), 696 make_scoped_refptr(observer),
699 true)); 697 true));
700 loop->Run(); 698 loop->Run();
701 } 699 }
702 700
703 static const BookmarkList kFirefox3Bookmarks[] = { 701 static const BookmarkList kFirefox3Bookmarks[] = {
704 {true, 0, {}, 702 {true, 1, {L"Bookmarks Toolbar"},
705 L"Toolbar", 703 L"Toolbar",
706 "http://site/"}, 704 "http://site/"},
707 {false, 0, {}, 705 {false, 0, {},
708 L"Title", 706 L"Title",
709 "http://www.google.com/"}, 707 "http://www.google.com/"},
710 }; 708 };
711 709
712 static const PasswordList kFirefox3Passwords[] = { 710 static const PasswordList kFirefox3Passwords[] = {
713 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", 711 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/",
714 L"loginuser", L"abc", L"loginpass", L"123", false}, 712 L"loginuser", L"abc", L"loginpass", L"123", false},
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title()); 805 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title());
808 EXPECT_EQ("http://www.google.com/", page[1].url().spec()); 806 EXPECT_EQ("http://www.google.com/", page[1].url().spec());
809 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title()); 807 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title());
810 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/form1 -POST.html", 808 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/form1 -POST.html",
811 page[2].url().spec()); 809 page[2].url().spec());
812 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title()); 810 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title());
813 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 811 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
814 ++history_count_; 812 ++history_count_;
815 } 813 }
816 814
817 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark, 815 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
818 const string16& first_folder_name, 816 const string16& top_level_folder_name) OVERRIDE {
819 int options) OVERRIDE { 817 for (size_t i = 0; i < bookmarks.size(); ++i) {
820 for (size_t i = 0; i < bookmark.size(); ++i) { 818 if (FindBookmarkEntry(bookmarks[i], kFirefox3Bookmarks,
821 if (FindBookmarkEntry(bookmark[i], kFirefox3Bookmarks,
822 arraysize(kFirefox3Bookmarks))) 819 arraysize(kFirefox3Bookmarks)))
823 ++bookmark_count_; 820 ++bookmark_count_;
824 } 821 }
825 } 822 }
826 823
827 void AddKeywords(const std::vector<TemplateURL*>& template_urls, 824 void AddKeywords(const std::vector<TemplateURL*>& template_urls,
828 int default_keyword_index, 825 int default_keyword_index,
829 bool unique_on_host_and_path) { 826 bool unique_on_host_and_path) {
830 for (size_t i = 0; i < template_urls.size(); ++i) { 827 for (size_t i = 0; i < template_urls.size(); ++i) {
831 // The order might not be deterministic, look in the expected list for 828 // The order might not be deterministic, look in the expected list for
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 true); 872 true);
876 } 873 }
877 874
878 TEST_F(ImporterTest, MAYBE(Firefox35Importer)) { 875 TEST_F(ImporterTest, MAYBE(Firefox35Importer)) {
879 bool import_search_engines = false; 876 bool import_search_engines = false;
880 scoped_refptr<Firefox3Observer> observer( 877 scoped_refptr<Firefox3Observer> observer(
881 new Firefox3Observer(import_search_engines)); 878 new Firefox3Observer(import_search_engines));
882 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), 879 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(),
883 import_search_engines); 880 import_search_engines);
884 } 881 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/importer_host.cc ('k') | chrome/browser/importer/in_process_importer_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698