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

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

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted back to asvitkine's fix. REALLY answered PK's comments. :) Created 7 years, 10 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 "chrome/browser/instant/instant_commit_type.h" 5 #include "chrome/browser/instant/instant_commit_type.h"
6 #include "chrome/browser/instant/instant_ntp.h" 6 #include "chrome/browser/instant/instant_ntp.h"
7 #include "chrome/browser/instant/instant_overlay.h" 7 #include "chrome/browser/instant/instant_overlay.h"
8 #include "chrome/browser/instant/instant_service.h" 8 #include "chrome/browser/instant/instant_service.h"
9 #include "chrome/browser/instant/instant_service_factory.h" 9 #include "chrome/browser/instant/instant_service_factory.h"
10 #include "chrome/browser/instant/instant_test_utils.h" 10 #include "chrome/browser/instant/instant_test_utils.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 omnibox()->model()->OnUpOrDownKeyPressed(1); 47 omnibox()->model()->OnUpOrDownKeyPressed(1);
48 // Wait for JavaScript to run the key handler by executing a blank script. 48 // Wait for JavaScript to run the key handler by executing a blank script.
49 EXPECT_TRUE(ExecuteScript(std::string())); 49 EXPECT_TRUE(ExecuteScript(std::string()));
50 } 50 }
51 51
52 void SendUpArrow() { 52 void SendUpArrow() {
53 omnibox()->model()->OnUpOrDownKeyPressed(-1); 53 omnibox()->model()->OnUpOrDownKeyPressed(-1);
54 // Wait for JavaScript to run the key handler by executing a blank script. 54 // Wait for JavaScript to run the key handler by executing a blank script.
55 EXPECT_TRUE(ExecuteScript(std::string())); 55 EXPECT_TRUE(ExecuteScript(std::string()));
56 } 56 }
57
58 void SendEscape() {
59 omnibox()->model()->OnEscapeKeyPressed();
60 // Wait for JavaScript to run the key handler by executing a blank script.
61 EXPECT_TRUE(ExecuteScript(std::string()));
62 }
57 }; 63 };
58 64
59 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { 65 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) {
60 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 66 ASSERT_NO_FATAL_FAILURE(SetupInstant());
61 EXPECT_TRUE(instant()->extended_enabled_); 67 EXPECT_TRUE(instant()->extended_enabled_);
62 } 68 }
63 69
64 // Test that Instant is preloaded when the omnibox is focused. 70 // Test that Instant is preloaded when the omnibox is focused.
65 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { 71 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
66 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 72 ASSERT_NO_FATAL_FAILURE(SetupInstant());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 content::WebContents* active_tab = 340 content::WebContents* active_tab =
335 browser()->tab_strip_model()->GetActiveWebContents(); 341 browser()->tab_strip_model()->GetActiveWebContents();
336 EXPECT_TRUE(instant_service->IsInstantProcess( 342 EXPECT_TRUE(instant_service->IsInstantProcess(
337 active_tab->GetRenderProcessHost()->GetID())); 343 active_tab->GetRenderProcessHost()->GetID()));
338 344
339 // Navigating elsewhere should not use the Instant render process. 345 // Navigating elsewhere should not use the Instant render process.
340 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 346 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
341 EXPECT_FALSE(instant_service->IsInstantProcess( 347 EXPECT_FALSE(instant_service->IsInstantProcess(
342 active_tab->GetRenderProcessHost()->GetID())); 348 active_tab->GetRenderProcessHost()->GetID()));
343 } 349 }
350
351 // This test simulates a search provider using the InstantExtended API to
352 // navigate through the suggested results and hitting escape to get back to the
353 // original user query.
354 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
355 ASSERT_NO_FATAL_FAILURE(SetupInstant());
356 FocusOmniboxAndWaitForInstantSupport();
357
358 SetOmniboxTextAndWaitForInstantToShow("hello");
359 EXPECT_EQ("hello", GetOmniboxText());
360
361 SendDownArrow();
362 EXPECT_EQ("result 1", GetOmniboxText());
363 SendDownArrow();
364 EXPECT_EQ("result 2", GetOmniboxText());
365 SendEscape();
366 EXPECT_EQ("hello", GetOmniboxText());
367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698