Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / search / instant_search_prerenderer_unittest.cc
blob0f9aafc99aa4241d1b348faf43275470f6d833c8
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/browser/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(
228 base::UTF16ToASCII(prerenderer->get_last_query()),
229 base::UTF16ToASCII(search::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(
236 base::UTF16ToASCII(prerenderer->get_last_query()),
237 base::UTF16ToASCII(search::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(
351 search::ExtractSearchTermsFromURL(profile(), active_tab->GetURL())
352 .empty());
353 EXPECT_FALSE(search::ShouldPrefetchSearchResultsOnSRP());
354 EXPECT_FALSE(prerenderer->IsAllowed(search_type_match, active_tab));
357 TEST_F(InstantSearchPrerendererTest, UsePrerenderPage) {
358 PrerenderSearchQuery(ASCIIToUTF16("foo"));
360 // Open a search results page. A prerendered page exists for |url|. Make sure
361 // the browser swaps the current tab contents with the prerendered contents.
362 GURL url("https://www.google.com/alt#quux=foo&strk");
363 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
364 ui::PAGE_TRANSITION_TYPED,
365 false));
366 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
367 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
370 TEST_F(InstantSearchPrerendererTest, PrerenderRequestCancelled) {
371 PrerenderSearchQuery(ASCIIToUTF16("foo"));
373 // Cancel the prerender request.
374 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
375 prerenderer->Cancel();
376 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
378 // Open a search results page. Prerendered page does not exists for |url|.
379 // Make sure the browser navigates the current tab to this |url|.
380 GURL url("https://www.google.com/alt#quux=foo&strk");
381 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
382 ui::PAGE_TRANSITION_TYPED,
383 false));
384 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
385 EXPECT_EQ(url, GetActiveWebContents()->GetURL());
388 TEST_F(InstantSearchPrerendererTest,
389 UsePrerenderedPage_SearchQueryMistmatch) {
390 PrerenderSearchQuery(ASCIIToUTF16("foo"));
392 // Open a search results page. Committed query("pen") doesn't match with the
393 // prerendered search query("foo"). Make sure the browser swaps the current
394 // tab contents with the prerendered contents.
395 GURL url("https://www.google.com/alt#quux=pen&strk");
396 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
397 ui::PAGE_TRANSITION_TYPED,
398 false));
399 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
400 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
403 TEST_F(InstantSearchPrerendererTest,
404 CancelPrerenderRequest_EmptySearchQueryCommitted) {
405 PrerenderSearchQuery(ASCIIToUTF16("foo"));
407 // Open a search results page. Make sure the InstantSearchPrerenderer cancels
408 // the active prerender request upon the receipt of empty search query.
409 GURL url("https://www.google.com/alt#quux=&strk");
410 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
411 ui::PAGE_TRANSITION_TYPED,
412 false));
413 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
414 EXPECT_EQ(url, GetActiveWebContents()->GetURL());
415 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
418 TEST_F(InstantSearchPrerendererTest,
419 CancelPrerenderRequest_UnsupportedDispositions) {
420 PrerenderSearchQuery(ASCIIToUTF16("pen"));
422 // Open a search results page. Make sure the InstantSearchPrerenderer cancels
423 // the active prerender request for unsupported window dispositions.
424 GURL url("https://www.google.com/alt#quux=pen&strk");
425 browser()->OpenURL(content::OpenURLParams(url, Referrer(), NEW_FOREGROUND_TAB,
426 ui::PAGE_TRANSITION_TYPED,
427 false));
428 content::WebContents* new_tab =
429 browser()->tab_strip_model()->GetWebContentsAt(1);
430 EXPECT_NE(GetPrerenderURL(), new_tab->GetURL());
431 EXPECT_EQ(url, new_tab->GetURL());
432 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
435 class ReuseInstantSearchBasePageTest : public InstantSearchPrerendererTest {
436 public:
437 ReuseInstantSearchBasePageTest() {}
439 protected:
440 void SetUp() override {
441 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
442 "Group1 strk:20"));
443 InstantUnitTestBase::SetUp();
447 TEST_F(ReuseInstantSearchBasePageTest, CanCommitQuery) {
448 Init(true, true);
449 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
450 base::string16 query = ASCIIToUTF16("flowers");
451 prerenderer->Prerender(InstantSuggestion(query, std::string()));
452 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
454 // When the Instant search base page has finished loading,
455 // InstantSearchPrerenderer can commit any search query to the prerendered
456 // page (even if it doesn't match the last known suggestion query).
457 EXPECT_TRUE(prerenderer->CanCommitQuery(GetActiveWebContents(),
458 ASCIIToUTF16("joy")));
459 // Invalid search query committed.
460 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
461 base::string16()));
464 TEST_F(ReuseInstantSearchBasePageTest,
465 CanCommitQuery_InstantSearchBasePageLoadInProgress) {
466 Init(true, false);
467 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
468 base::string16 query = ASCIIToUTF16("flowers");
469 prerenderer->Prerender(InstantSuggestion(query, std::string()));
471 // When the Instant search base page hasn't finished loading,
472 // InstantSearchPrerenderer cannot commit any search query to the base page.
473 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
474 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
475 ASCIIToUTF16("joy")));
478 #if !defined(OS_IOS) && !defined(OS_ANDROID)
479 class TestUsePrerenderPage : public InstantSearchPrerendererTest {
480 protected:
481 void SetUp() override {
482 // Disable query extraction flag in field trials.
483 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
484 "EmbeddedSearch", "Group1 strk:20 query_extraction:0"));
485 InstantUnitTestBase::SetUpWithoutQueryExtraction();
489 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) {
490 PrerenderSearchQuery(ASCIIToUTF16("foo"));
492 // Open a search results page. Query extraction flag is disabled in field
493 // trials. Search results page URL does not contain search terms replacement
494 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL
495 // and uses the prerendered page contents.
496 GURL url("https://www.google.com/alt#quux=foo");
497 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
498 ui::PAGE_TRANSITION_TYPED,
499 false));
500 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
501 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
504 TEST_F(TestUsePrerenderPage, DoNotUsePrerenderPage) {
505 PrerenderSearchQuery(ASCIIToUTF16("foo"));
507 // Do not use prerendered page for renderer initiated search request.
508 GURL url("https://www.google.com/alt#quux=foo");
509 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
510 ui::PAGE_TRANSITION_LINK,
511 true /* is_renderer_initiated */));
512 EXPECT_NE(GetPrerenderURL(), GetActiveWebContents()->GetURL());
513 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
516 TEST_F(TestUsePrerenderPage, SetEmbeddedSearchRequestParams) {
517 PrerenderSearchQuery(ASCIIToUTF16("foo"));
518 EXPECT_TRUE(browser()->instant_controller());
520 // Open a search results page. Query extraction flag is disabled in field
521 // trials. Search results page URL does not contain search terms replacement
522 // key.
523 GURL url("https://www.google.com/url?bar=foo&aqs=chrome...0&ie=utf-8&oq=f");
524 browser()->instant_controller()->OpenInstant(CURRENT_TAB, url);
525 content::MockRenderProcessHost* process =
526 static_cast<content::MockRenderProcessHost*>(
527 prerender_contents()->GetRenderViewHost()->GetProcess());
528 const IPC::Message* message = process->sink().GetFirstMessageMatching(
529 ChromeViewMsg_SearchBoxSubmit::ID);
530 ASSERT_TRUE(message);
532 // Verify the IPC message params.
533 base::Tuple<base::string16, EmbeddedSearchRequestParams> params;
534 ChromeViewMsg_SearchBoxSubmit::Read(message, &params);
535 EXPECT_EQ("foo", base::UTF16ToASCII(base::get<0>(params)));
536 EXPECT_EQ("f", base::UTF16ToASCII(base::get<1>(params).original_query));
537 EXPECT_EQ("utf-8", base::UTF16ToASCII(base::get<1>(params).input_encoding));
538 EXPECT_EQ("", base::UTF16ToASCII(base::get<1>(params).rlz_parameter_value));
539 EXPECT_EQ("chrome...0",
540 base::UTF16ToASCII(base::get<1>(params).assisted_query_stats));
542 #endif