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

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

Issue 940043002: Use GetPreferredDataTypes rather than GetActiveDataTypes when performing sync check for chrome sugg… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | no next file » | 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ASSERT_TRUE(signin_manager); 99 ASSERT_TRUE(signin_manager);
100 signin_manager->SetAuthenticatedUsername(username); 100 signin_manager->SetAuthenticatedUsername(username);
101 } 101 }
102 } 102 }
103 103
104 // Configure the account to |sync_history| or not. 104 // Configure the account to |sync_history| or not.
105 void SetHistorySync(bool sync_history) { 105 void SetHistorySync(bool sync_history) {
106 ProfileSyncServiceMock* sync_service = static_cast<ProfileSyncServiceMock*>( 106 ProfileSyncServiceMock* sync_service = static_cast<ProfileSyncServiceMock*>(
107 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile())); 107 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile()));
108 108
109 EXPECT_CALL(*sync_service, SyncActive()).WillRepeatedly(Return(true));
110 syncer::ModelTypeSet result; 109 syncer::ModelTypeSet result;
111 if (sync_history) { 110 if (sync_history) {
112 result.Put(syncer::HISTORY_DELETE_DIRECTIVES); 111 result.Put(syncer::HISTORY_DELETE_DIRECTIVES);
113 } 112 }
114 EXPECT_CALL(*sync_service, GetActiveDataTypes()) 113 EXPECT_CALL(*sync_service, GetPreferredDataTypes())
115 .WillRepeatedly(Return(result)); 114 .WillRepeatedly(Return(result));
116 } 115 }
117 116
118 bool MessageWasSent(uint32 id) { 117 bool MessageWasSent(uint32 id) {
119 return process()->sink().GetFirstMessageMatching(id) != NULL; 118 return process()->sink().GetFirstMessageMatching(id) != NULL;
120 } 119 }
121 120
122 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; } 121 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; }
123 122
124 private: 123 private:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( 272 const IPC::Message* message = process()->sink().GetUniqueMessageMatching(
274 ChromeViewMsg_ChromeIdentityCheckResult::ID); 273 ChromeViewMsg_ChromeIdentityCheckResult::ID);
275 ASSERT_TRUE(message != NULL); 274 ASSERT_TRUE(message != NULL);
276 275
277 ChromeViewMsg_ChromeIdentityCheckResult::Param params; 276 ChromeViewMsg_ChromeIdentityCheckResult::Param params;
278 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params); 277 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
279 EXPECT_EQ(test_identity, get<0>(params)); 278 EXPECT_EQ(test_identity, get<0>(params));
280 ASSERT_FALSE(get<1>(params)); 279 ASSERT_FALSE(get<1>(params));
281 } 280 }
282 281
283 TEST_F(SearchTabHelperTest, OnHistorySyncCheckSyncInactive) {
284 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
285 ProfileSyncServiceMock* sync_service = static_cast<ProfileSyncServiceMock*>(
286 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile()));
287 EXPECT_CALL(*sync_service, SyncActive()).WillRepeatedly(Return(false));
288 SearchTabHelper* search_tab_helper =
289 SearchTabHelper::FromWebContents(web_contents());
290 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
291
292 search_tab_helper->OnHistorySyncCheck();
293
294 const IPC::Message* message = process()->sink().GetUniqueMessageMatching(
295 ChromeViewMsg_HistorySyncCheckResult::ID);
296 ASSERT_TRUE(message != NULL);
297
298 ChromeViewMsg_HistorySyncCheckResult::Param params;
299 ChromeViewMsg_HistorySyncCheckResult::Read(message, &params);
300 ASSERT_FALSE(get<0>(params));
301 }
302
303 TEST_F(SearchTabHelperTest, OnHistorySyncCheckSyncing) { 282 TEST_F(SearchTabHelperTest, OnHistorySyncCheckSyncing) {
304 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); 283 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
305 SetHistorySync(true); 284 SetHistorySync(true);
306 SearchTabHelper* search_tab_helper = 285 SearchTabHelper* search_tab_helper =
307 SearchTabHelper::FromWebContents(web_contents()); 286 SearchTabHelper::FromWebContents(web_contents());
308 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); 287 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper);
309 288
310 search_tab_helper->OnHistorySyncCheck(); 289 search_tab_helper->OnHistorySyncCheck();
311 290
312 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( 291 const IPC::Message* message = process()->sink().GetUniqueMessageMatching(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 435 }
457 436
458 TEST_F(SearchTabHelperPrerenderTest, 437 TEST_F(SearchTabHelperPrerenderTest,
459 OnTabActivatedNoPrerenderIfOmniboxBlurred) { 438 OnTabActivatedNoPrerenderIfOmniboxBlurred) {
460 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; 439 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false;
461 SearchTabHelper* search_tab_helper = 440 SearchTabHelper* search_tab_helper =
462 SearchTabHelper::FromWebContents(web_contents()); 441 SearchTabHelper::FromWebContents(web_contents());
463 search_tab_helper->OnTabActivated(); 442 search_tab_helper->OnTabActivated();
464 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); 443 ASSERT_FALSE(IsInstantURLMarkedForPrerendering());
465 } 444 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698