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

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: Added/expanded comments for IE history API. 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 // 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;
gab 2014/12/17 18:55:30 No '_' suffix for local variables.
Alexey Seren 2014/12/18 12:08:15 Acknowledged.
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
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; 493 HRESULT res;
477 494
478 // Sets up a special history link. 495 // Sets up a special history link.
479 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; 496 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2;
480 res = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, 497 res = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL,
481 CLSCTX_INPROC_SERVER); 498 CLSCTX_INPROC_SERVER);
482 ASSERT_TRUE(res == S_OK); 499 ASSERT_TRUE(res == S_OK);
483 res = url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle, 0); 500 // Usage of ADDURL_ADDTOHISTORYANDCACHE and ADDURL_ADDTOCACHE flags
501 // is explained in the article:
502 // http://msdn.microsoft.com/ru-ru/aa767730
503 res = url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle,
504 ADDURL_ADDTOHISTORYANDCACHE);
505 ASSERT_TRUE(res == S_OK);
506 res = url_history_stg2->AddUrl(kIECacheItemUrl, kIECacheItemTitle,
507 ADDURL_ADDTOCACHE);
484 ASSERT_TRUE(res == S_OK); 508 ASSERT_TRUE(res == S_OK);
485 509
486 // Starts to import the above settings. 510 // Starts to import the above settings.
487 // Deletes itself. 511 // Deletes itself.
488 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; 512 ExternalProcessImporterHost* host = new ExternalProcessImporterHost;
489 TestObserver* observer = new TestObserver( 513 TestObserver* observer = new TestObserver(
490 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, 514 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
491 TestObserver::IE6); 515 TestObserver::IE6);
492 host->set_observer(observer); 516 host->set_observer(observer);
493 517
494 importer::SourceProfile source_profile; 518 importer::SourceProfile source_profile;
495 source_profile.importer_type = importer::TYPE_IE; 519 source_profile.importer_type = importer::TYPE_IE;
496 source_profile.source_path = temp_dir_.path(); 520 source_profile.source_path = temp_dir_.path();
497 521
498 host->StartImportSettings( 522 host->StartImportSettings(
499 source_profile, 523 source_profile,
500 browser()->profile(), 524 browser()->profile(),
501 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, 525 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
502 observer); 526 observer);
503 base::MessageLoop::current()->Run(); 527 base::MessageLoop::current()->Run();
504 528
505 // Cleans up. 529 // Cleans up.
506 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0); 530 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0);
531 url_history_stg2->DeleteUrl(kIECacheItemUrl, 0);
507 url_history_stg2.Release(); 532 url_history_stg2.Release();
508 } 533 }
509 534
510 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, 535 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest,
511 IEImporterMalformedFavoritesRegistry) { 536 IEImporterMalformedFavoritesRegistry) {
512 // Sets up a favorites folder. 537 // Sets up a favorites folder.
513 base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); 538 base::FilePath path = temp_dir_.path().AppendASCII("Favorites");
514 CreateDirectory(path.value().c_str(), NULL); 539 CreateDirectory(path.value().c_str(), NULL);
515 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL); 540 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL);
516 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"), 541 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(); 651 source_profile.source_path = temp_dir_.path();
627 652
628 host->StartImportSettings( 653 host->StartImportSettings(
629 source_profile, 654 source_profile,
630 browser()->profile(), 655 browser()->profile(),
631 importer::HOME_PAGE, 656 importer::HOME_PAGE,
632 observer); 657 observer);
633 base::MessageLoop::current()->Run(); 658 base::MessageLoop::current()->Run();
634 } 659 }
635 660
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/importer/ie_importer_win.cc » ('j') | chrome/utility/importer/ie_importer_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698