OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 } | 631 } |
632 | 632 |
633 virtual void AddKeywords(const std::vector<TemplateURL*>& template_urls, | 633 virtual void AddKeywords(const std::vector<TemplateURL*>& template_urls, |
634 int default_keyword_index, | 634 int default_keyword_index, |
635 bool unique_on_host_and_path) { | 635 bool unique_on_host_and_path) { |
636 for (size_t i = 0; i < template_urls.size(); ++i) { | 636 for (size_t i = 0; i < template_urls.size(); ++i) { |
637 // The order might not be deterministic, look in the expected list for | 637 // The order might not be deterministic, look in the expected list for |
638 // that template URL. | 638 // that template URL. |
639 bool found = false; | 639 bool found = false; |
640 string16 keyword = template_urls[i]->keyword(); | 640 std::wstring keyword = template_urls[i]->keyword(); |
641 for (size_t j = 0; j < arraysize(kFirefox2Keywords); ++j) { | 641 for (size_t j = 0; j < arraysize(kFirefox2Keywords); ++j) { |
642 if (template_urls[i]->keyword() == | 642 if (template_urls[i]->keyword() == kFirefox2Keywords[j].keyword) { |
643 WideToUTF16Hack(kFirefox2Keywords[j].keyword)) { | |
644 EXPECT_EQ(kFirefox2Keywords[j].url, template_urls[i]->url()->url()); | 643 EXPECT_EQ(kFirefox2Keywords[j].url, template_urls[i]->url()->url()); |
645 found = true; | 644 found = true; |
646 break; | 645 break; |
647 } | 646 } |
648 } | 647 } |
649 EXPECT_TRUE(found); | 648 EXPECT_TRUE(found); |
650 ++keyword_count_; | 649 ++keyword_count_; |
651 } | 650 } |
652 | 651 |
653 if (default_keyword_index != -1) { | 652 if (default_keyword_index != -1) { |
654 EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size())); | 653 EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size())); |
655 TemplateURL* default_turl = template_urls[default_keyword_index]; | 654 TemplateURL* default_turl = template_urls[default_keyword_index]; |
656 default_keyword_ = UTF16ToWideHack(default_turl->keyword()); | 655 default_keyword_ = default_turl->keyword(); |
657 default_keyword_url_ = default_turl->url()->url(); | 656 default_keyword_url_ = default_turl->url()->url(); |
658 } | 657 } |
659 | 658 |
660 STLDeleteContainerPointers(template_urls.begin(), template_urls.end()); | 659 STLDeleteContainerPointers(template_urls.begin(), template_urls.end()); |
661 } | 660 } |
662 | 661 |
663 void AddFavicons(const std::vector<history::ImportedFavIconUsage>& favicons) { | 662 void AddFavicons(const std::vector<history::ImportedFavIconUsage>& favicons) { |
664 } | 663 } |
665 | 664 |
666 private: | 665 private: |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 } | 837 } |
839 } | 838 } |
840 | 839 |
841 void AddKeywords(const std::vector<TemplateURL*>& template_urls, | 840 void AddKeywords(const std::vector<TemplateURL*>& template_urls, |
842 int default_keyword_index, | 841 int default_keyword_index, |
843 bool unique_on_host_and_path) { | 842 bool unique_on_host_and_path) { |
844 for (size_t i = 0; i < template_urls.size(); ++i) { | 843 for (size_t i = 0; i < template_urls.size(); ++i) { |
845 // The order might not be deterministic, look in the expected list for | 844 // The order might not be deterministic, look in the expected list for |
846 // that template URL. | 845 // that template URL. |
847 bool found = false; | 846 bool found = false; |
848 string16 keyword = template_urls[i]->keyword(); | 847 std::wstring keyword = template_urls[i]->keyword(); |
849 for (size_t j = 0; j < arraysize(kFirefox3Keywords); ++j) { | 848 for (size_t j = 0; j < arraysize(kFirefox3Keywords); ++j) { |
850 if (template_urls[i]->keyword() == | 849 if (template_urls[i]->keyword() == kFirefox3Keywords[j].keyword) { |
851 WideToUTF16Hack(kFirefox3Keywords[j].keyword)) { | |
852 EXPECT_EQ(kFirefox3Keywords[j].url, template_urls[i]->url()->url()); | 850 EXPECT_EQ(kFirefox3Keywords[j].url, template_urls[i]->url()->url()); |
853 found = true; | 851 found = true; |
854 break; | 852 break; |
855 } | 853 } |
856 } | 854 } |
857 EXPECT_TRUE(found); | 855 EXPECT_TRUE(found); |
858 ++keyword_count_; | 856 ++keyword_count_; |
859 } | 857 } |
860 | 858 |
861 if (default_keyword_index != -1) { | 859 if (default_keyword_index != -1) { |
862 EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size())); | 860 EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size())); |
863 TemplateURL* default_turl = template_urls[default_keyword_index]; | 861 TemplateURL* default_turl = template_urls[default_keyword_index]; |
864 default_keyword_ = UTF16ToWideHack(default_turl->keyword()); | 862 default_keyword_ = default_turl->keyword(); |
865 default_keyword_url_ = default_turl->url()->url(); | 863 default_keyword_url_ = default_turl->url()->url(); |
866 } | 864 } |
867 | 865 |
868 STLDeleteContainerPointers(template_urls.begin(), template_urls.end()); | 866 STLDeleteContainerPointers(template_urls.begin(), template_urls.end()); |
869 } | 867 } |
870 | 868 |
871 void AddFavicons(const std::vector<history::ImportedFavIconUsage>& favicons) { | 869 void AddFavicons(const std::vector<history::ImportedFavIconUsage>& favicons) { |
872 } | 870 } |
873 | 871 |
874 private: | 872 private: |
(...skipping 14 matching lines...) Expand all Loading... |
889 true); | 887 true); |
890 } | 888 } |
891 | 889 |
892 TEST_F(ImporterTest, MAYBE(Firefox35Importer)) { | 890 TEST_F(ImporterTest, MAYBE(Firefox35Importer)) { |
893 bool import_search_engines = false; | 891 bool import_search_engines = false; |
894 scoped_refptr<Firefox3Observer> observer( | 892 scoped_refptr<Firefox3Observer> observer( |
895 new Firefox3Observer(import_search_engines)); | 893 new Firefox3Observer(import_search_engines)); |
896 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), | 894 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), |
897 import_search_engines); | 895 import_search_engines); |
898 } | 896 } |
OLD | NEW |