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

Side by Side Diff: chrome/browser/search/instant_service_unittest.cc

Issue 283623002: Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for Web… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 scoped_ptr<content::MockRenderProcessHost> rph( 99 scoped_ptr<content::MockRenderProcessHost> rph(
100 new content::MockRenderProcessHost(profile())); 100 new content::MockRenderProcessHost(profile()));
101 rph->sink().ClearMessages(); 101 rph->sink().ClearMessages();
102 instant_service_->Observe( 102 instant_service_->Observe(
103 content::NOTIFICATION_RENDERER_PROCESS_CREATED, 103 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
104 content::Source<content::MockRenderProcessHost>(rph.get()), 104 content::Source<content::MockRenderProcessHost>(rph.get()),
105 content::NotificationService::NoDetails()); 105 content::NotificationService::NoDetails());
106 EXPECT_EQ(1U, rph->sink().message_count()); 106 EXPECT_EQ(1U, rph->sink().message_count());
107 const IPC::Message* msg = rph->sink().GetMessageAt(0); 107 const IPC::Message* msg = rph->sink().GetMessageAt(0);
108 ASSERT_TRUE(msg); 108 ASSERT_TRUE(msg);
109 std::vector<GURL> search_urls; 109 ChromeViewMsg_SetSearchURLs::Param params;
110 GURL new_tab_page_url; 110 ChromeViewMsg_SetSearchURLs::Read(msg, &params);
111 ChromeViewMsg_SetSearchURLs::Read(msg, &search_urls, &new_tab_page_url); 111 std::vector<GURL> search_urls = params.a;
112 GURL new_tab_page_url = params.b;
112 EXPECT_EQ(2U, search_urls.size()); 113 EXPECT_EQ(2U, search_urls.size());
113 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec()); 114 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec());
114 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec()); 115 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec());
115 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec()); 116 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec());
116 } 117 }
117 118
118 TEST_F(InstantServiceTest, InstantSearchDisabled) { 119 TEST_F(InstantServiceTest, InstantSearchDisabled) {
119 // 'prefetch_results' flag is not enabled in field trials. Make sure 120 // 'prefetch_results' flag is not enabled in field trials. Make sure
120 // InstantSearchPrerenderer is not initialized. 121 // InstantSearchPrerenderer is not initialized.
121 EXPECT_EQ(static_cast<InstantSearchPrerenderer*>(NULL), 122 EXPECT_EQ(static_cast<InstantSearchPrerenderer*>(NULL),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 NotifyGoogleBaseURLUpdate(new_base_url); 158 NotifyGoogleBaseURLUpdate(new_base_url);
158 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); 159 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer());
159 } 160 }
160 161
161 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { 162 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) {
162 int new_start_margin = 92; 163 int new_start_margin = 92;
163 EXPECT_CALL(*instant_service_observer_.get(), 164 EXPECT_CALL(*instant_service_observer_.get(),
164 OmniboxStartMarginChanged(new_start_margin)).Times(1); 165 OmniboxStartMarginChanged(new_start_margin)).Times(1);
165 UpdateOmniboxStartMargin(new_start_margin); 166 UpdateOmniboxStartMargin(new_start_margin);
166 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698