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

Side by Side Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 11576044: Remove call to IsInstantExtendedAPIGoogleSearchUrl from ToolbarModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nit Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/rlz/rlz.h" 9 #include "chrome/browser/rlz/rlz.h"
10 #include "chrome/browser/search_engines/search_terms_data.h" 10 #include "chrome/browser/search_engines/search_terms_data.h"
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 data.SetURL("http://google.com/?q={searchTerms}"); 751 data.SetURL("http://google.com/?q={searchTerms}");
752 data.instant_url = "http://google.com/instant#q={searchTerms}"; 752 data.instant_url = "http://google.com/instant#q={searchTerms}";
753 data.alternate_urls.push_back("http://google.com/alt/#q={searchTerms}"); 753 data.alternate_urls.push_back("http://google.com/alt/#q={searchTerms}");
754 data.alternate_urls.push_back( 754 data.alternate_urls.push_back(
755 "http://google.com/alt/?ext=foo&q={searchTerms}#ref=bar"); 755 "http://google.com/alt/?ext=foo&q={searchTerms}#ref=bar");
756 TemplateURL url(NULL, data); 756 TemplateURL url(NULL, data);
757 string16 result; 757 string16 result;
758 758
759 EXPECT_TRUE(url.ExtractSearchTermsFromURL( 759 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
760 GURL("http://google.com/?q=something"), &result)); 760 GURL("http://google.com/?q=something"), &result));
761
762 EXPECT_EQ(ASCIIToUTF16("something"), result);
763
764 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
765 GURL("http://google.com/?espv&q=something"), &result));
766 EXPECT_EQ(ASCIIToUTF16("something"), result);
767
768 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
769 GURL("http://google.com/?espv=1&q=something"), &result));
770 EXPECT_EQ(ASCIIToUTF16("something"), result);
771
772 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
773 GURL("http://google.com/?espv=0&q=something"), &result));
774 EXPECT_EQ(ASCIIToUTF16("something"), result);
775
776 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
777 GURL("http://google.com/alt/#q=something"), &result));
778 EXPECT_EQ(ASCIIToUTF16("something"), result);
779
780 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
781 GURL("http://google.com/alt/#espv&q=something"), &result));
782 EXPECT_EQ(ASCIIToUTF16("something"), result);
783
784 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
785 GURL("http://google.com/alt/#espv=1&q=something"), &result));
786 EXPECT_EQ(ASCIIToUTF16("something"), result);
787
788 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
789 GURL("http://google.com/alt/#espv=0&q=something"), &result));
790
761 EXPECT_EQ(ASCIIToUTF16("something"), result); 791 EXPECT_EQ(ASCIIToUTF16("something"), result);
762 792
763 EXPECT_FALSE(url.ExtractSearchTermsFromURL( 793 EXPECT_FALSE(url.ExtractSearchTermsFromURL(
764 GURL("http://google.ca/?q=something"), &result)); 794 GURL("http://google.ca/?q=something"), &result));
765 EXPECT_EQ(string16(), result); 795 EXPECT_EQ(string16(), result);
766 796
767 EXPECT_FALSE(url.ExtractSearchTermsFromURL( 797 EXPECT_FALSE(url.ExtractSearchTermsFromURL(
768 GURL("http://google.com/foo/?q=foo"), &result)); 798 GURL("http://google.com/foo/?q=foo"), &result));
769 EXPECT_EQ(string16(), result); 799 EXPECT_EQ(string16(), result);
770 800
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 EXPECT_EQ(string16(), result); 835 EXPECT_EQ(string16(), result);
806 836
807 EXPECT_FALSE(url.ExtractSearchTermsFromURL( 837 EXPECT_FALSE(url.ExtractSearchTermsFromURL(
808 GURL("http://google.com/alt/?q=123#q="), &result)); 838 GURL("http://google.com/alt/?q=123#q="), &result));
809 EXPECT_EQ(string16(), result); 839 EXPECT_EQ(string16(), result);
810 840
811 EXPECT_TRUE(url.ExtractSearchTermsFromURL( 841 EXPECT_TRUE(url.ExtractSearchTermsFromURL(
812 GURL("http://google.com/alt/?q=#q=123"), &result)); 842 GURL("http://google.com/alt/?q=#q=123"), &result));
813 EXPECT_EQ(ASCIIToUTF16("123"), result); 843 EXPECT_EQ(ASCIIToUTF16("123"), result);
814 } 844 }
845
846 TEST_F(TemplateURLTest, HasSearchTermsReplacementKey) {
847 TemplateURLData data;
848 data.SetURL("http://google.com/?q={searchTerms}");
849 data.instant_url = "http://google.com/instant#q={searchTerms}";
850 data.alternate_urls.push_back("http://google.com/alt/#q={searchTerms}");
851 data.alternate_urls.push_back(
852 "http://google.com/alt/?ext=foo&q={searchTerms}#ref=bar");
853 data.search_terms_replacement_key = "espv";
854 TemplateURL url(NULL, data);
855
856 // Test with instant enabled required.
857 EXPECT_FALSE(url.HasSearchTermsReplacementKey(
858 GURL("http://google.com/")));
859
860 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
861 GURL("http://google.com/?espv")));
862
863 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
864 GURL("http://google.com/#espv")));
865
866 EXPECT_FALSE(url.HasSearchTermsReplacementKey(
867 GURL("http://google.com/?q=something")));
868
869 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
870 GURL("http://google.com/?q=something&espv")));
871
872 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
873 GURL("http://google.com/?q=something&espv=1")));
874
875 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
876 GURL("http://google.com/?q=something&espv=0")));
877
878 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
879 GURL("http://google.com/?espv&q=something")));
880
881 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
882 GURL("http://google.com/?espv=1&q=something")));
883
884 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
885 GURL("http://google.com/?espv=0&q=something")));
886
887 EXPECT_FALSE(url.HasSearchTermsReplacementKey(
888 GURL("http://google.com/alt/#q=something")));
889
890 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
891 GURL("http://google.com/alt/#q=something&espv")));
892
893 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
894 GURL("http://google.com/alt/#q=something&espv=1")));
895
896 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
897 GURL("http://google.com/alt/#q=something&espv=0")));
898
899 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
900 GURL("http://google.com/alt/#espv&q=something")));
901
902 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
903 GURL("http://google.com/alt/#espv=1&q=something")));
904
905 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
906 GURL("http://google.com/alt/#espv=0&q=something")));
907
908 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
909 GURL("http://google.com/?espv#q=something")));
910
911 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
912 GURL("http://google.com/?espv=1#q=something")));
913
914 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
915 GURL("http://google.com/?q=something#espv")));
916
917 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
918 GURL("http://google.com/?q=something#espv=1")));
919
920 // This does not ensure the domain matches.
921 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
922 GURL("http://bing.com/?espv")));
923
924 EXPECT_TRUE(url.HasSearchTermsReplacementKey(
925 GURL("http://bing.com/#espv")));
926 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698