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