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

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

Issue 11884037: InstantExtended: Bail on TemplateURLs with no espv. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. 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) 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/ui/search/search.h" 5 #include "chrome/browser/ui/search/search.h"
6
7 #include "chrome/browser/search_engines/template_url.h"
8 #include "chrome/browser/search_engines/template_url_service.h"
9 #include "chrome/browser/search_engines/template_url_service_factory.h"
10 #include "chrome/browser/search_engines/template_url_service_test_util.h"
11 #include "chrome/test/base/testing_profile.h"
6 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
7 13
8 namespace chrome { 14 namespace chrome {
9 namespace search { 15 namespace search {
10 16
11 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) { 17 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) {
12 FieldTrialFlags flags; 18 FieldTrialFlags flags;
13 uint64 group_number = 0; 19 uint64 group_number = 0;
14 const uint64 ZERO = 0; 20 const uint64 ZERO = 0;
15 21
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 "moose", "default", flags)); 61 "moose", "default", flags));
56 62
57 group_number = 0; 63 group_number = 0;
58 flags.clear(); 64 flags.clear();
59 GetFieldTrialInfo( 65 GetFieldTrialInfo(
60 "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number); 66 "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number);
61 EXPECT_EQ(ZERO, group_number); 67 EXPECT_EQ(ZERO, group_number);
62 EXPECT_EQ(ZERO, flags.size()); 68 EXPECT_EQ(ZERO, flags.size());
63 } 69 }
64 70
71 TEST(EmbeddedSearchPageVersionTest, BailsWithBadTemplateURL) {
72 EnableInstantExtendedAPIForTesting();
73
74 TemplateURLServiceTestUtil test_util;
75 test_util.SetUp();
76 test_util.VerifyLoad();
77 TemplateURLData data;
78 data.SetURL("http://google.com/?q={searchTerms}");
79 data.instant_url = "http://google.com/instant#q={searchTerms}";
80 TemplateURL* url = new TemplateURL(test_util.profile(), data);
81 test_util.model()->Add(url);
82 test_util.model()->SetDefaultSearchProvider(url);
83 ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider());
84 ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())->
dhollowa 2013/01/16 17:30:05 nit: ASSERT_NE(static_cast<...>(NULL), TemplateURL
Jered 2013/01/16 18:37:28 Done.
85 FindNewDefaultSearchProvider() != NULL);
86
87 EXPECT_EQ(0U, chrome::search::EmbeddedSearchPageVersion(
88 test_util.profile()->GetOriginalProfile()));
89 test_util.TearDown();
90 }
91
92 TEST(EmbeddedSearchPageVersionTest, DoesNotBailWithGoodTemplateURL) {
93 EnableInstantExtendedAPIForTesting();
94
95 TemplateURLServiceTestUtil test_util;
96 test_util.SetUp();
97 test_util.VerifyLoad();
98 TemplateURLData data;
99 data.SetURL("http://google.com/?q={searchTerms}");
100 data.instant_url = "http://google.com/instant#q={searchTerms}"
101 "{google:instantExtendedEnabledParameter}";
dhollowa 2013/01/16 17:30:05 This wouldn't cover the case when espv=0 I suppose
Jered 2013/01/16 18:37:28 The logic I'm adding only needs to know that the s
102 TemplateURL* url = new TemplateURL(test_util.profile(), data);
103 test_util.model()->Add(url);
104 test_util.model()->SetDefaultSearchProvider(url);
105 ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider());
106 ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())->
dhollowa 2013/01/16 17:30:05 nit: ASSERT_NE... as above.
Jered 2013/01/16 18:37:28 Done.
107 FindNewDefaultSearchProvider() != NULL);
108
109 EXPECT_NE(0U, chrome::search::EmbeddedSearchPageVersion(
110 test_util.profile()->GetOriginalProfile()));
111 test_util.TearDown();
112 }
113
65 } // namespace search 114 } // namespace search
66 } // namespace chrome 115 } // namespace chrome
OLDNEW
« chrome/browser/ui/search/search.cc ('K') | « chrome/browser/ui/search/search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698