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

Side by Side Diff: chrome/browser/ui/search/search_unittest.cc

Issue 12250033: Consolidate search terms extraction and Instant process determination. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style nit Created 7 years, 10 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) 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 #include "chrome/browser/search_engines/template_url.h"
5 #include "chrome/browser/ui/search/search.h" 6 #include "chrome/browser/ui/search/search.h"
6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
7 8
8 namespace chrome { 9 namespace chrome {
9 namespace search { 10 namespace search {
10 11
11 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) { 12 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) {
12 FieldTrialFlags flags; 13 FieldTrialFlags flags;
13 uint64 group_number = 0; 14 uint64 group_number = 0;
14 const uint64 ZERO = 0; 15 const uint64 ZERO = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 "moose", "default", flags)); 59 "moose", "default", flags));
59 60
60 group_number = 0; 61 group_number = 0;
61 flags.clear(); 62 flags.clear();
62 EXPECT_FALSE(GetFieldTrialInfo( 63 EXPECT_FALSE(GetFieldTrialInfo(
63 "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number)); 64 "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number));
64 EXPECT_EQ(ZERO, group_number); 65 EXPECT_EQ(ZERO, group_number);
65 EXPECT_EQ(ZERO, flags.size()); 66 EXPECT_EQ(ZERO, flags.size());
66 } 67 }
67 68
69 TEST(SearchTest, ShouldAssignURLToInstantRendererImpl) {
70 TemplateURLData data;
71 data.SetURL("http://foo.com/url?bar={searchTerms}");
72 data.instant_url = "http://foo.com/instant";
73 data.alternate_urls.push_back("http://foo.com/alt#quux={searchTerms}");
74 data.search_terms_replacement_key = "strk";
75 TemplateURL url(NULL, data);
76
77 struct {
78 const char* const url;
79 bool extended_api_enabled;
80 bool expected_result;
81 } kTestCases[] = {
82 {"invalid URL", false, false},
83 {"unknown://scheme/path", false, false},
84 {"chrome-search://foo/bar", false, true},
85 {kLocalOmniboxPopupURL, false, false},
86 {kLocalOmniboxPopupURL, true, true},
87 {"http://foo.com/instant", false, true},
88 {"http://foo.com/instant?foo=bar", false, true},
89 {"https://foo.com/instant", false, true},
90 {"https://foo.com/instant#foo=bar", false, true},
91 {"HtTpS://fOo.CoM/instant", false, true},
92 {"http://foo.com:80/instant", false, true},
93 {"ftp://foo.com/instant", false, false},
94 {"http://sub.foo.com/instant", false, false},
95 {"http://foo.com:26/instant", false, false},
96 {"http://foo.com/instant/bar", false, false},
97 {"http://foo.com/Instant", false, false},
98 {"https://foo.com/instant?strk", true, true},
99 {"https://foo.com/instant#strk", true, true},
100 {"https://foo.com/instant?strk=0", true, true},
101 {"http://foo.com/instant", true, false},
102 {"https://foo.com/instant", true, false},
103 {"http://foo.com/instant?strk=1", true, false},
104 {"https://foo.com/url?strk", true, true},
105 {"https://foo.com/alt?strk", true, true},
106 };
107
108 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
109 EXPECT_EQ(kTestCases[i].expected_result,
110 ShouldAssignURLToInstantRendererImpl(
111 GURL(kTestCases[i].url),
112 kTestCases[i].extended_api_enabled,
113 &url)) << kTestCases[i].url << " "
114 << kTestCases[i].extended_api_enabled;
115 }
116 }
117
68 } // namespace search 118 } // namespace search
69 } // namespace chrome 119 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698