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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address 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
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_test_utils.h" 5 #include "chrome/browser/instant/instant_test_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/interactive_test_utils.h" 14 #include "chrome/test/base/interactive_test_utils.h"
16 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/result_codes.h" 18 #include "content/public/common/result_codes.h"
21 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
22 20
23 namespace { 21 namespace {
24 22
25 std::string WrapScript(const std::string& script) { 23 std::string WrapScript(const std::string& script) {
26 return "domAutomationController.send(" + script + ")"; 24 return "domAutomationController.send(" + script + ")";
27 } 25 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void InstantTestBase::FocusOmnibox() { 82 void InstantTestBase::FocusOmnibox() {
85 // If the omnibox already has focus, just notify Instant. 83 // If the omnibox already has focus, just notify Instant.
86 if (omnibox()->model()->has_focus()) { 84 if (omnibox()->model()->has_focus()) {
87 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE, 85 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE,
88 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); 86 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL);
89 } else { 87 } else {
90 browser()->window()->GetLocationBar()->FocusLocation(false); 88 browser()->window()->GetLocationBar()->FocusLocation(false);
91 } 89 }
92 } 90 }
93 91
94 void InstantTestBase::FocusOmniboxAndWaitForInstantSupport() {
95 content::WindowedNotificationObserver observer(
96 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
97 content::NotificationService::AllSources());
98 FocusOmnibox();
99 observer.Wait();
100 }
101
102 void InstantTestBase::SetOmniboxText(const std::string& text) { 92 void InstantTestBase::SetOmniboxText(const std::string& text) {
103 FocusOmnibox(); 93 FocusOmnibox();
104 omnibox()->SetUserText(UTF8ToUTF16(text)); 94 omnibox()->SetUserText(UTF8ToUTF16(text));
105 } 95 }
106 96
107 void InstantTestBase::SetOmniboxTextAndWaitForInstantToShow( 97 void InstantTestBase::SetOmniboxTextAndWaitForInstantToShow(
108 const std::string& text) { 98 const std::string& text) {
109 InstantTestModelObserver observer( 99 InstantTestModelObserver observer(
110 instant()->model(), chrome::search::Mode::MODE_SEARCH_SUGGESTIONS); 100 instant()->model(), chrome::search::Mode::MODE_SEARCH_SUGGESTIONS);
111 SetOmniboxText(text); 101 SetOmniboxText(text);
(...skipping 26 matching lines...) Expand all
138 } 128 }
139 129
140 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents, 130 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents,
141 bool expected) { 131 bool expected) {
142 bool actual = !expected; // Purposely start with a mis-match. 132 bool actual = !expected; // Purposely start with a mis-match.
143 // We can only use ASSERT_*() in a method that returns void, hence this 133 // We can only use ASSERT_*() in a method that returns void, hence this
144 // convoluted check. 134 // convoluted check.
145 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) && 135 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) &&
146 actual == expected; 136 actual == expected;
147 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698