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

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

Issue 2852693002: Remove DetermineIfPageSupportsInstant and all its plumbing (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/common/instant.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; } 133 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; }
134 134
135 MockSearchBox* mock_search_box() { return &mock_search_box_; } 135 MockSearchBox* mock_search_box() { return &mock_search_box_; }
136 136
137 private: 137 private:
138 MockSearchIPCRouterDelegate delegate_; 138 MockSearchIPCRouterDelegate delegate_;
139 MockSearchBox mock_search_box_; 139 MockSearchBox mock_search_box_;
140 }; 140 };
141 141
142 TEST_F(SearchTabHelperTest, DetermineIfPageSupportsInstant_Local) {
143 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
144 EXPECT_CALL(*mock_delegate(), OnInstantSupportDetermined(true)).Times(0);
145
146 SearchTabHelper* search_tab_helper =
147 SearchTabHelper::FromWebContents(web_contents());
148 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
149 search_tab_helper->ipc_router_for_testing().set_delegate_for_testing(
150 mock_delegate());
151 search_tab_helper->DetermineIfPageSupportsInstant();
152 }
153
154 TEST_F(SearchTabHelperTest, DetermineIfPageSupportsInstant_NonLocal) {
155 NavigateAndCommit(GURL("chrome-search://foo/bar"));
156 EXPECT_CALL(*mock_delegate(), OnInstantSupportDetermined(true)).Times(1);
157
158 SearchTabHelper* search_tab_helper =
159 SearchTabHelper::FromWebContents(web_contents());
160 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
161 search_tab_helper->ipc_router_for_testing().set_delegate_for_testing(
162 mock_delegate());
163 EXPECT_CALL(*mock_search_box(), DetermineIfPageSupportsInstant());
164 search_tab_helper->DetermineIfPageSupportsInstant();
165
166 search_tab_helper->ipc_router_for_testing().InstantSupportDetermined(
167 search_tab_helper->ipc_router_for_testing().page_seq_no_for_testing(),
168 true);
169 }
170
171 TEST_F(SearchTabHelperTest, PageURLDoesntBelongToInstantRenderer) {
172 // Navigate to a page URL that doesn't belong to Instant renderer.
173 // SearchTabHelper::DeterminerIfPageSupportsInstant() should return
174 // immediately without dispatching any message to the renderer.
175 NavigateAndCommit(GURL("http://www.example.com"));
176 EXPECT_CALL(*mock_delegate(), OnInstantSupportDetermined(false)).Times(0);
177
178 SearchTabHelper* search_tab_helper =
179 SearchTabHelper::FromWebContents(web_contents());
180 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
181 search_tab_helper->ipc_router_for_testing().set_delegate_for_testing(
182 mock_delegate());
183 EXPECT_CALL(*mock_search_box(), DetermineIfPageSupportsInstant()).Times(0);
184 search_tab_helper->DetermineIfPageSupportsInstant();
185 }
186
187 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatch) { 142 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatch) {
188 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); 143 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
189 CreateSigninManager(std::string("foo@bar.com")); 144 CreateSigninManager(std::string("foo@bar.com"));
190 SearchTabHelper* search_tab_helper = 145 SearchTabHelper* search_tab_helper =
191 SearchTabHelper::FromWebContents(web_contents()); 146 SearchTabHelper::FromWebContents(web_contents());
192 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); 147 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
193 148
194 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 149 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
195 EXPECT_CALL(*mock_search_box(), 150 EXPECT_CALL(*mock_search_box(),
196 ChromeIdentityCheckResult(Eq(test_identity), true)); 151 ChromeIdentityCheckResult(Eq(test_identity), true));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 }; 257 };
303 258
304 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { 259 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) {
305 TabTitleObserver title_observer(web_contents()); 260 TabTitleObserver title_observer(web_contents());
306 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); 261 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL));
307 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); 262 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
308 EXPECT_EQ(title, title_observer.title_on_start()); 263 EXPECT_EQ(title, title_observer.title_on_start());
309 EXPECT_EQ(title, title_observer.title_on_commit()); 264 EXPECT_EQ(title, title_observer.title_on_commit());
310 EXPECT_EQ(title, web_contents()->GetTitle()); 265 EXPECT_EQ(title, web_contents()->GetTitle());
311 } 266 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/common/instant.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698