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

Side by Side Diff: chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc

Issue 18223002: InstantExtended: Remove overlay control code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 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 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 "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "chrome/browser/search/search.h" 6 #include "chrome/browser/search/search.h"
7 #include "chrome/browser/task_manager/task_manager.h" 7 #include "chrome/browser/task_manager/task_manager.h"
8 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 8 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/host_desktop.h" 11 #include "chrome/browser/ui/host_desktop.h"
12 #include "chrome/browser/ui/omnibox/omnibox_view.h" 12 #include "chrome/browser/ui/omnibox/omnibox_view.h"
13 #include "chrome/browser/ui/search/instant_ntp.h" 13 #include "chrome/browser/ui/search/instant_ntp.h"
14 #include "chrome/browser/ui/search/instant_overlay.h"
15 #include "chrome/browser/ui/search/instant_test_utils.h" 14 #include "chrome/browser/ui/search/instant_test_utils.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/search_types.h" 17 #include "chrome/common/search_types.h"
19 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/interactive_test_utils.h" 20 #include "chrome/test/base/interactive_test_utils.h"
22 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
(...skipping 27 matching lines...) Expand all
52 virtual ~InstantExtendedManualTest() { 51 virtual ~InstantExtendedManualTest() {
53 scoped_host_resolver_proc_.reset(); 52 scoped_host_resolver_proc_.reset();
54 host_resolver_proc_ = NULL; 53 host_resolver_proc_ = NULL;
55 } 54 }
56 55
57 virtual void SetUpOnMainThread() OVERRIDE { 56 virtual void SetUpOnMainThread() OVERRIDE {
58 const testing::TestInfo* const test_info = 57 const testing::TestInfo* const test_info =
59 testing::UnitTest::GetInstance()->current_test_info(); 58 testing::UnitTest::GetInstance()->current_test_info();
60 ASSERT_TRUE(StartsWithASCII(test_info->name(), "MANUAL_", true) || 59 ASSERT_TRUE(StartsWithASCII(test_info->name(), "MANUAL_", true) ||
61 StartsWithASCII(test_info->name(), "DISABLED_", true)); 60 StartsWithASCII(test_info->name(), "DISABLED_", true));
62 // Make IsOffline() return false so we don't try to use the local overlay. 61 // Make IsOffline() return false so we don't try to use the local NTP.
63 disable_network_change_notifier_.reset( 62 disable_network_change_notifier_.reset(
64 new net::NetworkChangeNotifier::DisableForTest()); 63 new net::NetworkChangeNotifier::DisableForTest());
65 } 64 }
66 65
67 virtual void CleanUpOnMainThread() OVERRIDE { 66 virtual void CleanUpOnMainThread() OVERRIDE {
68 disable_network_change_notifier_.reset(); 67 disable_network_change_notifier_.reset();
69 } 68 }
70 69
71 protected: 70 protected:
72 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 71 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
73 chrome::EnableInstantExtendedAPIForTesting(); 72 chrome::EnableInstantExtendedAPIForTesting();
74 } 73 }
75 74
76 content::WebContents* active_tab() { 75 content::WebContents* active_tab() {
77 return browser()->tab_strip_model()->GetActiveWebContents(); 76 return browser()->tab_strip_model()->GetActiveWebContents();
78 } 77 }
79 78
80 bool PressBackspace() {
81 return ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_BACK,
82 false, false, false, false);
83 }
84
85 bool PressBackspaceAndWaitForSuggestions() {
86 content::WindowedNotificationObserver observer(
87 chrome::NOTIFICATION_INSTANT_SET_SUGGESTION,
88 content::NotificationService::AllSources());
89 bool result = PressBackspace();
90 observer.Wait();
91 return result;
92 }
93
94 bool PressBackspaceAndWaitForOverlayToShow() {
95 InstantTestModelObserver observer(
96 instant()->model(), SearchMode::MODE_SEARCH_SUGGESTIONS);
97 return PressBackspace() && observer.WaitForExpectedOverlayState() ==
98 SearchMode::MODE_SEARCH_SUGGESTIONS;
99 }
100
101 bool PressEnterAndWaitForNavigationWithTitle(content::WebContents* contents,
102 const string16& title) {
103 content::TitleWatcher title_watcher(contents, title);
104 content::WindowedNotificationObserver nav_observer(
105 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
106 content::NotificationService::AllSources());
107 browser()->window()->GetLocationBar()->AcceptInput();
108 nav_observer.Wait();
109 return title_watcher.WaitAndGetTitle() == title;
110 }
111
112 GURL GetActiveTabURL() {
113 return active_tab()->GetController().GetActiveEntry()->GetURL();
114 }
115
116 bool GetSelectionState(bool* selected) {
117 return GetBoolFromJS(instant()->GetOverlayContents(),
118 "google.ac.gs().api.i()", selected);
119 }
120
121 bool IsGooglePage(content::WebContents* contents) { 79 bool IsGooglePage(content::WebContents* contents) {
122 bool is_google = false; 80 bool is_google = false;
123 if (!GetBoolFromJS(contents, "!!window.google", &is_google)) 81 if (!GetBoolFromJS(contents, "!!window.google", &is_google))
124 return false; 82 return false;
125 return is_google; 83 return is_google;
126 } 84 }
127 85
128 private: 86 private:
129 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; 87 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_;
130 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; 88 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_;
131 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> 89 scoped_ptr<net::NetworkChangeNotifier::DisableForTest>
132 disable_network_change_notifier_; 90 disable_network_change_notifier_;
133 }; 91 };
134 92
135 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_ShowsGoogleNTP) { 93 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_ShowsGoogleNTP) {
136 set_browser(browser()); 94 set_browser(browser());
137 instant()->SetInstantEnabled(false, true); 95 instant()->ReloadStaleNTP();
138 instant()->SetInstantEnabled(true, false);
139 FocusOmniboxAndWaitForInstantNTPSupport(); 96 FocusOmniboxAndWaitForInstantNTPSupport();
140 97
141 ui_test_utils::NavigateToURLWithDisposition( 98 ui_test_utils::NavigateToURLWithDisposition(
142 browser(), 99 browser(),
143 GURL(chrome::kChromeUINewTabURL), 100 GURL(chrome::kChromeUINewTabURL),
144 NEW_FOREGROUND_TAB, 101 NEW_FOREGROUND_TAB,
145 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 102 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
146 content::WebContents* active_tab = 103 EXPECT_TRUE(IsGooglePage(active_tab()));
147 browser()->tab_strip_model()->GetActiveWebContents();
148 EXPECT_TRUE(IsGooglePage(active_tab));
149 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698