| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(OnLogImpression, void(int position, |
| 56 const base::string16& provider)); | 56 const base::string16& provider)); |
| 57 MOCK_METHOD2(OnLogNavigation, void(int position, |
| 58 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(new ChromeViewHostMsg_LogImpression( |
| 370 contents->GetRoutingID(), | 372 contents->GetRoutingID(), |
| 371 contents->GetController().GetVisibleEntry()->GetPageID(), | 373 contents->GetController().GetVisibleEntry()->GetPageID(), |
| 372 3, | 374 3, |
| 373 base::ASCIIToUTF16("Server"))); | 375 base::ASCIIToUTF16("Server"))); |
| 374 OnMessageReceived(*message); | 376 OnMessageReceived(*message); |
| 375 } | 377 } |
| 376 | 378 |
| 379 TEST_F(SearchIPCRouterTest, ProcessLogNavigationMsg) { |
| 380 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 381 SetupMockDelegateAndPolicy(); |
| 382 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 383 EXPECT_CALL(*mock_delegate(), |
| 384 OnLogNavigation(3, base::ASCIIToUTF16("Server"))).Times(1); |
| 385 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
| 386 .WillOnce(testing::Return(true)); |
| 387 |
| 388 content::WebContents* contents = web_contents(); |
| 389 scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogNavigation( |
| 390 contents->GetRoutingID(), |
| 391 contents->GetController().GetVisibleEntry()->GetPageID(), |
| 392 3, |
| 393 base::ASCIIToUTF16("Server"))); |
| 394 OnMessageReceived(*message); |
| 395 } |
| 396 |
| 377 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { | 397 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { |
| 378 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 398 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 379 SetupMockDelegateAndPolicy(); | 399 SetupMockDelegateAndPolicy(); |
| 380 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 400 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 381 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); | 401 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); |
| 382 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); | 402 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); |
| 383 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) | 403 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) |
| 384 .WillOnce(testing::Return(true)); | 404 .WillOnce(testing::Return(true)); |
| 385 | 405 |
| 386 content::WebContents* contents = web_contents(); | 406 content::WebContents* contents = web_contents(); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 918 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 899 SetupMockDelegateAndPolicy(); | 919 SetupMockDelegateAndPolicy(); |
| 900 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 920 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 901 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) | 921 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) |
| 902 .WillOnce(testing::Return(false)); | 922 .WillOnce(testing::Return(false)); |
| 903 | 923 |
| 904 process()->sink().ClearMessages(); | 924 process()->sink().ClearMessages(); |
| 905 GetSearchIPCRouter().ToggleVoiceSearch(); | 925 GetSearchIPCRouter().ToggleVoiceSearch(); |
| 906 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 926 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
| 907 } | 927 } |
| OLD | NEW |