OLD | NEW |
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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 437 |
438 base::ScopedTempDir temp_dir_; | 438 base::ScopedTempDir temp_dir_; |
439 | 439 |
440 // Overrides the default registry key for IE registry keys like favorites, | 440 // Overrides the default registry key for IE registry keys like favorites, |
441 // settings, password store, etc. | 441 // settings, password store, etc. |
442 ImporterTestRegistryOverrider test_registry_overrider_; | 442 ImporterTestRegistryOverrider test_registry_overrider_; |
443 }; | 443 }; |
444 | 444 |
445 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporter) { | 445 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporter) { |
446 // Sets up a favorites folder. | 446 // Sets up a favorites folder. |
447 base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); | 447 base::FilePath path = temp_dir_.GetPath().AppendASCII("Favorites"); |
448 CreateDirectory(path.value().c_str(), NULL); | 448 CreateDirectory(path.value().c_str(), NULL); |
449 CreateDirectory(path.AppendASCII("SubFolder").value().c_str(), NULL); | 449 CreateDirectory(path.AppendASCII("SubFolder").value().c_str(), NULL); |
450 base::FilePath links_path = path.AppendASCII("Links"); | 450 base::FilePath links_path = path.AppendASCII("Links"); |
451 CreateDirectory(links_path.value().c_str(), NULL); | 451 CreateDirectory(links_path.value().c_str(), NULL); |
452 CreateDirectory(links_path.AppendASCII("SubFolderOfLinks").value().c_str(), | 452 CreateDirectory(links_path.AppendASCII("SubFolderOfLinks").value().c_str(), |
453 NULL); | 453 NULL); |
454 CreateDirectory(path.AppendASCII("\x0061").value().c_str(), NULL); | 454 CreateDirectory(path.AppendASCII("\x0061").value().c_str(), NULL); |
455 ASSERT_TRUE(CreateUrlFileWithFavicon(path.AppendASCII("Google Home Page.url"), | 455 ASSERT_TRUE(CreateUrlFileWithFavicon(path.AppendASCII("Google Home Page.url"), |
456 L"http://www.google.com/", | 456 L"http://www.google.com/", |
457 L"http://www.google.com/favicon.ico")); | 457 L"http://www.google.com/favicon.ico")); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // Starts to import the above settings. | 508 // Starts to import the above settings. |
509 // Deletes itself. | 509 // Deletes itself. |
510 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; | 510 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; |
511 TestObserver* observer = new TestObserver( | 511 TestObserver* observer = new TestObserver( |
512 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, | 512 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, |
513 TestObserver::IE6); | 513 TestObserver::IE6); |
514 host->set_observer(observer); | 514 host->set_observer(observer); |
515 | 515 |
516 importer::SourceProfile source_profile; | 516 importer::SourceProfile source_profile; |
517 source_profile.importer_type = importer::TYPE_IE; | 517 source_profile.importer_type = importer::TYPE_IE; |
518 source_profile.source_path = temp_dir_.path(); | 518 source_profile.source_path = temp_dir_.GetPath(); |
519 | 519 |
520 host->StartImportSettings( | 520 host->StartImportSettings( |
521 source_profile, | 521 source_profile, |
522 browser()->profile(), | 522 browser()->profile(), |
523 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, | 523 importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, |
524 observer); | 524 observer); |
525 base::RunLoop().Run(); | 525 base::RunLoop().Run(); |
526 | 526 |
527 // Cleans up. | 527 // Cleans up. |
528 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0); | 528 url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0); |
529 url_history_stg2->DeleteUrl(kIECacheItemUrl, 0); | 529 url_history_stg2->DeleteUrl(kIECacheItemUrl, 0); |
530 url_history_stg2.Release(); | 530 url_history_stg2.Release(); |
531 } | 531 } |
532 | 532 |
533 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, | 533 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, |
534 IEImporterMalformedFavoritesRegistry) { | 534 IEImporterMalformedFavoritesRegistry) { |
535 // Sets up a favorites folder. | 535 // Sets up a favorites folder. |
536 base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); | 536 base::FilePath path = temp_dir_.GetPath().AppendASCII("Favorites"); |
537 CreateDirectory(path.value().c_str(), NULL); | 537 CreateDirectory(path.value().c_str(), NULL); |
538 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL); | 538 CreateDirectory(path.AppendASCII("b").value().c_str(), NULL); |
539 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"), | 539 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"), |
540 L"http://www.google.com/0")); | 540 L"http://www.google.com/0")); |
541 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("a.url"), | 541 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("a.url"), |
542 L"http://www.google.com/1")); | 542 L"http://www.google.com/1")); |
543 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("b.url"), | 543 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("b").AppendASCII("b.url"), |
544 L"http://www.google.com/2")); | 544 L"http://www.google.com/2")); |
545 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("c.url"), | 545 ASSERT_TRUE(CreateUrlFile(path.AppendASCII("c.url"), |
546 L"http://www.google.com/3")); | 546 L"http://www.google.com/3")); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 586 |
587 // Starts to import the above settings. | 587 // Starts to import the above settings. |
588 // Deletes itself. | 588 // Deletes itself. |
589 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; | 589 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; |
590 MalformedFavoritesRegistryTestObserver* observer = | 590 MalformedFavoritesRegistryTestObserver* observer = |
591 new MalformedFavoritesRegistryTestObserver(); | 591 new MalformedFavoritesRegistryTestObserver(); |
592 host->set_observer(observer); | 592 host->set_observer(observer); |
593 | 593 |
594 importer::SourceProfile source_profile; | 594 importer::SourceProfile source_profile; |
595 source_profile.importer_type = importer::TYPE_IE; | 595 source_profile.importer_type = importer::TYPE_IE; |
596 source_profile.source_path = temp_dir_.path(); | 596 source_profile.source_path = temp_dir_.GetPath(); |
597 | 597 |
598 host->StartImportSettings( | 598 host->StartImportSettings( |
599 source_profile, | 599 source_profile, |
600 browser()->profile(), | 600 browser()->profile(), |
601 importer::FAVORITES, | 601 importer::FAVORITES, |
602 observer); | 602 observer); |
603 base::RunLoop().Run(); | 603 base::RunLoop().Run(); |
604 } | 604 } |
605 } | 605 } |
606 | 606 |
607 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IE7ImporterPasswordsTest) { | 607 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IE7ImporterPasswordsTest) { |
608 // Starts to import the IE7 passwords. | 608 // Starts to import the IE7 passwords. |
609 // Deletes itself. | 609 // Deletes itself. |
610 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; | 610 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; |
611 TestObserver* observer = new TestObserver(importer::PASSWORDS, | 611 TestObserver* observer = new TestObserver(importer::PASSWORDS, |
612 TestObserver::IE7); | 612 TestObserver::IE7); |
613 host->set_observer(observer); | 613 host->set_observer(observer); |
614 | 614 |
615 base::string16 key_path(importer::GetIE7PasswordsKey()); | 615 base::string16 key_path(importer::GetIE7PasswordsKey()); |
616 base::win::RegKey key; | 616 base::win::RegKey key; |
617 ASSERT_EQ(ERROR_SUCCESS, | 617 ASSERT_EQ(ERROR_SUCCESS, |
618 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); | 618 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); |
619 key.WriteValue(L"Test1", 1); | 619 key.WriteValue(L"Test1", 1); |
620 | 620 |
621 importer::SourceProfile source_profile; | 621 importer::SourceProfile source_profile; |
622 source_profile.importer_type = importer::TYPE_IE; | 622 source_profile.importer_type = importer::TYPE_IE; |
623 source_profile.source_path = temp_dir_.path(); | 623 source_profile.source_path = temp_dir_.GetPath(); |
624 | 624 |
625 host->StartImportSettings( | 625 host->StartImportSettings( |
626 source_profile, | 626 source_profile, |
627 browser()->profile(), | 627 browser()->profile(), |
628 importer::PASSWORDS, | 628 importer::PASSWORDS, |
629 observer); | 629 observer); |
630 base::RunLoop().Run(); | 630 base::RunLoop().Run(); |
631 } | 631 } |
632 | 632 |
633 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporterHomePageTest) { | 633 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporterHomePageTest) { |
634 // Starts to import the IE home page. | 634 // Starts to import the IE home page. |
635 // Deletes itself. | 635 // Deletes itself. |
636 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; | 636 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; |
637 TestObserver* observer = new TestObserver(importer::HOME_PAGE, | 637 TestObserver* observer = new TestObserver(importer::HOME_PAGE, |
638 TestObserver::IE6); | 638 TestObserver::IE6); |
639 host->set_observer(observer); | 639 host->set_observer(observer); |
640 | 640 |
641 base::string16 key_path(importer::GetIESettingsKey()); | 641 base::string16 key_path(importer::GetIESettingsKey()); |
642 base::win::RegKey key; | 642 base::win::RegKey key; |
643 ASSERT_EQ(ERROR_SUCCESS, | 643 ASSERT_EQ(ERROR_SUCCESS, |
644 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); | 644 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); |
645 key.WriteValue(L"Start Page", L"http://www.test.com/"); | 645 key.WriteValue(L"Start Page", L"http://www.test.com/"); |
646 | 646 |
647 importer::SourceProfile source_profile; | 647 importer::SourceProfile source_profile; |
648 source_profile.importer_type = importer::TYPE_IE; | 648 source_profile.importer_type = importer::TYPE_IE; |
649 source_profile.source_path = temp_dir_.path(); | 649 source_profile.source_path = temp_dir_.GetPath(); |
650 | 650 |
651 host->StartImportSettings( | 651 host->StartImportSettings( |
652 source_profile, | 652 source_profile, |
653 browser()->profile(), | 653 browser()->profile(), |
654 importer::HOME_PAGE, | 654 importer::HOME_PAGE, |
655 observer); | 655 observer); |
656 base::RunLoop().Run(); | 656 base::RunLoop().Run(); |
657 } | 657 } |
658 | 658 |
OLD | NEW |