| 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is | 673 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is |
| 674 // set to true if the underlying page is a results page and | 674 // set to true if the underlying page is a results page and |
| 675 // "prefetch_results_srp" flag is enabled via field trials. | 675 // "prefetch_results_srp" flag is enabled via field trials. |
| 676 VerifyDisplayInstantResultsMsg(true); | 676 VerifyDisplayInstantResultsMsg(true); |
| 677 } | 677 } |
| 678 | 678 |
| 679 TEST_F(SearchIPCRouterTest, | 679 TEST_F(SearchIPCRouterTest, |
| 680 SendSetDisplayInstantResultsMsg_DisableInstantOnResultsPage) { | 680 SendSetDisplayInstantResultsMsg_DisableInstantOnResultsPage) { |
| 681 // |prefetch_results_srp" flag is disabled via field trials. | 681 // |prefetch_results_srp" flag is disabled via field trials. |
| 682 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 682 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 683 "EmbeddedSearch", "Group1 espv:42 prefetch_results_srp:0")); | 683 "EmbeddedSearch", |
| 684 "Group1 espv:42 query_extraction:1 prefetch_results_srp:0")); |
| 684 NavigateAndCommitActiveTab(GURL("https://foo.com/url?espv&bar=abc")); | 685 NavigateAndCommitActiveTab(GURL("https://foo.com/url?espv&bar=abc")); |
| 685 | 686 |
| 686 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is | 687 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is |
| 687 // set to false. | 688 // set to false. |
| 688 VerifyDisplayInstantResultsMsg(false); | 689 VerifyDisplayInstantResultsMsg(false); |
| 689 } | 690 } |
| 690 | 691 |
| 691 TEST_F(SearchIPCRouterTest, | 692 TEST_F(SearchIPCRouterTest, |
| 692 SendSetDisplayInstantResultsMsg_DisableInstantOutsideResultsPage) { | 693 SendSetDisplayInstantResultsMsg_EnableInstantOutsideSearchResultsPage) { |
| 693 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 694 "EmbeddedSearch", "Group1 espv:42 prefetch_results_srp:1")); | |
| 695 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 694 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 696 | |
| 697 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults param is set to | 695 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults param is set to |
| 698 // false if the underlying page is not a search results page. | 696 // true if the underlying page is not a search results page. |
| 699 VerifyDisplayInstantResultsMsg(false); | |
| 700 } | |
| 701 | |
| 702 TEST_F(SearchIPCRouterTest, | |
| 703 SendSetDisplayInstantResultsMsg_InstantSearchEnabled) { | |
| 704 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 705 "EmbeddedSearch", | |
| 706 "Group1 espv:42 prefetch_results:1 use_cacheable_ntp:1")); | |
| 707 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | |
| 708 | |
| 709 // If the "prefetch_results" flag is enabled via field trials, then | |
| 710 // ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is set to | |
| 711 // true irrespective of the underlying page. | |
| 712 VerifyDisplayInstantResultsMsg(true); | 697 VerifyDisplayInstantResultsMsg(true); |
| 713 } | 698 } |
| 714 | 699 |
| 715 TEST_F(SearchIPCRouterTest, | |
| 716 SendSetDisplayInstantResultsMsg_InstantSearchDisabled) { | |
| 717 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 718 "EmbeddedSearch", | |
| 719 "Group1 espv:42 use_cacheable_ntp:1 prefetch_results:0")); | |
| 720 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | |
| 721 | |
| 722 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults param is set to | |
| 723 // false if the "prefetch_results" flag is disabled via field trials. | |
| 724 VerifyDisplayInstantResultsMsg(false); | |
| 725 } | |
| 726 | |
| 727 TEST_F(SearchIPCRouterTest, DoNotSendSetDisplayInstantResultsMsg) { | 700 TEST_F(SearchIPCRouterTest, DoNotSendSetDisplayInstantResultsMsg) { |
| 728 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 701 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 729 SetupMockDelegateAndPolicy(); | 702 SetupMockDelegateAndPolicy(); |
| 730 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 703 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 731 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) | 704 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) |
| 732 .WillOnce(testing::Return(false)); | 705 .WillOnce(testing::Return(false)); |
| 733 | 706 |
| 734 process()->sink().ClearMessages(); | 707 process()->sink().ClearMessages(); |
| 735 GetSearchIPCRouter().SetDisplayInstantResults(); | 708 GetSearchIPCRouter().SetDisplayInstantResults(); |
| 736 EXPECT_FALSE(MessageWasSent( | 709 EXPECT_FALSE(MessageWasSent( |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 904 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 932 SetupMockDelegateAndPolicy(); | 905 SetupMockDelegateAndPolicy(); |
| 933 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 906 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 934 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) | 907 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) |
| 935 .WillOnce(testing::Return(false)); | 908 .WillOnce(testing::Return(false)); |
| 936 | 909 |
| 937 process()->sink().ClearMessages(); | 910 process()->sink().ClearMessages(); |
| 938 GetSearchIPCRouter().ToggleVoiceSearch(); | 911 GetSearchIPCRouter().ToggleVoiceSearch(); |
| 939 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 912 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
| 940 } | 913 } |
| OLD | NEW |