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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 10732002: Upstream rewrite of Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First round of comments Created 8 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/instant/instant_controller.h" 10 #include "chrome/browser/instant/instant_controller.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
37 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
38 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 41
42 using content::WebContents; 42 using content::WebContents;
43 43
44 // Tests are flaky on Linux because of http://crbug.com/80118. 44 // Tests are flaky on Linux because of http://crbug.com/80118.
45 #if defined(OS_LINUX) && !defined(USE_ASH) 45 #if defined(OS_WIN)
46 #define MAYBE(TestName) DISABLED_ ## TestName
47 #elif defined(OS_WIN)
48 #define MAYBE(TestName) FLAKY_ ## TestName 46 #define MAYBE(TestName) FLAKY_ ## TestName
49 #else 47 #else
50 #define MAYBE(TestName) TestName 48 #define MAYBE(TestName) TestName
51 #endif 49 #endif
52 50
53 class InstantTest : public InProcessBrowserTest { 51 class InstantTest : public InProcessBrowserTest {
54 public: 52 public:
55 InstantTest() { 53 InstantTest() :
54 search_term_(ASCIIToUTF16("def")) {
56 EnableDOMAutomation(); 55 EnableDOMAutomation();
57 } 56 }
58 57
59 void EnableInstant() { 58 void EnableInstant() {
60 InstantController::Enable(browser()->profile()); 59 InstantController::Enable(browser()->profile());
61 } 60 }
62 61
63 void SetupInstantProvider(const std::string& page) { 62 void SetupInstantProvider(const std::string& page) {
64 Profile* profile = browser()->profile(); 63 Profile* profile = browser()->profile();
65 TemplateURLService* model = 64 TemplateURLService* model =
(...skipping 13 matching lines...) Expand all
79 data.SetURL(base::StringPrintf("http://%s:%d/files/%s?q={searchTerms}", 78 data.SetURL(base::StringPrintf("http://%s:%d/files/%s?q={searchTerms}",
80 test_server()->host_port_pair().host().c_str(), 79 test_server()->host_port_pair().host().c_str(),
81 test_server()->host_port_pair().port(), page.c_str())); 80 test_server()->host_port_pair().port(), page.c_str()));
82 data.instant_url = data.url(); 81 data.instant_url = data.url();
83 // TemplateURLService takes ownership of this. 82 // TemplateURLService takes ownership of this.
84 TemplateURL* template_url = new TemplateURL(profile, data); 83 TemplateURL* template_url = new TemplateURL(profile, data);
85 model->Add(template_url); 84 model->Add(template_url);
86 model->SetDefaultSearchProvider(template_url); 85 model->SetDefaultSearchProvider(template_url);
87 } 86 }
88 87
88 void SetOmniboxFocusAndUserText(const string16& user_text) {
89 omnibox()->SetFocus();
90 omnibox()->SetUserText(user_text);
91 }
92
89 // Type a character to get instant to trigger and determine instant support. 93 // Type a character to get instant to trigger and determine instant support.
90 void DetermineInstantSupport() { 94 void DetermineInstantSupport() {
91 ui_test_utils::WindowedNotificationObserver observer( 95 ui_test_utils::WindowedNotificationObserver observer(
92 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 96 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
93 content::NotificationService::AllSources()); 97 content::NotificationService::AllSources());
94 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword. 98 // "a" triggers the "about:" provider. "b" begins the "bing.com" keyword.
95 // "c" might someday trigger a "chrome:" provider. 99 // "c" might someday trigger a "chrome:" provider.
96 omnibox()->SetUserText(ASCIIToUTF16("d")); 100 SetOmniboxFocusAndUserText(ASCIIToUTF16("d"));
97 observer.Wait(); 101 observer.Wait();
98 } 102 }
99 103
100 // Types "def" into the omnibox and waits for the preview to be shown. 104 // Types "def" into the omnibox and waits for the preview to be shown.
101 void SearchAndWaitForPreviewToShow() { 105 void SearchAndWaitForPreviewToShow() {
102 ui_test_utils::WindowedNotificationObserver observer( 106 ui_test_utils::WindowedNotificationObserver observer(
103 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN, 107 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
104 content::NotificationService::AllSources()); 108 content::NotificationService::AllSources());
105 omnibox()->SetUserText(ASCIIToUTF16("def")); 109 SetOmniboxFocusAndUserText(search_term_);
106 observer.Wait(); 110 observer.Wait();
107 } 111 }
108 112
109 // Sends a message to the renderer and waits for the response to come back to 113 // Sends a message to the renderer and waits for the response to come back to
110 // the browser. Returns true on success. 114 // the browser. Returns true on success.
111 bool WaitForMessageToBeProcessedByRenderer() { 115 bool WaitForMessageToBeProcessedByRenderer() {
112 bool result = false; 116 bool result = false;
113 return GetBoolFromJavascript(preview()->web_contents(), "true", &result) && 117 return GetBoolFromJavascript(preview()->web_contents(), "true", &result) &&
114 result; 118 result;
115 } 119 }
116 120
117 InstantController* instant() const { 121 InstantController* instant() const {
118 return browser()->instant_controller()->instant(); 122 return browser()->instant_controller()->instant();
119 } 123 }
120 124
121 OmniboxView* omnibox() const { 125 OmniboxView* omnibox() const {
122 return browser()->window()->GetLocationBar()->GetLocationEntry(); 126 return browser()->window()->GetLocationBar()->GetLocationEntry();
123 } 127 }
124 128
125 TabContents* preview() const { 129 TabContents* preview() const {
126 return instant()->GetPreviewContents(); 130 return instant()->GetPreviewContents();
127 } 131 }
128 132
129 InstantLoader* loader() const { 133 InstantLoader* loader() const {
130 return instant()->loader_.get(); 134 return instant()->loader_.get();
131 } 135 }
132 136
133 std::string GetSuggestion() const { 137 string16 last_full_text() const {
134 return UTF16ToUTF8(loader()->complete_suggested_text_); 138 return instant()->last_full_text_;
139 }
140
141 bool is_showing() const {
142 return instant()->is_showing_;
135 } 143 }
136 144
137 bool PressEnter() { 145 bool PressEnter() {
138 return ui_test_utils::SendKeyPressSync( 146 return ui_test_utils::SendKeyPressSync(
139 browser(), ui::VKEY_RETURN, false, false, false, false); 147 browser(), ui::VKEY_RETURN, false, false, false, false);
140 } 148 }
141 149
142 bool SetSuggestionsJavascriptArgument(const std::string& argument) { 150 bool SetSuggestionsJavascriptArgument(const std::string& argument) {
143 std::wstring script = UTF8ToWide(base::StringPrintf( 151 std::wstring script = UTF8ToWide(base::StringPrintf(
144 "window.setSuggestionsArgument = %s;", argument.c_str())); 152 "window.setSuggestionsArgument = %s;", argument.c_str()));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 selection_end); 266 selection_end);
259 } 267 }
260 268
261 protected: 269 protected:
262 virtual void SetUpCommandLine(CommandLine* command_line) { 270 virtual void SetUpCommandLine(CommandLine* command_line) {
263 // Do not prelaunch the GPU process for these tests because it will show 271 // Do not prelaunch the GPU process for these tests because it will show
264 // up in task manager but whether it appears before or after the new tab 272 // up in task manager but whether it appears before or after the new tab
265 // renderer process is not well defined. 273 // renderer process is not well defined.
266 command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch); 274 command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
267 } 275 }
276
277 const string16 search_term_;
268 }; 278 };
269 279
270 // TODO(tonyg): Add the following tests: 280 // TODO(tonyg): Add the following tests:
271 // - Test that the search box API is not populated for pages other than the 281 // - Test that the search box API is not populated for pages other than the
272 // default search provider. 282 // default search provider.
273 // - Test resize events. 283 // - Test resize events.
274 284
275 // Verify that the onchange event is dispatched upon typing in the box. 285 // Verify that the onchange event is dispatched upon typing in the box.
276 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(OnChangeEvent)) { 286 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(OnChangeEvent)) {
277 ASSERT_TRUE(test_server()->Start()); 287 ASSERT_TRUE(test_server()->Start());
278 EnableInstant(); 288 EnableInstant();
279 SetupInstantProvider("instant.html"); 289 SetupInstantProvider("instant.html");
280 DetermineInstantSupport(); 290 DetermineInstantSupport();
281 SearchAndWaitForPreviewToShow(); 291 SearchAndWaitForPreviewToShow();
282 292
283 EXPECT_TRUE(preview()); 293 EXPECT_TRUE(preview());
284 EXPECT_TRUE(instant()->is_displayable()); 294 EXPECT_TRUE(is_showing());
285 EXPECT_TRUE(instant()->IsCurrent()); 295 EXPECT_TRUE(instant()->IsCurrent());
286 EXPECT_EQ("defghi", UTF16ToUTF8(omnibox()->GetText())); 296 EXPECT_EQ(ASCIIToUTF16("defghi"), omnibox()->GetText());
287 297
288 // Make sure the URL that will get committed when we press <Enter> matches 298 // Make sure the URL that will get committed when we press <Enter> matches
289 // that of the default search provider. 299 // that of the default search provider.
290 const TemplateURL* default_turl = 300 const TemplateURL* default_turl =
291 TemplateURLServiceFactory::GetForProfile(browser()->profile())-> 301 TemplateURLServiceFactory::GetForProfile(browser()->profile())->
292 GetDefaultSearchProvider(); 302 GetDefaultSearchProvider();
293 EXPECT_TRUE(default_turl); 303 EXPECT_TRUE(default_turl);
294 EXPECT_EQ(default_turl->url_ref().ReplaceSearchTerms( 304 EXPECT_EQ(default_turl->url_ref().ReplaceSearchTerms(
295 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("defghi"))), 305 TemplateURLRef::SearchTermsArgs(string16())),
296 loader()->url().spec()); 306 loader()->instant_url().spec());
297 307
298 // Check that the value is reflected and onchange is called. 308 // Check that the value is reflected and onchange is called.
299 EXPECT_EQ("true 0 0 1 true d false def false 3 3", 309 EXPECT_EQ("true 0 0 2 false d false def true 3 3",
300 GetSearchStateAsString(preview()->web_contents(), false)); 310 GetSearchStateAsString(preview()->web_contents(), false));
301 } 311 }
302 312
303 // Verify that the onsubmit event is dispatched upon pressing <Enter>. 313 // Verify that the onsubmit event is dispatched upon pressing <Enter>.
304 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(OnSubmitEvent)) { 314 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(OnSubmitEvent)) {
305 ASSERT_TRUE(test_server()->Start()); 315 ASSERT_TRUE(test_server()->Start());
306 EnableInstant(); 316 EnableInstant();
307 SetupInstantProvider("instant.html"); 317 SetupInstantProvider("instant.html");
308 DetermineInstantSupport(); 318 DetermineInstantSupport();
309 SearchAndWaitForPreviewToShow(); 319 SearchAndWaitForPreviewToShow();
310 320
311 EXPECT_TRUE(preview()); 321 EXPECT_TRUE(preview());
312 EXPECT_TRUE(instant()->is_displayable()); 322 EXPECT_TRUE(is_showing());
313 EXPECT_TRUE(instant()->IsCurrent()); 323 EXPECT_TRUE(instant()->IsCurrent());
314 EXPECT_EQ("defghi", UTF16ToUTF8(omnibox()->GetText())); 324 EXPECT_EQ("defghi", UTF16ToUTF8(omnibox()->GetText()));
315 325
316 WebContents* preview_tab = preview()->web_contents(); 326 WebContents* preview_tab = preview()->web_contents();
317 EXPECT_TRUE(preview_tab); 327 EXPECT_TRUE(preview_tab);
318 328
319 ASSERT_TRUE(PressEnter()); 329 ASSERT_TRUE(PressEnter());
320 330
321 // Check that the preview has been committed. 331 // Check that the preview has been committed.
322 EXPECT_FALSE(preview()); 332 EXPECT_FALSE(preview());
323 EXPECT_FALSE(instant()->is_displayable()); 333 EXPECT_FALSE(is_showing());
324 EXPECT_FALSE(instant()->IsCurrent()); 334 EXPECT_FALSE(instant()->IsCurrent());
325 EXPECT_EQ(preview_tab, chrome::GetActiveWebContents(browser())); 335 EXPECT_EQ(preview_tab, chrome::GetActiveWebContents(browser()));
326 336
327 // We should have two entries. One corresponding to the page the user was 337 // We should have two entries. One corresponding to the page the user was
328 // first on, and one for the search page. 338 // first on, and one for the search page.
329 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); 339 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount());
330 340
331 // Check that the value is reflected and onsubmit is called. 341 // Check that the value is reflected and onsubmit is called.
332 EXPECT_EQ("true 1 0 1 true d false defghi true 3 3", 342 EXPECT_EQ("true 1 0 2 false d false defghi true 6 6",
333 GetSearchStateAsString(preview_tab, true)); 343 GetSearchStateAsString(preview_tab, true));
334 344
335 // Make sure the searchbox values were reset. 345 // Make sure the searchbox values were reset.
336 EXPECT_EQ("true 1 0 1 true d false false 0 0", 346 EXPECT_EQ("true 1 0 2 false d false false 0 0",
337 GetSearchStateAsString(preview_tab, false)); 347 GetSearchStateAsString(preview_tab, false));
338 } 348 }
339 349
340 // Verify that the oncancel event is dispatched upon losing focus. 350 // Verify that the oncancel event is dispatched upon losing focus.
341 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnCancelEvent) { 351 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnCancelEvent) {
342 ASSERT_TRUE(test_server()->Start()); 352 ASSERT_TRUE(test_server()->Start());
343 EnableInstant(); 353 EnableInstant();
344 SetupInstantProvider("instant.html"); 354 SetupInstantProvider("instant.html");
345 DetermineInstantSupport(); 355 DetermineInstantSupport();
346 SearchAndWaitForPreviewToShow(); 356 SearchAndWaitForPreviewToShow();
347 357
348 EXPECT_TRUE(preview()); 358 EXPECT_TRUE(preview());
349 EXPECT_TRUE(instant()->is_displayable()); 359 EXPECT_TRUE(is_showing());
350 EXPECT_TRUE(instant()->IsCurrent()); 360 EXPECT_TRUE(instant()->IsCurrent());
351 EXPECT_EQ("defghi", UTF16ToUTF8(omnibox()->GetText())); 361 EXPECT_EQ("defghi", UTF16ToUTF8(omnibox()->GetText()));
352 362
353 WebContents* preview_tab = preview()->web_contents(); 363 WebContents* preview_tab = preview()->web_contents();
354 EXPECT_TRUE(preview_tab); 364 EXPECT_TRUE(preview_tab);
355 365
356 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 366 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
357 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); 367 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
358 368
359 // Check that the preview has been committed. 369 // Check that the preview has been committed.
360 EXPECT_FALSE(preview()); 370 EXPECT_FALSE(preview());
361 EXPECT_FALSE(instant()->is_displayable()); 371 EXPECT_FALSE(is_showing());
362 EXPECT_FALSE(instant()->IsCurrent()); 372 EXPECT_FALSE(instant()->IsCurrent());
363 EXPECT_EQ(preview_tab, chrome::GetActiveWebContents(browser())); 373 EXPECT_EQ(preview_tab, chrome::GetActiveWebContents(browser()));
364 374
365 // Check that the value is reflected and oncancel is called. 375 // Check that the value is reflected and oncancel is called.
366 EXPECT_EQ("true 0 1 1 true d false def false 3 3", 376 EXPECT_EQ("true 0 1 1 true d false def false 3 3",
367 GetSearchStateAsString(preview_tab, true)); 377 GetSearchStateAsString(preview_tab, true));
368 378
369 // Make sure the searchbox values were reset. 379 // Make sure the searchbox values were reset.
370 EXPECT_EQ("true 0 1 1 true d false false 0 0", 380 EXPECT_EQ("true 0 1 1 true d false false 0 0",
371 GetSearchStateAsString(preview_tab, false)); 381 GetSearchStateAsString(preview_tab, false));
372 } 382 }
373 383
374 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsArrayOfStrings)) { 384 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsArrayOfStrings)) {
375 ASSERT_TRUE(test_server()->Start()); 385 ASSERT_TRUE(test_server()->Start());
376 EnableInstant(); 386 EnableInstant();
377 SetupInstantProvider("instant.html"); 387 SetupInstantProvider("instant.html");
378 DetermineInstantSupport(); 388 DetermineInstantSupport();
379 389
380 ASSERT_TRUE(SetSuggestionsJavascriptArgument("['defg', 'unused']")); 390 ASSERT_TRUE(SetSuggestionsJavascriptArgument("['defg', 'unused']"));
381 SearchAndWaitForPreviewToShow(); 391 SearchAndWaitForPreviewToShow();
382 EXPECT_EQ("defg", GetSuggestion()); 392 EXPECT_EQ(ASCIIToUTF16("defg"), last_full_text());
383 } 393 }
384 394
385 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptyArray)) { 395 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptyArray)) {
386 ASSERT_TRUE(test_server()->Start()); 396 ASSERT_TRUE(test_server()->Start());
387 EnableInstant(); 397 EnableInstant();
388 SetupInstantProvider("instant.html"); 398 SetupInstantProvider("instant.html");
389 DetermineInstantSupport(); 399 DetermineInstantSupport();
390 400
391 ASSERT_TRUE(SetSuggestionsJavascriptArgument("[]")); 401 ASSERT_TRUE(SetSuggestionsJavascriptArgument("[]"));
392 SearchAndWaitForPreviewToShow(); 402 SearchAndWaitForPreviewToShow();
393 EXPECT_EQ("", GetSuggestion()); 403 EXPECT_EQ(search_term_, last_full_text());
394 } 404 }
395 405
396 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsValidJson)) { 406 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsValidJson)) {
397 ASSERT_TRUE(test_server()->Start()); 407 ASSERT_TRUE(test_server()->Start());
398 EnableInstant(); 408 EnableInstant();
399 SetupInstantProvider("instant.html"); 409 SetupInstantProvider("instant.html");
400 DetermineInstantSupport(); 410 DetermineInstantSupport();
401 411
402 ASSERT_TRUE(SetSuggestionsJavascriptArgument( 412 ASSERT_TRUE(SetSuggestionsJavascriptArgument(
403 "{suggestions:[{value:'defg'},{value:'unused'}]}")); 413 "{suggestions:[{value:'defg'},{value:'unused'}]}"));
404 SearchAndWaitForPreviewToShow(); 414 SearchAndWaitForPreviewToShow();
405 EXPECT_EQ("defg", GetSuggestion()); 415 EXPECT_EQ(ASCIIToUTF16("defg"), last_full_text());
406 } 416 }
407 417
408 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsInvalidSuggestions)) { 418 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsInvalidSuggestions)) {
409 ASSERT_TRUE(test_server()->Start()); 419 ASSERT_TRUE(test_server()->Start());
410 EnableInstant(); 420 EnableInstant();
411 SetupInstantProvider("instant.html"); 421 SetupInstantProvider("instant.html");
412 DetermineInstantSupport(); 422 DetermineInstantSupport();
413 423
414 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:{value:'defg'}}")); 424 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:{value:'defg'}}"));
415 SearchAndWaitForPreviewToShow(); 425 SearchAndWaitForPreviewToShow();
416 EXPECT_EQ("", GetSuggestion()); 426 EXPECT_EQ(search_term_, last_full_text());
417 } 427 }
418 428
419 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptyJson)) { 429 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptyJson)) {
420 ASSERT_TRUE(test_server()->Start()); 430 ASSERT_TRUE(test_server()->Start());
421 EnableInstant(); 431 EnableInstant();
422 SetupInstantProvider("instant.html"); 432 SetupInstantProvider("instant.html");
423 DetermineInstantSupport(); 433 DetermineInstantSupport();
424 434
425 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{}")); 435 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{}"));
426 SearchAndWaitForPreviewToShow(); 436 SearchAndWaitForPreviewToShow();
427 EXPECT_EQ("", GetSuggestion()); 437 EXPECT_EQ(search_term_, last_full_text());
428 } 438 }
429 439
430 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptySuggestions)) { 440 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptySuggestions)) {
431 ASSERT_TRUE(test_server()->Start()); 441 ASSERT_TRUE(test_server()->Start());
432 EnableInstant(); 442 EnableInstant();
433 SetupInstantProvider("instant.html"); 443 SetupInstantProvider("instant.html");
434 DetermineInstantSupport(); 444 DetermineInstantSupport();
435 445
436 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:[]}")); 446 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:[]}"));
437 SearchAndWaitForPreviewToShow(); 447 SearchAndWaitForPreviewToShow();
438 EXPECT_EQ("", GetSuggestion()); 448 EXPECT_EQ(search_term_, last_full_text());
439 } 449 }
440 450
441 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptySuggestion)) { 451 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SetSuggestionsEmptySuggestion)) {
442 ASSERT_TRUE(test_server()->Start()); 452 ASSERT_TRUE(test_server()->Start());
443 EnableInstant(); 453 EnableInstant();
444 SetupInstantProvider("instant.html"); 454 SetupInstantProvider("instant.html");
445 DetermineInstantSupport(); 455 DetermineInstantSupport();
446 456
447 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:[{}]}")); 457 ASSERT_TRUE(SetSuggestionsJavascriptArgument("{suggestions:[{}]}"));
448 SearchAndWaitForPreviewToShow(); 458 SearchAndWaitForPreviewToShow();
449 EXPECT_EQ("", GetSuggestion()); 459 EXPECT_EQ(search_term_, last_full_text());
450 } 460 }
451 461
452 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(InstantCompleteNever)) { 462 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(InstantCompleteNever)) {
453 ASSERT_TRUE(test_server()->Start()); 463 ASSERT_TRUE(test_server()->Start());
454 EnableInstant(); 464 EnableInstant();
455 SetupInstantProvider("instant.html"); 465 SetupInstantProvider("instant.html");
456 DetermineInstantSupport(); 466 DetermineInstantSupport();
457 467
458 ASSERT_TRUE(SetSuggestionsJavascriptArgument( 468 ASSERT_TRUE(SetSuggestionsJavascriptArgument(
459 "{suggestions:[{value:'defg'}],complete_behavior:'never'}")); 469 "{suggestions:[{value:'defg'}],complete_behavior:'never'}"));
460 SearchAndWaitForPreviewToShow(); 470 SearchAndWaitForPreviewToShow();
461 EXPECT_EQ("defg", GetSuggestion()); 471 EXPECT_EQ(search_term_, last_full_text());
462 472
463 EXPECT_EQ(INSTANT_COMPLETE_NEVER, 473 EXPECT_EQ(INSTANT_COMPLETE_NEVER,
464 omnibox()->model()->instant_complete_behavior()); 474 omnibox()->model()->instant_complete_behavior());
465 EXPECT_EQ("def", UTF16ToUTF8(omnibox()->GetText())); 475 EXPECT_EQ(search_term_, omnibox()->GetText());
466 } 476 }
467 477
468 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(InstantCompleteDelayed)) { 478 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_InstantCompleteDelayed) {
469 ASSERT_TRUE(test_server()->Start()); 479 ASSERT_TRUE(test_server()->Start());
470 EnableInstant(); 480 EnableInstant();
471 SetupInstantProvider("instant.html"); 481 SetupInstantProvider("instant.html");
472 DetermineInstantSupport(); 482 DetermineInstantSupport();
473 483
474 ASSERT_TRUE(SetSuggestionsJavascriptArgument( 484 ASSERT_TRUE(SetSuggestionsJavascriptArgument(
475 "{suggestions:[{value:'defg'}],complete_behavior:'delayed'}")); 485 "{suggestions:[{value:'defg'}],complete_behavior:'delayed'}"));
476 SearchAndWaitForPreviewToShow(); 486 SearchAndWaitForPreviewToShow();
477 EXPECT_EQ("defg", GetSuggestion()); 487 EXPECT_EQ(search_term_, last_full_text());
478 488
479 EXPECT_EQ(INSTANT_COMPLETE_DELAYED, 489 EXPECT_EQ(INSTANT_COMPLETE_DELAYED,
480 omnibox()->model()->instant_complete_behavior()); 490 omnibox()->model()->instant_complete_behavior());
481 EXPECT_EQ("def", UTF16ToUTF8(omnibox()->GetText())); 491 EXPECT_EQ(ASCIIToUTF16("defg"), omnibox()->GetText());
482 } 492 }
483 493
484 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(InstantCompleteNow)) { 494 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(InstantCompleteNow)) {
485 ASSERT_TRUE(test_server()->Start()); 495 ASSERT_TRUE(test_server()->Start());
486 EnableInstant(); 496 EnableInstant();
487 SetupInstantProvider("instant.html"); 497 SetupInstantProvider("instant.html");
488 DetermineInstantSupport(); 498 DetermineInstantSupport();
489 499
490 ASSERT_TRUE(SetSuggestionsJavascriptArgument( 500 ASSERT_TRUE(SetSuggestionsJavascriptArgument(
491 "{suggestions:[{value:'defg'}],complete_behavior:'now'}")); 501 "{suggestions:[{value:'defg'}],complete_behavior:'now'}"));
492 SearchAndWaitForPreviewToShow(); 502 SearchAndWaitForPreviewToShow();
493 EXPECT_EQ("defg", GetSuggestion()); 503 EXPECT_EQ(ASCIIToUTF16("defg"), last_full_text());
494 504
495 EXPECT_EQ(INSTANT_COMPLETE_NOW, 505 EXPECT_EQ(INSTANT_COMPLETE_NOW,
496 omnibox()->model()->instant_complete_behavior()); 506 omnibox()->model()->instant_complete_behavior());
497 EXPECT_EQ("defg", UTF16ToUTF8(omnibox()->GetText())); 507 EXPECT_EQ(ASCIIToUTF16("defg"), omnibox()->GetText());
498 } 508 }
499 509
500 // Verifies that instant previews aren't shown for crash URLs. 510 // Verifies that instant previews aren't shown for crash URLs.
501 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(CrashUrlCancelsInstant)) { 511 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(CrashUrlCancelsInstant)) {
502 ASSERT_TRUE(test_server()->Start()); 512 ASSERT_TRUE(test_server()->Start());
503 EnableInstant(); 513 EnableInstant();
504 SetupInstantProvider("instant.html"); 514 SetupInstantProvider("instant.html");
505 515
506 omnibox()->SetUserText(ASCIIToUTF16(chrome::kChromeUICrashURL)); 516 SetOmniboxFocusAndUserText(ASCIIToUTF16(chrome::kChromeUICrashURL));
507 EXPECT_FALSE(preview()); 517 EXPECT_FALSE(preview());
508 } 518 }
509 519
510 // Tests that instant doesn't fire for intranet paths that look like searches. 520 // Tests that instant doesn't fire for intranet paths that look like searches.
511 // http://crbug.com/99836 521 // http://crbug.com/99836
512 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(IntranetPathLooksLikeSearch)) { 522 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(IntranetPathLooksLikeSearch)) {
513 ASSERT_TRUE(test_server()->Start()); 523 ASSERT_TRUE(test_server()->Start());
514 EnableInstant(); 524 EnableInstant();
515 SetupInstantProvider("instant.html"); 525 SetupInstantProvider("instant.html");
516 526
(...skipping 10 matching lines...) Expand all
527 EXPECT_FALSE(preview()); 537 EXPECT_FALSE(preview());
528 } 538 }
529 539
530 // Verifies that instant previews aren't shown for non-search URLs. 540 // Verifies that instant previews aren't shown for non-search URLs.
531 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(ShowPreviewNonSearch)) { 541 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(ShowPreviewNonSearch)) {
532 ASSERT_TRUE(test_server()->Start()); 542 ASSERT_TRUE(test_server()->Start());
533 EnableInstant(); 543 EnableInstant();
534 SetupInstantProvider("instant.html"); 544 SetupInstantProvider("instant.html");
535 545
536 GURL url(test_server()->GetURL("files/empty.html")); 546 GURL url(test_server()->GetURL("files/empty.html"));
537 omnibox()->SetUserText(UTF8ToUTF16(url.spec())); 547 SetOmniboxFocusAndUserText(UTF8ToUTF16(url.spec()));
538 EXPECT_FALSE(preview()); 548 EXPECT_FALSE(preview());
539 } 549 }
540 550
541 // Transition from non-search to search and make sure everything works. 551 // Transition from non-search to search and make sure everything works.
542 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(NonSearchToSearch)) { 552 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(NonSearchToSearch)) {
543 ASSERT_TRUE(test_server()->Start()); 553 ASSERT_TRUE(test_server()->Start());
544 EnableInstant(); 554 EnableInstant();
545 SetupInstantProvider("instant.html"); 555 SetupInstantProvider("instant.html");
546 556
547 // Load a non-search URL. 557 // Load a non-search URL.
548 GURL url(test_server()->GetURL("files/empty.html")); 558 GURL url(test_server()->GetURL("files/empty.html"));
549 omnibox()->SetUserText(UTF8ToUTF16(url.spec())); 559 SetOmniboxFocusAndUserText(UTF8ToUTF16(url.spec()));
550 EXPECT_FALSE(preview()); 560 EXPECT_FALSE(preview());
551 561
552 // Now type in some search text. 562 // Now type in some search text.
553 DetermineInstantSupport(); 563 DetermineInstantSupport();
554 564
555 // We should now have a preview, but it shouldn't be showing yet, because we 565 // We should now have a preview, but it shouldn't be showing yet, because we
556 // haven't gotten back suggestions. 566 // haven't gotten back suggestions.
557 EXPECT_TRUE(preview()); 567 EXPECT_TRUE(preview());
558 EXPECT_FALSE(loader()->ready()); 568 EXPECT_FALSE(is_showing());
559 EXPECT_FALSE(instant()->is_displayable()); 569 EXPECT_TRUE(instant()->IsCurrent());
560 EXPECT_FALSE(instant()->IsCurrent());
561 570
562 // Reset the user text so that the page is told the text changed. 571 // Reset the user text so that the page is told the text changed.
563 // 572 //
564 // Typing into the omnibox sends onchange() to the page, which responds with 573 // Typing into the omnibox sends onchange() to the page, which responds with
565 // suggestions, which causes the preview to be shown. However, when we called 574 // suggestions, which causes the preview to be shown. However, when we called
566 // DetermineInstantSupport(), the resulting onchange was dropped on the floor 575 // DetermineInstantSupport(), the resulting onchange was dropped on the floor
567 // because the page wasn't loaded yet. This is fine (the user may type before 576 // because the page wasn't loaded yet. This is fine (the user may type before
568 // the page loads too). To handle this, we explicitly call onchange after the 577 // the page loads too). To handle this, we explicitly call onchange after the
569 // page loads (see initScript in searchbox_extension.cc). The search provider 578 // page loads (see initScript in searchbox_extension.cc). The search provider
570 // used in this test (instant.html) doesn't support initScript, so we have to 579 // used in this test (instant.html) doesn't support initScript, so we have to
571 // trigger an onchange ourselves. 580 // trigger an onchange ourselves.
572 SearchAndWaitForPreviewToShow(); 581 SearchAndWaitForPreviewToShow();
573 582
574 // We should now be showing the preview. 583 // We should now be showing the preview.
575 EXPECT_TRUE(preview()); 584 EXPECT_TRUE(preview());
576 EXPECT_TRUE(loader()->ready()); 585 EXPECT_TRUE(is_showing());
577 EXPECT_TRUE(instant()->is_displayable());
578 EXPECT_TRUE(instant()->IsCurrent()); 586 EXPECT_TRUE(instant()->IsCurrent());
579 587
580 content::RenderWidgetHostView* rwhv = 588 content::RenderWidgetHostView* rwhv =
581 preview()->web_contents()->GetRenderWidgetHostView(); 589 preview()->web_contents()->GetRenderWidgetHostView();
582 EXPECT_TRUE(rwhv); 590 EXPECT_TRUE(rwhv);
583 EXPECT_TRUE(rwhv->IsShowing()); 591 EXPECT_TRUE(rwhv->IsShowing());
584 } 592 }
585 593
586 // Transition from search to non-search and make sure instant isn't displayable. 594 // Transition from search to non-search and make sure instant isn't displayable.
587 // See bug http://crbug.com/100368 for details. 595 // See bug http://crbug.com/100368 for details.
588 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SearchToNonSearch)) { 596 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SearchToNonSearch)) {
589 ASSERT_TRUE(test_server()->Start()); 597 ASSERT_TRUE(test_server()->Start());
590 EnableInstant(); 598 EnableInstant();
591 SetupInstantProvider("instant.html"); 599 SetupInstantProvider("instant.html");
592 600
593 ui_test_utils::WindowedNotificationObserver instant_support_observer( 601 ui_test_utils::WindowedNotificationObserver instant_support_observer(
594 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 602 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
595 content::NotificationService::AllSources()); 603 content::NotificationService::AllSources());
596 604
597 // Type in some search text. 605 // Type in some search text.
598 omnibox()->SetUserText(ASCIIToUTF16("def")); 606 SetOmniboxFocusAndUserText(search_term_);
599 607
600 // Load a non search URL. Don't wait for the preview to navigate. It'll still 608 // Load a non search URL. Don't wait for the preview to navigate. It'll still
601 // end up loading in the background. 609 // end up loading in the background.
602 GURL url(test_server()->GetURL("files/empty.html")); 610 GURL url(test_server()->GetURL("files/empty.html"));
603 omnibox()->SetUserText(UTF8ToUTF16(url.spec())); 611 SetOmniboxFocusAndUserText(UTF8ToUTF16(url.spec()));
604 612
605 instant_support_observer.Wait(); 613 instant_support_observer.Wait();
606 614
607 // We should now have a preview, but it shouldn't be showing yet. 615 // We should now have a preview, but it shouldn't be showing yet.
608 EXPECT_TRUE(preview()); 616 EXPECT_TRUE(preview());
609 EXPECT_FALSE(loader()->ready()); 617 EXPECT_FALSE(is_showing());
610 EXPECT_FALSE(instant()->is_displayable());
611 EXPECT_FALSE(instant()->IsCurrent()); 618 EXPECT_FALSE(instant()->IsCurrent());
612 619
613 // Send onchange so that the page sends up suggestions. See the comments in 620 // Send onchange so that the page sends up suggestions. See the comments in
614 // NonSearchToSearch for why this is needed. 621 // NonSearchToSearch for why this is needed.
615 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 622 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
616 preview()->web_contents()->GetRenderViewHost(), std::wstring(), 623 preview()->web_contents()->GetRenderViewHost(), std::wstring(),
617 L"window.chrome.searchBox.onchange();")); 624 L"window.chrome.searchBox.onchange();"));
618 ASSERT_TRUE(WaitForMessageToBeProcessedByRenderer()); 625 ASSERT_TRUE(WaitForMessageToBeProcessedByRenderer());
619 626
620 // Instant should be active, but not displaying. 627 // Instant should be active, but not displaying.
621 EXPECT_TRUE(preview()); 628 EXPECT_TRUE(preview());
622 EXPECT_TRUE(loader()->ready()); 629 EXPECT_FALSE(is_showing());
623 EXPECT_FALSE(instant()->is_displayable());
624 EXPECT_FALSE(instant()->IsCurrent()); 630 EXPECT_FALSE(instant()->IsCurrent());
625 } 631 }
626 632
627 // Makes sure that if the server doesn't support the instant API we don't show 633 // Makes sure that if the server doesn't support the instant API we don't show
628 // anything. 634 // anything.
629 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SearchServerDoesntSupportInstant)) { 635 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(SearchServerDoesntSupportInstant)) {
630 ASSERT_TRUE(test_server()->Start()); 636 ASSERT_TRUE(test_server()->Start());
631 EnableInstant(); 637 EnableInstant();
632 SetupInstantProvider("empty.html"); 638 SetupInstantProvider("empty.html");
633 639
634 ui_test_utils::WindowedNotificationObserver tab_closed_observer( 640 ui_test_utils::WindowedNotificationObserver tab_closed_observer(
635 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 641 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
636 content::NotificationService::AllSources()); 642 content::NotificationService::AllSources());
637 643
638 omnibox()->SetUserText(ASCIIToUTF16("d")); 644 SetOmniboxFocusAndUserText(ASCIIToUTF16("d"));
639 EXPECT_TRUE(preview()); 645 EXPECT_TRUE(preview());
640 646
641 // When the response comes back that the page doesn't support instant the tab 647 // When the response comes back that the page doesn't support instant the tab
642 // should be closed. 648 // should be closed.
643 tab_closed_observer.Wait(); 649 tab_closed_observer.Wait();
644 EXPECT_FALSE(preview()); 650 EXPECT_FALSE(preview());
645 } 651 }
646 652
647 // Verifies transitioning from loading a non-search string to a search string 653 // Verifies transitioning from loading a non-search string to a search string
648 // with the provider not supporting instant works (meaning we don't display 654 // with the provider not supporting instant works (meaning we don't display
649 // anything). 655 // anything).
650 IN_PROC_BROWSER_TEST_F(InstantTest, 656 IN_PROC_BROWSER_TEST_F(InstantTest,
651 MAYBE(NonSearchToSearchDoesntSupportInstant)) { 657 MAYBE(NonSearchToSearchDoesntSupportInstant)) {
652 ASSERT_TRUE(test_server()->Start()); 658 ASSERT_TRUE(test_server()->Start());
653 EnableInstant(); 659 EnableInstant();
654 SetupInstantProvider("empty.html"); 660 SetupInstantProvider("empty.html");
655 661
656 GURL url(test_server()->GetURL("files/empty.html")); 662 GURL url(test_server()->GetURL("files/empty.html"));
657 omnibox()->SetUserText(UTF8ToUTF16(url.spec())); 663 SetOmniboxFocusAndUserText(UTF8ToUTF16(url.spec()));
658 EXPECT_FALSE(preview()); 664 EXPECT_FALSE(preview());
659 665
660 ui_test_utils::WindowedNotificationObserver tab_closed_observer( 666 ui_test_utils::WindowedNotificationObserver tab_closed_observer(
661 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 667 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
662 content::NotificationService::AllSources()); 668 content::NotificationService::AllSources());
663 669
664 // Now type in some search text. 670 // Now type in some search text.
665 omnibox()->SetUserText(ASCIIToUTF16("d")); 671 SetOmniboxFocusAndUserText(ASCIIToUTF16("d"));
666 EXPECT_TRUE(preview()); 672 EXPECT_TRUE(preview());
667 673
668 // When the response comes back that the page doesn't support instant the tab 674 // When the response comes back that the page doesn't support instant the tab
669 // should be closed. 675 // should be closed.
670 tab_closed_observer.Wait(); 676 tab_closed_observer.Wait();
671 EXPECT_FALSE(preview()); 677 EXPECT_FALSE(preview());
672 } 678 }
673 679
674 // Verifies the page was told a non-zero height. 680 // Verifies the page was told a non-zero height.
675 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(ValidHeight)) { 681 // TODO(dominich): This seems to be a dumb test. Confirm that it's dumb.
682 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_ValidHeight) {
676 ASSERT_TRUE(test_server()->Start()); 683 ASSERT_TRUE(test_server()->Start());
677 EnableInstant(); 684 EnableInstant();
678 SetupInstantProvider("instant.html"); 685 SetupInstantProvider("instant.html");
679 DetermineInstantSupport(); 686 DetermineInstantSupport();
680 SearchAndWaitForPreviewToShow(); 687 SearchAndWaitForPreviewToShow();
681 688
682 int height = -1; 689 int height = -1;
683 690
684 // searchBox height is not yet set during initial load. 691 // searchBox height is not yet set during initial load.
685 ASSERT_TRUE(GetIntFromJavascript(preview()->web_contents(), 692 ASSERT_TRUE(GetIntFromJavascript(preview()->web_contents(),
(...skipping 23 matching lines...) Expand all
709 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(DontPersistSearchbox)) { 716 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(DontPersistSearchbox)) {
710 ASSERT_TRUE(test_server()->Start()); 717 ASSERT_TRUE(test_server()->Start());
711 EnableInstant(); 718 EnableInstant();
712 SetupInstantProvider("instant.html"); 719 SetupInstantProvider("instant.html");
713 DetermineInstantSupport(); 720 DetermineInstantSupport();
714 SearchAndWaitForPreviewToShow(); 721 SearchAndWaitForPreviewToShow();
715 722
716 std::string value; 723 std::string value;
717 ASSERT_TRUE(GetStringFromJavascript(preview()->web_contents(), 724 ASSERT_TRUE(GetStringFromJavascript(preview()->web_contents(),
718 "window.chrome.searchBox.value", &value)); 725 "window.chrome.searchBox.value", &value));
719 EXPECT_EQ("def", value); 726 EXPECT_EQ(search_term_, UTF8ToUTF16(value));
720 727
721 // Commit the preview. 728 // Commit the preview.
722 ASSERT_TRUE(PressEnter()); 729 ASSERT_TRUE(PressEnter());
723 EXPECT_FALSE(preview()); 730 EXPECT_FALSE(preview());
724 731
725 // The searchBox actually gets cleared on commit. 732 // The searchBox actually gets cleared on commit.
726 ASSERT_TRUE(GetStringFromJavascript(chrome::GetActiveWebContents(browser()), 733 ASSERT_TRUE(GetStringFromJavascript(chrome::GetActiveWebContents(browser()),
727 "window.chrome.searchBox.value", &value)); 734 "window.chrome.searchBox.value", &value));
728 EXPECT_EQ("", value); 735 EXPECT_EQ("", value);
729 736
(...skipping 30 matching lines...) Expand all
760 767
761 // Focusing the omnibox should cause instant to be preloaded. 768 // Focusing the omnibox should cause instant to be preloaded.
762 ui_test_utils::WindowedNotificationObserver instant_support_observer( 769 ui_test_utils::WindowedNotificationObserver instant_support_observer(
763 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 770 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
764 content::NotificationService::AllSources()); 771 content::NotificationService::AllSources());
765 browser()->window()->GetLocationBar()->FocusLocation(false); 772 browser()->window()->GetLocationBar()->FocusLocation(false);
766 instant_support_observer.Wait(); 773 instant_support_observer.Wait();
767 774
768 // Instant should have a preview, but not display it. 775 // Instant should have a preview, but not display it.
769 EXPECT_TRUE(preview()); 776 EXPECT_TRUE(preview());
770 EXPECT_FALSE(instant()->is_displayable()); 777 EXPECT_FALSE(is_showing());
771 EXPECT_FALSE(instant()->IsCurrent()); 778 EXPECT_FALSE(instant()->IsCurrent());
772 ASSERT_TRUE(CheckVisibilityIs(preview()->web_contents(), false)); 779 ASSERT_TRUE(CheckVisibilityIs(preview()->web_contents(), false));
773 780
774 // Adding a new tab shouldn't delete (or recreate) the TabContents. 781 // Adding a new tab shouldn't delete (or recreate) the TabContents.
775 TabContents* preview_tab = preview(); 782 TabContents* preview_tab = preview();
776 AddBlankTabAndShow(browser()); 783 AddBlankTabAndShow(browser());
777 EXPECT_EQ(preview_tab, preview()); 784 EXPECT_EQ(preview_tab, preview());
778 785
779 // Doing a search should still use the same loader for the preview. 786 // Doing a search should still use the same loader for the preview.
780 SearchAndWaitForPreviewToShow(); 787 SearchAndWaitForPreviewToShow();
781 EXPECT_EQ(preview_tab, preview()); 788 EXPECT_EQ(preview_tab, preview());
782 789
783 // Verify that the preview is in fact showing instant search. 790 // Verify that the preview is in fact showing instant search.
784 EXPECT_TRUE(instant()->is_displayable()); 791 EXPECT_TRUE(is_showing());
785 EXPECT_TRUE(instant()->IsCurrent()); 792 EXPECT_TRUE(instant()->IsCurrent());
786 ASSERT_TRUE(CheckVisibilityIs(preview()->web_contents(), true)); 793 ASSERT_TRUE(CheckVisibilityIs(preview()->web_contents(), true));
787 } 794 }
788 795
789 // Tests that the instant search page's visibility is set correctly. 796 // Tests that the instant search page's visibility is set correctly.
790 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(PageVisibilityTest)) { 797 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(PageVisibilityTest)) {
791 ASSERT_TRUE(test_server()->Start()); 798 ASSERT_TRUE(test_server()->Start());
792 EnableInstant(); 799 EnableInstant();
793 SetupInstantProvider("instant.html"); 800 SetupInstantProvider("instant.html");
794 801
795 // Initially navigate to the empty page which should be visible. 802 // Initially navigate to the empty page which should be visible.
796 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("")); 803 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(""));
797 WebContents* initial_contents = chrome::GetActiveWebContents(browser()); 804 WebContents* initial_contents = chrome::GetActiveWebContents(browser());
798 805
799 ASSERT_TRUE(CheckVisibilityIs(initial_contents, true)); 806 ASSERT_TRUE(CheckVisibilityIs(initial_contents, true));
800 807
801 // Type a search term and wait for the preview to appear. 808 // Type a search term and wait for the preview to appear.
802 browser()->window()->GetLocationBar()->FocusLocation(false); 809 browser()->window()->GetLocationBar()->FocusLocation(false);
803 DetermineInstantSupport(); 810 DetermineInstantSupport();
804 SearchAndWaitForPreviewToShow(); 811 SearchAndWaitForPreviewToShow();
805 WebContents* preview_contents = preview()->web_contents(); 812 WebContents* preview_contents = preview()->web_contents();
806 813
807 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true)); 814 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true));
808 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false)); 815 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false));
809 816
810 // Deleting the user text should hide the preview. 817 // Deleting the user text should hide the preview.
811 omnibox()->SetUserText(string16()); 818 SetOmniboxFocusAndUserText(string16());
812 ASSERT_TRUE(CheckVisibilityIs(preview_contents, false)); 819 ASSERT_TRUE(CheckVisibilityIs(preview_contents, false));
813 ASSERT_TRUE(CheckVisibilityIs(initial_contents, true)); 820 ASSERT_TRUE(CheckVisibilityIs(initial_contents, true));
814 821
815 // Set the user text back and we should see the preview again. 822 // Set the user text back and we should see the preview again.
816 omnibox()->SetUserText(ASCIIToUTF16("def")); 823 // TODO(dominich): This bit is not working. Copy-pasting allows us to see this
824 // in Chrome too.
825 SetOmniboxFocusAndUserText(ASCIIToUTF16("def"));
817 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true)); 826 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true));
818 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false)); 827 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false));
819 828
820 // Commit the preview. 829 // Commit the preview.
821 ASSERT_TRUE(PressEnter()); 830 ASSERT_TRUE(PressEnter());
822 EXPECT_EQ(preview_contents, chrome::GetActiveWebContents(browser())); 831 EXPECT_EQ(preview_contents, chrome::GetActiveWebContents(browser()));
823 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true)); 832 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true));
824 } 833 }
825 834
826 // Tests that the task manager identifies instant's preview tab correctly. 835 // Tests that the task manager identifies instant's preview tab correctly.
(...skipping 10 matching lines...) Expand all
837 DetermineInstantSupport(); 846 DetermineInstantSupport();
838 SearchAndWaitForPreviewToShow(); 847 SearchAndWaitForPreviewToShow();
839 848
840 // Now there should be three rows, the third being the instant preview. 849 // Now there should be three rows, the third being the instant preview.
841 TaskManagerBrowserTestUtil::WaitForResourceChange(3); 850 TaskManagerBrowserTestUtil::WaitForResourceChange(3);
842 string16 prefix = l10n_util::GetStringFUTF16( 851 string16 prefix = l10n_util::GetStringFUTF16(
843 IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX, string16()); 852 IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX, string16());
844 string16 title = task_manager->GetResourceTitle(2); 853 string16 title = task_manager->GetResourceTitle(2);
845 EXPECT_TRUE(StartsWith(title, prefix, true)) << title << " vs " << prefix; 854 EXPECT_TRUE(StartsWith(title, prefix, true)) << title << " vs " << prefix;
846 } 855 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_commit_type.h » ('j') | chrome/browser/instant/instant_controller.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698