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

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

Issue 800433002: Search for history items that was imported from IE is not working. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed some issues/comments found by Gab@ Created 5 years, 12 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
« no previous file with comments | « no previous file | chrome/utility/importer/ie_importer_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The order of these includes is important. 5 // The order of these includes is important.
6 #include <windows.h> 6 #include <windows.h>
7 #include <unknwn.h> 7 #include <unknwn.h>
8 #include <intshcut.h> 8 #include <intshcut.h>
9 #include <propvarutil.h> 9 #include <propvarutil.h>
10 #include <shlguid.h> 10 #include <shlguid.h>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 {false, 0, {}, L"a", "http://www.google.com/0"}, 78 {false, 0, {}, L"a", "http://www.google.com/0"},
79 {false, 1, {"b"}, L"a", "http://www.google.com/1"}, 79 {false, 1, {"b"}, L"a", "http://www.google.com/1"},
80 {false, 1, {"b"}, L"b", "http://www.google.com/2"}, 80 {false, 1, {"b"}, L"b", "http://www.google.com/2"},
81 {false, 0, {}, L"c", "http://www.google.com/3"}, 81 {false, 0, {}, L"c", "http://www.google.com/3"},
82 }; 82 };
83 83
84 const base::char16 kIEIdentifyUrl[] = 84 const base::char16 kIEIdentifyUrl[] =
85 L"http://A79029D6-753E-4e27-B807-3D46AB1545DF.com:8080/path?key=value"; 85 L"http://A79029D6-753E-4e27-B807-3D46AB1545DF.com:8080/path?key=value";
86 const base::char16 kIEIdentifyTitle[] = 86 const base::char16 kIEIdentifyTitle[] =
87 L"Unittest GUID"; 87 L"Unittest GUID";
88 const base::char16 kIECacheItemUrl[] =
89 L"http://B2EF40C8-2569-4D7E-97EA-BAD9DF468D9C.com";
90 const base::char16 kIECacheItemTitle[] =
91 L"Unittest Cache Item GUID";
88 92
89 const base::char16 kFaviconStreamSuffix[] = L"url:favicon:$DATA"; 93 const base::char16 kFaviconStreamSuffix[] = L"url:favicon:$DATA";
90 const char kDummyFaviconImageData[] = 94 const char kDummyFaviconImageData[] =
91 "\x42\x4D" // Magic signature 'BM' 95 "\x42\x4D" // Magic signature 'BM'
92 "\x1E\x00\x00\x00" // File size 96 "\x1E\x00\x00\x00" // File size
93 "\x00\x00\x00\x00" // Reserved 97 "\x00\x00\x00\x00" // Reserved
94 "\x1A\x00\x00\x00" // Offset of the pixel data 98 "\x1A\x00\x00\x00" // Offset of the pixel data
95 "\x0C\x00\x00\x00" // Header Size 99 "\x0C\x00\x00\x00" // Header Size
96 "\x01\x00\x01\x00" // Size: 1x1 100 "\x01\x00\x01\x00" // Size: 1x1
97 "\x01\x00" // Reserved 101 "\x01\x00" // Reserved
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 virtual void ImportStarted() override {} 238 virtual void ImportStarted() override {}
235 virtual void ImportItemStarted(importer::ImportItem item) override {} 239 virtual void ImportItemStarted(importer::ImportItem item) override {}
236 virtual void ImportItemEnded(importer::ImportItem item) override {} 240 virtual void ImportItemEnded(importer::ImportItem item) override {}
237 virtual void ImportEnded() override { 241 virtual void ImportEnded() override {
238 base::MessageLoop::current()->Quit(); 242 base::MessageLoop::current()->Quit();
239 if (importer_items_ & importer::FAVORITES) { 243 if (importer_items_ & importer::FAVORITES) {
240 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_); 244 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_);
241 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_); 245 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_);
242 } 246 }
243 if (importer_items_ & importer::HISTORY) 247 if (importer_items_ & importer::HISTORY)
244 EXPECT_EQ(1, history_count_); 248 EXPECT_EQ(2, history_count_);
245 if (importer_items_ & importer::HOME_PAGE) 249 if (importer_items_ & importer::HOME_PAGE)
246 EXPECT_EQ(1, homepage_count_); 250 EXPECT_EQ(1, homepage_count_);
247 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7)) 251 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7))
248 EXPECT_EQ(1, ie7_password_count_); 252 EXPECT_EQ(1, ie7_password_count_);
249 // We need to test the IE6 password importer code. 253 // We need to test the IE6 password importer code.
250 // https://crbug.com/257100 254 // https://crbug.com/257100
251 // EXPECT_EQ(1, password_count_); 255 // EXPECT_EQ(1, password_count_);
252 } 256 }
253 257
254 virtual bool BookmarkModelIsLoaded() const { 258 virtual bool BookmarkModelIsLoaded() const {
(...skipping 12 matching lines...) Expand all
267 EXPECT_EQ(L"user", form.username_element); 271 EXPECT_EQ(L"user", form.username_element);
268 EXPECT_EQ(L"1", form.username_value); 272 EXPECT_EQ(L"1", form.username_value);
269 EXPECT_EQ(L"", form.password_element); 273 EXPECT_EQ(L"", form.password_element);
270 EXPECT_EQ(L"2", form.password_value); 274 EXPECT_EQ(L"2", form.password_value);
271 EXPECT_EQ("", form.action.spec()); 275 EXPECT_EQ("", form.action.spec());
272 ++password_count_; 276 ++password_count_;
273 } 277 }
274 278
275 virtual void AddHistoryPage(const history::URLRows& page, 279 virtual void AddHistoryPage(const history::URLRows& page,
276 history::VisitSource visit_source) { 280 history::VisitSource visit_source) {
281 bool cache_item_found = false;
282 bool history_item_found = false;
277 // Importer should read the specified URL. 283 // Importer should read the specified URL.
278 for (size_t i = 0; i < page.size(); ++i) { 284 for (size_t i = 0; i < page.size(); ++i) {
279 if (page[i].title() == kIEIdentifyTitle && 285 if (page[i].title() == kIEIdentifyTitle &&
280 page[i].url() == GURL(kIEIdentifyUrl)) 286 page[i].url() == GURL(kIEIdentifyUrl)) {
287 EXPECT_FALSE(page[i].hidden());
288 history_item_found = true;
281 ++history_count_; 289 ++history_count_;
290 }
291 if (page[i].title() == kIECacheItemTitle &&
292 page[i].url() == GURL(kIECacheItemUrl)) {
293 EXPECT_TRUE(page[i].hidden());
294 cache_item_found = true;
295 ++history_count_;
296 }
282 } 297 }
298 EXPECT_TRUE(history_item_found);
299 EXPECT_TRUE(cache_item_found);
283 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); 300 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source);
284 } 301 }
285 302
286 virtual void AddBookmarks( 303 virtual void AddBookmarks(
287 const std::vector<ImportedBookmarkEntry>& bookmarks, 304 const std::vector<ImportedBookmarkEntry>& bookmarks,
288 const base::string16& top_level_folder_name) override { 305 const base::string16& top_level_folder_name) override {
289 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks)); 306 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks));
290 // Importer should import the IE Favorites folder the same as the list, 307 // Importer should import the IE Favorites folder the same as the list,
291 // in the same order. 308 // in the same order.
292 for (size_t i = 0; i < bookmarks.size(); ++i) { 309 for (size_t i = 0; i < bookmarks.size(); ++i) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 L"SubFolder", 483 L"SubFolder",
467 L"WithPortAndQuery.url", 484 L"WithPortAndQuery.url",
468 L"a", 485 L"a",
469 L"SubFolder.url", 486 L"SubFolder.url",
470 }; 487 };
471 ASSERT_TRUE(CreateOrderBlob( 488 ASSERT_TRUE(CreateOrderBlob(
472 base::FilePath(path), L"", 489 base::FilePath(path), L"",
473 std::vector<base::string16>(root_links, 490 std::vector<base::string16>(root_links,
474 root_links + arraysize(root_links)))); 491 root_links + arraysize(root_links))));
475 492
476 HRESULT res;
477
478 // Sets up a special history link. 493 // Sets up a special history link.
479 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; 494 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2;
480 res = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, 495 ASSERT_EQ(S_OK, url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL,
481 CLSCTX_INPROC_SERVER); 496 CLSCTX_INPROC_SERVER));
482 ASSERT_TRUE(res == S_OK); 497 // Usage of ADDURL_ADDTOHISTORYANDCACHE and ADDURL_ADDTOCACHE flags
483 res = url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle, 0); 498 // is explained in the article:
484 ASSERT_TRUE(res == S_OK); 499 // http://msdn.microsoft.com/ru-ru/aa767730
500 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle,
501 ADDURL_ADDTOHISTORYANDCACHE));
502 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIECacheItemUrl, kIECacheItemTitle,
503 ADDURL_ADDTOCACHE));
485 504
486 // Starts to import the above settings. 505 // Starts to import the above settings.
487 // Deletes itself. 506 // Deletes itself.
488 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; 507 ExternalProcessImporterHost* host = new ExternalProcessImporterHost;
489 TestObserver* observer = new TestObserver( 508 TestObserver* observer = new TestObserver(
490 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, 509 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
491 TestObserver::IE6); 510 TestObserver::IE6);
492 host->set_observer(observer); 511 host->set_observer(observer);
493 512
494 importer::SourceProfile source_profile; 513 importer::SourceProfile source_profile;
495 source_profile.importer_type = importer::TYPE_IE; 514 source_profile.importer_type = importer::TYPE_IE;
496 source_profile.source_path = temp_dir_.path(); 515 source_profile.source_path = temp_dir_.path();
497 516
498 host->StartImportSettings( 517 host->StartImportSettings(
499 source_profile, 518 source_profile,
500 browser()->profile(), 519 browser()->profile(),
501 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, 520 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
502 observer); 521 observer);
503 base::MessageLoop::current()->Run(); 522 base::MessageLoop::current()->Run();
504 523
505 // Cleans up. 524 // Cleans up.
506 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0); 525 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0);
526 url_history_stg2->DeleteUrl(kIECacheItemUrl, 0);
507 url_history_stg2.Release(); 527 url_history_stg2.Release();
508 } 528 }
509 529
510 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, 530 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest,
511 IEImporterMalformedFavoritesRegistry) { 531 IEImporterMalformedFavoritesRegistry) {
512 // Sets up a favorites folder. 532 // Sets up a favorites folder.
513 base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); 533 base::FilePath path = temp_dir_.path().AppendASCII("Favorites");
514 CreateDirectory(path.value().c_str(), NULL); 534 CreateDirectory(path.value().c_str(), NULL);
515 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL); 535 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL);
516 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"), 536 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"),
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 source_profile.source_path = temp_dir_.path(); 646 source_profile.source_path = temp_dir_.path();
627 647
628 host->StartImportSettings( 648 host->StartImportSettings(
629 source_profile, 649 source_profile,
630 browser()->profile(), 650 browser()->profile(),
631 importer::HOME_PAGE, 651 importer::HOME_PAGE,
632 observer); 652 observer);
633 base::MessageLoop::current()->Run(); 653 base::MessageLoop::current()->Run();
634 } 654 }
635 655
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/importer/ie_importer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698