Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / search / instant_search_prerenderer_unittest.cc
blob23ffae6731f8db065cba17858dcd885b89771442
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/prerender/prerender_contents.h"
14 #include "chrome/browser/prerender/prerender_handle.h"
15 #include "chrome/browser/prerender/prerender_manager.h"
16 #include "chrome/browser/prerender/prerender_manager_factory.h"
17 #include "chrome/browser/prerender/prerender_origin.h"
18 #include "chrome/browser/prerender/prerender_tab_helper.h"
19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/search/instant_service.h"
21 #include "chrome/browser/search/instant_unittest_base.h"
22 #include "chrome/browser/search/search.h"
23 #include "chrome/browser/search_engines/template_url_service_factory.h"
24 #include "chrome/browser/ui/browser_instant_controller.h"
25 #include "chrome/browser/ui/search/search_tab_helper.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/instant_types.h"
28 #include "chrome/common/render_messages.h"
29 #include "components/omnibox/autocomplete_match.h"
30 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/web_contents.h"
32 #include "content/public/common/url_constants.h"
33 #include "content/public/test/mock_render_process_host.h"
34 #include "ipc/ipc_message.h"
35 #include "ipc/ipc_test_sink.h"
36 #include "testing/gmock/include/gmock/gmock.h"
37 #include "ui/gfx/geometry/size.h"
39 using base::ASCIIToUTF16;
41 namespace {
43 using content::Referrer;
44 using prerender::Origin;
45 using prerender::PrerenderContents;
46 using prerender::PrerenderHandle;
47 using prerender::PrerenderManager;
48 using prerender::PrerenderManagerFactory;
49 using prerender::PrerenderTabHelper;
51 class DummyPrerenderContents : public PrerenderContents {
52 public:
53 DummyPrerenderContents(
54 PrerenderManager* prerender_manager,
55 Profile* profile,
56 const GURL& url,
57 const Referrer& referrer,
58 Origin origin,
59 bool call_did_finish_load);
61 void StartPrerendering(
62 const gfx::Size& size,
63 content::SessionStorageNamespace* session_storage_namespace) override;
64 bool GetChildId(int* child_id) const override;
65 bool GetRouteId(int* route_id) const override;
67 private:
68 Profile* profile_;
69 const GURL url_;
70 bool call_did_finish_load_;
72 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents);
75 class DummyPrerenderContentsFactory : public PrerenderContents::Factory {
76 public:
77 explicit DummyPrerenderContentsFactory(bool call_did_finish_load)
78 : call_did_finish_load_(call_did_finish_load) {
81 PrerenderContents* CreatePrerenderContents(
82 PrerenderManager* prerender_manager,
83 Profile* profile,
84 const GURL& url,
85 const Referrer& referrer,
86 Origin origin) override;
88 private:
89 bool call_did_finish_load_;
91 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContentsFactory);
94 DummyPrerenderContents::DummyPrerenderContents(
95 PrerenderManager* prerender_manager,
96 Profile* profile,
97 const GURL& url,
98 const Referrer& referrer,
99 Origin origin,
100 bool call_did_finish_load)
101 : PrerenderContents(prerender_manager, profile, url, referrer, origin),
102 profile_(profile),
103 url_(url),
104 call_did_finish_load_(call_did_finish_load) {
107 void DummyPrerenderContents::StartPrerendering(
108 const gfx::Size& size,
109 content::SessionStorageNamespace* session_storage_namespace) {
110 content::SessionStorageNamespaceMap session_storage_namespace_map;
111 session_storage_namespace_map[std::string()] = session_storage_namespace;
112 prerender_contents_.reset(content::WebContents::CreateWithSessionStorage(
113 content::WebContents::CreateParams(profile_),
114 session_storage_namespace_map));
115 PrerenderTabHelper::CreateForWebContents(prerender_contents_.get());
116 content::NavigationController::LoadURLParams params(url_);
117 prerender_contents_->GetController().LoadURLWithParams(params);
118 SearchTabHelper::CreateForWebContents(prerender_contents_.get());
120 prerendering_has_started_ = true;
121 DCHECK(session_storage_namespace);
122 session_storage_namespace_id_ = session_storage_namespace->id();
123 NotifyPrerenderStart();
125 if (call_did_finish_load_)
126 DidFinishLoad(prerender_contents_->GetMainFrame(), url_);
129 bool DummyPrerenderContents::GetChildId(int* child_id) const {
130 *child_id = 1;
131 return true;
134 bool DummyPrerenderContents::GetRouteId(int* route_id) const {
135 *route_id = 1;
136 return true;
139 PrerenderContents* DummyPrerenderContentsFactory::CreatePrerenderContents(
140 PrerenderManager* prerender_manager,
141 Profile* profile,
142 const GURL& url,
143 const Referrer& referrer,
144 Origin origin) {
145 return new DummyPrerenderContents(prerender_manager, profile, url, referrer,
146 origin, call_did_finish_load_);
149 } // namespace
151 class InstantSearchPrerendererTest : public InstantUnitTestBase {
152 public:
153 InstantSearchPrerendererTest() {}
155 protected:
156 void SetUp() override {
157 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
158 "Group1 strk:20"));
159 InstantUnitTestBase::SetUp();
162 void Init(bool prerender_search_results_base_page,
163 bool call_did_finish_load) {
164 AddTab(browser(), GURL(url::kAboutBlankURL));
166 PrerenderManagerFactory::GetForProfile(browser()->profile())->
167 SetPrerenderContentsFactory(
168 new DummyPrerenderContentsFactory(call_did_finish_load));
169 if (prerender_search_results_base_page) {
170 content::SessionStorageNamespace* session_storage_namespace =
171 GetActiveWebContents()->GetController().
172 GetDefaultSessionStorageNamespace();
173 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
174 prerenderer->Init(session_storage_namespace, gfx::Size(640, 480));
175 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle());
179 InstantSearchPrerenderer* GetInstantSearchPrerenderer() {
180 return instant_service_->instant_search_prerenderer();
183 const GURL& GetPrerenderURL() {
184 return GetInstantSearchPrerenderer()->prerender_url_;
187 void SetLastQuery(const base::string16& query) {
188 GetInstantSearchPrerenderer()->last_instant_suggestion_ =
189 InstantSuggestion(query, std::string());
192 content::WebContents* prerender_contents() {
193 return GetInstantSearchPrerenderer()->prerender_contents();
196 bool MessageWasSent(uint32 id) {
197 content::MockRenderProcessHost* process =
198 static_cast<content::MockRenderProcessHost*>(
199 prerender_contents()->GetRenderViewHost()->GetProcess());
200 return process->sink().GetFirstMessageMatching(id) != NULL;
203 content::WebContents* GetActiveWebContents() const {
204 return browser()->tab_strip_model()->GetWebContentsAt(0);
207 PrerenderHandle* prerender_handle() {
208 return GetInstantSearchPrerenderer()->prerender_handle_.get();
211 void PrerenderSearchQuery(const base::string16& query) {
212 Init(true, true);
213 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
214 prerenderer->Prerender(InstantSuggestion(query, std::string()));
215 CommitPendingLoad(&prerender_contents()->GetController());
216 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
217 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle());
221 TEST_F(InstantSearchPrerendererTest, GetSearchTermsFromPrerenderedPage) {
222 Init(false, false);
223 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
224 GURL url(GetPrerenderURL());
225 EXPECT_EQ(GURL("https://www.google.com/instant?ion=1&foo=foo#foo=foo&strk"),
226 url);
227 EXPECT_EQ(base::UTF16ToASCII(prerenderer->get_last_query()),
228 base::UTF16ToASCII(
229 chrome::ExtractSearchTermsFromURL(profile(), url)));
231 // Assume the prerendered page prefetched search results for the query
232 // "flowers".
233 SetLastQuery(ASCIIToUTF16("flowers"));
234 EXPECT_EQ("flowers", base::UTF16ToASCII(prerenderer->get_last_query()));
235 EXPECT_EQ(base::UTF16ToASCII(prerenderer->get_last_query()),
236 base::UTF16ToASCII(
237 chrome::ExtractSearchTermsFromURL(profile(), url)));
240 TEST_F(InstantSearchPrerendererTest, PrefetchSearchResults) {
241 Init(true, true);
242 EXPECT_TRUE(prerender_handle()->IsFinishedLoading());
243 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
244 prerenderer->Prerender(
245 InstantSuggestion(ASCIIToUTF16("flowers"), std::string()));
246 EXPECT_EQ("flowers", base::UTF16ToASCII(prerenderer->get_last_query()));
247 EXPECT_TRUE(MessageWasSent(
248 ChromeViewMsg_SearchBoxSetSuggestionToPrefetch::ID));
251 TEST_F(InstantSearchPrerendererTest, DoNotPrefetchSearchResults) {
252 Init(true, false);
253 // Page hasn't finished loading yet.
254 EXPECT_FALSE(prerender_handle()->IsFinishedLoading());
255 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
256 prerenderer->Prerender(
257 InstantSuggestion(ASCIIToUTF16("flowers"), std::string()));
258 EXPECT_EQ("", base::UTF16ToASCII(prerenderer->get_last_query()));
259 EXPECT_FALSE(MessageWasSent(
260 ChromeViewMsg_SearchBoxSetSuggestionToPrefetch::ID));
263 TEST_F(InstantSearchPrerendererTest, CanCommitQuery) {
264 Init(true, true);
265 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
266 base::string16 query = ASCIIToUTF16("flowers");
267 prerenderer->Prerender(InstantSuggestion(query, std::string()));
268 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
270 // Make sure InstantSearchPrerenderer::CanCommitQuery() returns false for
271 // invalid search queries.
272 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(),
273 ASCIIToUTF16("joy")));
274 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
275 base::string16()));
278 TEST_F(InstantSearchPrerendererTest, CommitQuery) {
279 base::string16 query = ASCIIToUTF16("flowers");
280 PrerenderSearchQuery(query);
281 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
282 prerenderer->Commit(query, EmbeddedSearchRequestParams());
283 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxSubmit::ID));
286 TEST_F(InstantSearchPrerendererTest, CancelPrerenderRequestOnTabChangeEvent) {
287 Init(true, true);
288 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle());
290 // Add a new tab to deactivate the current tab.
291 AddTab(browser(), GURL(url::kAboutBlankURL));
292 EXPECT_EQ(2, browser()->tab_strip_model()->count());
294 // Make sure the pending prerender request is cancelled.
295 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
298 TEST_F(InstantSearchPrerendererTest, CancelPendingPrerenderRequest) {
299 Init(true, true);
300 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle());
302 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
303 prerenderer->Cancel();
304 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
307 TEST_F(InstantSearchPrerendererTest, PrerenderingAllowed) {
308 Init(true, true);
309 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
310 content::WebContents* active_tab = GetActiveWebContents();
311 EXPECT_EQ(GURL(url::kAboutBlankURL), active_tab->GetURL());
313 // Allow prerendering only for search type AutocompleteMatch suggestions.
314 AutocompleteMatch search_type_match(NULL, 1100, false,
315 AutocompleteMatchType::SEARCH_SUGGEST);
316 search_type_match.keyword = ASCIIToUTF16("{google:baseurl}");
317 EXPECT_TRUE(AutocompleteMatch::IsSearchType(search_type_match.type));
318 EXPECT_TRUE(prerenderer->IsAllowed(search_type_match, active_tab));
320 // Do not allow prerendering for custom search provider requests.
321 TemplateURLData data;
322 data.SetURL("https://www.dummyurl.com/search?q=%s&img=1");
323 data.SetShortName(ASCIIToUTF16("t"));
324 data.SetKeyword(ASCIIToUTF16("k"));
325 TemplateURL* t_url = new TemplateURL(data);
326 TemplateURLService* service =
327 TemplateURLServiceFactory::GetForProfile(profile());
328 service->Add(t_url);
329 service->Load();
330 AutocompleteMatch custom_search_type_match(
331 NULL, 1100, false, AutocompleteMatchType::SEARCH_SUGGEST);
332 custom_search_type_match.keyword = ASCIIToUTF16("k");
333 custom_search_type_match.destination_url =
334 GURL("https://www.dummyurl.com/search?q=fan&img=1");
335 TemplateURL* template_url =
336 custom_search_type_match.GetTemplateURL(service, false);
337 EXPECT_TRUE(template_url);
338 EXPECT_TRUE(AutocompleteMatch::IsSearchType(custom_search_type_match.type));
339 EXPECT_FALSE(prerenderer->IsAllowed(custom_search_type_match, active_tab));
341 AutocompleteMatch url_type_match(NULL, 1100, true,
342 AutocompleteMatchType::URL_WHAT_YOU_TYPED);
343 EXPECT_FALSE(AutocompleteMatch::IsSearchType(url_type_match.type));
344 EXPECT_FALSE(prerenderer->IsAllowed(url_type_match, active_tab));
346 // Search results page supports Instant search. InstantSearchPrerenderer is
347 // used only when the underlying page doesn't support Instant.
348 NavigateAndCommitActiveTab(GURL("https://www.google.com/alt#quux=foo&strk"));
349 active_tab = GetActiveWebContents();
350 EXPECT_FALSE(chrome::ExtractSearchTermsFromURL(profile(),
351 active_tab->GetURL()).empty());
352 EXPECT_FALSE(chrome::ShouldPrefetchSearchResultsOnSRP());
353 EXPECT_FALSE(prerenderer->IsAllowed(search_type_match, active_tab));
356 TEST_F(InstantSearchPrerendererTest, UsePrerenderPage) {
357 PrerenderSearchQuery(ASCIIToUTF16("foo"));
359 // Open a search results page. A prerendered page exists for |url|. Make sure
360 // the browser swaps the current tab contents with the prerendered contents.
361 GURL url("https://www.google.com/alt#quux=foo&strk");
362 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
363 ui::PAGE_TRANSITION_TYPED,
364 false));
365 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
366 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
369 TEST_F(InstantSearchPrerendererTest, PrerenderRequestCancelled) {
370 PrerenderSearchQuery(ASCIIToUTF16("foo"));
372 // Cancel the prerender request.
373 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
374 prerenderer->Cancel();
375 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
377 // Open a search results page. Prerendered page does not exists for |url|.
378 // Make sure the browser navigates the current tab to this |url|.
379 GURL url("https://www.google.com/alt#quux=foo&strk");
380 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
381 ui::PAGE_TRANSITION_TYPED,
382 false));
383 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
384 EXPECT_EQ(url, GetActiveWebContents()->GetURL());
387 TEST_F(InstantSearchPrerendererTest,
388 UsePrerenderedPage_SearchQueryMistmatch) {
389 PrerenderSearchQuery(ASCIIToUTF16("foo"));
391 // Open a search results page. Committed query("pen") doesn't match with the
392 // prerendered search query("foo"). Make sure the browser swaps the current
393 // tab contents with the prerendered contents.
394 GURL url("https://www.google.com/alt#quux=pen&strk");
395 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
396 ui::PAGE_TRANSITION_TYPED,
397 false));
398 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
399 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
402 TEST_F(InstantSearchPrerendererTest,
403 CancelPrerenderRequest_EmptySearchQueryCommitted) {
404 PrerenderSearchQuery(ASCIIToUTF16("foo"));
406 // Open a search results page. Make sure the InstantSearchPrerenderer cancels
407 // the active prerender request upon the receipt of empty search query.
408 GURL url("https://www.google.com/alt#quux=&strk");
409 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
410 ui::PAGE_TRANSITION_TYPED,
411 false));
412 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
413 EXPECT_EQ(url, GetActiveWebContents()->GetURL());
414 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
417 TEST_F(InstantSearchPrerendererTest,
418 CancelPrerenderRequest_UnsupportedDispositions) {
419 PrerenderSearchQuery(ASCIIToUTF16("pen"));
421 // Open a search results page. Make sure the InstantSearchPrerenderer cancels
422 // the active prerender request for unsupported window dispositions.
423 GURL url("https://www.google.com/alt#quux=pen&strk");
424 browser()->OpenURL(content::OpenURLParams(url, Referrer(), NEW_FOREGROUND_TAB,
425 ui::PAGE_TRANSITION_TYPED,
426 false));
427 content::WebContents* new_tab =
428 browser()->tab_strip_model()->GetWebContentsAt(1);
429 EXPECT_NE(GetPrerenderURL(), new_tab->GetURL());
430 EXPECT_EQ(url, new_tab->GetURL());
431 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
434 class ReuseInstantSearchBasePageTest : public InstantSearchPrerendererTest {
435 public:
436 ReuseInstantSearchBasePageTest() {}
438 protected:
439 void SetUp() override {
440 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
441 "Group1 strk:20"));
442 InstantUnitTestBase::SetUp();
446 TEST_F(ReuseInstantSearchBasePageTest, CanCommitQuery) {
447 Init(true, true);
448 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
449 base::string16 query = ASCIIToUTF16("flowers");
450 prerenderer->Prerender(InstantSuggestion(query, std::string()));
451 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
453 // When the Instant search base page has finished loading,
454 // InstantSearchPrerenderer can commit any search query to the prerendered
455 // page (even if it doesn't match the last known suggestion query).
456 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(),
457 ASCIIToUTF16("joy")));
458 // Invalid search query committed.
459 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
460 base::string16()));
463 TEST_F(ReuseInstantSearchBasePageTest,
464 CanCommitQuery_InstantSearchBasePageLoadInProgress) {
465 Init(true, false);
466 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
467 base::string16 query = ASCIIToUTF16("flowers");
468 prerenderer->Prerender(InstantSuggestion(query, std::string()));
470 // When the Instant search base page hasn't finished loading,
471 // InstantSearchPrerenderer cannot commit any search query to the base page.
472 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
473 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
474 ASCIIToUTF16("joy")));
477 #if !defined(OS_IOS) && !defined(OS_ANDROID)
478 class TestUsePrerenderPage : public InstantSearchPrerendererTest {
479 protected:
480 void SetUp() override {
481 // Disable query extraction flag in field trials.
482 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
483 "EmbeddedSearch", "Group1 strk:20 query_extraction:0"));
484 InstantUnitTestBase::SetUpWithoutQueryExtraction();
488 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) {
489 PrerenderSearchQuery(ASCIIToUTF16("foo"));
491 // Open a search results page. Query extraction flag is disabled in field
492 // trials. Search results page URL does not contain search terms replacement
493 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL
494 // and uses the prerendered page contents.
495 GURL url("https://www.google.com/alt#quux=foo");
496 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
497 ui::PAGE_TRANSITION_TYPED,
498 false));
499 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
500 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
503 TEST_F(TestUsePrerenderPage, DoNotUsePrerenderPage) {
504 PrerenderSearchQuery(ASCIIToUTF16("foo"));
506 // Do not use prerendered page for renderer initiated search request.
507 GURL url("https://www.google.com/alt#quux=foo");
508 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
509 ui::PAGE_TRANSITION_LINK,
510 true /* is_renderer_initiated */));
511 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
512 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
515 TEST_F(TestUsePrerenderPage, SetEmbeddedSearchRequestParams) {
516 PrerenderSearchQuery(ASCIIToUTF16("foo"));
517 EXPECT_TRUE(browser()->instant_controller());
519 // Open a search results page. Query extraction flag is disabled in field
520 // trials. Search results page URL does not contain search terms replacement
521 // key.
522 GURL url("https://www.google.com/url?bar=foo&aqs=chrome...0&ie=utf-8&oq=f");
523 browser()->instant_controller()->OpenInstant(CURRENT_TAB, url);
524 content::MockRenderProcessHost* process =
525 static_cast<content::MockRenderProcessHost*>(
526 prerender_contents()->GetRenderViewHost()->GetProcess());
527 const IPC::Message* message = process->sink().GetFirstMessageMatching(
528 ChromeViewMsg_SearchBoxSubmit::ID);
529 ASSERT_TRUE(message);
531 // Verify the IPC message params.
532 Tuple<base::string16, EmbeddedSearchRequestParams> params;
533 ChromeViewMsg_SearchBoxSubmit::Read(message, &params);
534 EXPECT_EQ("foo", base::UTF16ToASCII(get<0>(params)));
535 EXPECT_EQ("f", base::UTF16ToASCII(get<1>(params).original_query));
536 EXPECT_EQ("utf-8", base::UTF16ToASCII(get<1>(params).input_encoding));
537 EXPECT_EQ("", base::UTF16ToASCII(get<1>(params).rlz_parameter_value));
538 EXPECT_EQ("chrome...0",
539 base::UTF16ToASCII(get<1>(params).assisted_query_stats));
541 #endif