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

Unified Diff: chrome/browser/ui/search/search_ipc_router_unittest.cc

Issue 342323008: Discard ChromeViewHostMsg_SearchBox* IPCs if they not sent from an Instant process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added tests Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_policy_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_ipc_router_unittest.cc
diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc
index fc9d79ccabcf3ac6fbbf9f5fb971f660d6677e1e..c7da7f83247d6c4d9a60f37f4440a42491ad36d1 100644
--- a/chrome/browser/ui/search/search_ipc_router_unittest.cc
+++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc
@@ -184,7 +184,10 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
}
void OnMessageReceived(const IPC::Message& message) {
- GetSearchIPCRouter().OnMessageReceived(message);
+ bool should_handle_message =
+ chrome::IsRenderedInInstantProcess(web_contents(), profile());
+ bool handled = GetSearchIPCRouter().OnMessageReceived(message);
+ EXPECT_EQ(should_handle_message, handled);
nasko 2014/06/20 21:27:42 nit: I'd make that an ASSERT, as it is never expec
kmadhusu 2014/06/20 21:33:54 Done.
}
bool IsActiveTab(content::WebContents* contents) {
@@ -196,6 +199,26 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
base::FieldTrialList field_trial_list_;
};
+TEST_F(SearchIPCRouterTest, IgnoreMessagesFromNonInstantRenderers) {
+ NavigateAndCommitActiveTab(GURL("file://foo/bar"));
+ SetupMockDelegateAndPolicy();
+ GURL destination_url("www.foo.com");
+ EXPECT_CALL(*mock_delegate(), NavigateToURL(destination_url, CURRENT_TAB,
+ true)).Times(0);
+ content::WebContents* contents = web_contents();
+ bool is_active_tab = IsActiveTab(contents);
+ EXPECT_TRUE(is_active_tab);
+
+ MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
+ EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(0);
+
+ scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(),
+ GetSearchIPCRouterSeqNo(),
+ destination_url, CURRENT_TAB, true));
+ OnMessageReceived(*message);
nasko 2014/06/20 21:18:02 How does the test pass/fail here?
kmadhusu 2014/06/20 21:20:28 Test will pass. We expect SearchIPCRouter::OnMessa
nasko 2014/06/20 21:27:42 Ok, it passes due to the expectations of no calls
kmadhusu 2014/06/20 21:33:54 Ack.
+}
+
TEST_F(SearchIPCRouterTest, ProcessVoiceSearchSupportMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy();
@@ -285,7 +308,7 @@ TEST_F(SearchIPCRouterTest, HandleTabChangedEvents) {
}
TEST_F(SearchIPCRouterTest, ProcessNavigateToURLMsg) {
- NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
+ NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
SetupMockDelegateAndPolicy();
GURL destination_url("www.foo.com");
EXPECT_CALL(*mock_delegate(), NavigateToURL(destination_url, CURRENT_TAB,
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_policy_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698