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

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

Issue 2544883006: Cleanup: Replace NTPLoggingTileSource by ntp_tiles::NTPTileSource (Closed)
Patch Set: tests Created 4 years 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
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_ipc_router.h" 5 #include "chrome/browser/ui/search/search_ipc_router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 virtual ~MockSearchIPCRouterDelegate() {} 49 virtual ~MockSearchIPCRouterDelegate() {}
50 50
51 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 51 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
52 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state)); 52 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state));
53 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url)); 53 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url));
54 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url)); 54 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url));
55 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void()); 55 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void());
56 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event, 56 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event,
57 base::TimeDelta time)); 57 base::TimeDelta time));
58 MOCK_METHOD2(OnLogMostVisitedImpression, 58 MOCK_METHOD2(OnLogMostVisitedImpression,
59 void(int position, NTPLoggingTileSource tile_source)); 59 void(int position, ntp_tiles::NTPTileSource tile_source));
60 MOCK_METHOD2(OnLogMostVisitedNavigation, 60 MOCK_METHOD2(OnLogMostVisitedNavigation,
61 void(int position, NTPLoggingTileSource tile_source)); 61 void(int position, ntp_tiles::NTPTileSource tile_source));
62 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&)); 62 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
63 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity)); 63 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
64 MOCK_METHOD0(OnHistorySyncCheck, void()); 64 MOCK_METHOD0(OnHistorySyncCheck, void());
65 }; 65 };
66 66
67 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 67 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
68 public: 68 public:
69 virtual ~MockSearchIPCRouterPolicy() {} 69 virtual ~MockSearchIPCRouterPolicy() {}
70 70
71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); 71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 OnMessageReceived(ChromeViewHostMsg_LogEvent( 284 OnMessageReceived(ChromeViewHostMsg_LogEvent(
285 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(), 285 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(),
286 NTP_ALL_TILES_LOADED, delta)); 286 NTP_ALL_TILES_LOADED, delta));
287 } 287 }
288 288
289 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { 289 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
290 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 290 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
291 SetupMockDelegateAndPolicy(); 291 SetupMockDelegateAndPolicy();
292 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 292 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
293 EXPECT_CALL(*mock_delegate(), 293 EXPECT_CALL(*mock_delegate(),
294 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); 294 OnLogMostVisitedImpression(
295 3, ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE))
296 .Times(1);
295 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 297 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
296 .WillOnce(testing::Return(true)); 298 .WillOnce(testing::Return(true));
297 299
298 content::WebContents* contents = web_contents(); 300 content::WebContents* contents = web_contents();
299 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedImpression( 301 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedImpression(
300 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(), 302 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(),
301 3, NTPLoggingTileSource::SERVER)); 303 3, ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE));
302 } 304 }
303 305
304 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) { 306 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
305 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 307 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
306 SetupMockDelegateAndPolicy(); 308 SetupMockDelegateAndPolicy();
307 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 309 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
308 EXPECT_CALL(*mock_delegate(), 310 EXPECT_CALL(*mock_delegate(),
309 OnLogMostVisitedNavigation(3, NTPLoggingTileSource::SERVER)).Times(1); 311 OnLogMostVisitedNavigation(
312 3, ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE))
313 .Times(1);
310 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 314 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
311 .WillOnce(testing::Return(true)); 315 .WillOnce(testing::Return(true));
312 316
313 content::WebContents* contents = web_contents(); 317 content::WebContents* contents = web_contents();
314 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedNavigation( 318 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedNavigation(
315 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(), 319 contents->GetRenderViewHost()->GetRoutingID(), GetSearchIPCRouterSeqNo(),
316 3, NTPLoggingTileSource::SERVER)); 320 3, ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE));
317 } 321 }
318 322
319 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { 323 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
320 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 324 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
321 SetupMockDelegateAndPolicy(); 325 SetupMockDelegateAndPolicy();
322 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 326 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
323 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 327 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
324 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); 328 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1);
325 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) 329 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1)
326 .WillOnce(testing::Return(true)); 330 .WillOnce(testing::Return(true));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 715
712 // Construct a series of synthetic messages for each valid IPC message type, 716 // Construct a series of synthetic messages for each valid IPC message type,
713 // ensuring the router ignores them all. 717 // ensuring the router ignores them all.
714 for (int i = 0; i < LastIPCMsgStart; ++i) { 718 for (int i = 0; i < LastIPCMsgStart; ++i) {
715 const int message_id = i << 16; 719 const int message_id = i << 16;
716 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); 720 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i);
717 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); 721 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW);
718 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; 722 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i;
719 } 723 }
720 } 724 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router.cc ('k') | chrome/browser/ui/search/search_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698