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

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

Issue 178253008: Redoing Issue 36073011: Allowing file:/// in Instant Extended's Most Visited links. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused consts. Created 6 years, 9 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 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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 virtual ~MockSearchIPCRouterDelegate() {} 45 virtual ~MockSearchIPCRouterDelegate() {}
46 46
47 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 47 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
48 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search)); 48 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search));
49 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state)); 49 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state));
50 MOCK_METHOD3(NavigateToURL, void(const GURL&, WindowOpenDisposition, bool)); 50 MOCK_METHOD3(NavigateToURL, void(const GURL&, WindowOpenDisposition, bool));
51 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url)); 51 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url));
52 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url)); 52 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url));
53 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void()); 53 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void());
54 MOCK_METHOD1(OnLogEvent, void(NTPLoggingEventType event)); 54 MOCK_METHOD1(OnLogEvent, void(NTPLoggingEventType event));
55 MOCK_METHOD2(OnLogImpression, void(int position, 55 MOCK_METHOD2(OnLogMostVisitedImpression,
56 const base::string16& provider)); 56 void(int position, const base::string16& provider));
57 MOCK_METHOD2(OnLogMostVisitedNavigation,
58 void(int position, const base::string16& provider));
57 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&)); 59 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
58 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity)); 60 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
59 }; 61 };
60 62
61 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 63 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
62 public: 64 public:
63 virtual ~MockSearchIPCRouterPolicy() {} 65 virtual ~MockSearchIPCRouterPolicy() {}
64 66
65 MOCK_METHOD0(ShouldProcessSetVoiceSearchSupport, bool()); 67 MOCK_METHOD0(ShouldProcessSetVoiceSearchSupport, bool());
66 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); 68 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 .WillOnce(testing::Return(false)); 351 .WillOnce(testing::Return(false));
350 352
351 content::WebContents* contents = web_contents(); 353 content::WebContents* contents = web_contents();
352 scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogEvent( 354 scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogEvent(
353 contents->GetRoutingID(), 355 contents->GetRoutingID(),
354 contents->GetController().GetVisibleEntry()->GetPageID(), 356 contents->GetController().GetVisibleEntry()->GetPageID(),
355 NTP_MOUSEOVER)); 357 NTP_MOUSEOVER));
356 OnMessageReceived(*message); 358 OnMessageReceived(*message);
357 } 359 }
358 360
359 TEST_F(SearchIPCRouterTest, ProcessLogImpressionMsg) { 361 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
360 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 362 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
361 SetupMockDelegateAndPolicy(); 363 SetupMockDelegateAndPolicy();
362 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 364 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
363 EXPECT_CALL(*mock_delegate(), 365 EXPECT_CALL(*mock_delegate(),
364 OnLogImpression(3, base::ASCIIToUTF16("Server"))).Times(1); 366 OnLogMostVisitedImpression(3, base::ASCIIToUTF16("Server"))).Times(1);
365 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 367 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
366 .WillOnce(testing::Return(true)); 368 .WillOnce(testing::Return(true));
367 369
368 content::WebContents* contents = web_contents(); 370 content::WebContents* contents = web_contents();
369 scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogImpression( 371 scoped_ptr<IPC::Message> message(
372 new ChromeViewHostMsg_LogMostVisitedImpression(
370 contents->GetRoutingID(), 373 contents->GetRoutingID(),
371 contents->GetController().GetVisibleEntry()->GetPageID(), 374 contents->GetController().GetVisibleEntry()->GetPageID(),
372 3, 375 3,
376 base::ASCIIToUTF16("Server")));
377 OnMessageReceived(*message);
378 }
379
380 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
381 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
382 SetupMockDelegateAndPolicy();
383 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
384 EXPECT_CALL(*mock_delegate(),
385 OnLogMostVisitedNavigation(3, base::ASCIIToUTF16("Server"))).Times(1);
386 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
387 .WillOnce(testing::Return(true));
388
389 content::WebContents* contents = web_contents();
390 scoped_ptr<IPC::Message> message(
391 new ChromeViewHostMsg_LogMostVisitedNavigation(
392 contents->GetRoutingID(),
393 contents->GetController().GetVisibleEntry()->GetPageID(),
394 3,
373 base::ASCIIToUTF16("Server"))); 395 base::ASCIIToUTF16("Server")));
374 OnMessageReceived(*message); 396 OnMessageReceived(*message);
375 } 397 }
376 398
377 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { 399 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
378 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 400 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
379 SetupMockDelegateAndPolicy(); 401 SetupMockDelegateAndPolicy();
380 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 402 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
381 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 403 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
382 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); 404 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1);
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 920 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
899 SetupMockDelegateAndPolicy(); 921 SetupMockDelegateAndPolicy();
900 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 922 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
901 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) 923 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1)
902 .WillOnce(testing::Return(false)); 924 .WillOnce(testing::Return(false));
903 925
904 process()->sink().ClearMessages(); 926 process()->sink().ClearMessages();
905 GetSearchIPCRouter().ToggleVoiceSearch(); 927 GetSearchIPCRouter().ToggleVoiceSearch();
906 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); 928 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID));
907 } 929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698