OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void SetupPreview() { | 76 void SetupPreview() { |
77 preview_ = browser()->instant()->GetPreviewContents()->tab_contents(); | 77 preview_ = browser()->instant()->GetPreviewContents()->tab_contents(); |
78 ASSERT_TRUE(preview_); | 78 ASSERT_TRUE(preview_); |
79 ui_test_utils::WaitForNavigation(&preview_->controller()); | 79 ui_test_utils::WaitForNavigation(&preview_->controller()); |
80 | 80 |
81 // Verify the initial setup of the search box. | 81 // Verify the initial setup of the search box. |
82 ASSERT_TRUE(browser()->instant()); | 82 ASSERT_TRUE(browser()->instant()); |
83 EXPECT_TRUE(browser()->instant()->IsShowingInstant()); | 83 EXPECT_TRUE(browser()->instant()->IsShowingInstant()); |
84 EXPECT_FALSE(browser()->instant()->is_active()); | 84 EXPECT_FALSE(browser()->instant()->is_active()); |
85 | 85 |
86 // When the page loads, the initial searchBox values are set and no events | 86 // When the page loads, the initial searchBox values are set and only a |
87 // have been called. | 87 // resize will have been sent. |
88 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 88 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
89 true, "window.chrome.sv", preview_)); | 89 true, "window.chrome.sv", preview_)); |
90 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 90 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
91 0, "window.onsubmitcalls", preview_)); | 91 0, "window.onsubmitcalls", preview_)); |
92 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 92 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
93 0, "window.oncancelcalls", preview_)); | 93 0, "window.oncancelcalls", preview_)); |
94 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 94 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
95 0, "window.onchangecalls", preview_)); | 95 0, "window.onchangecalls", preview_)); |
96 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 96 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
97 0, "window.onresizecalls", preview_)); | 97 1, "window.onresizecalls", preview_)); |
98 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( | 98 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( |
99 "a", "window.chrome.searchBox.value", preview_)); | 99 "a", "window.chrome.searchBox.value", preview_)); |
100 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 100 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
101 false, "window.chrome.searchBox.verbatim", preview_)); | 101 false, "window.chrome.searchBox.verbatim", preview_)); |
102 } | 102 } |
103 | 103 |
104 void SetLocationBarText(const std::wstring& text) { | 104 void SetLocationBarText(const std::wstring& text) { |
105 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 105 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
106 location_bar_->location_entry()->SetUserText(text); | 106 location_bar_->location_entry()->SetUserText(text); |
107 ui_test_utils::WaitForNotification( | 107 ui_test_utils::WaitForNotification( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Instant should not be current (it's still loading). | 237 // Instant should not be current (it's still loading). |
238 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 238 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
239 | 239 |
240 // When the response comes back that the page doesn't support instant the tab | 240 // When the response comes back that the page doesn't support instant the tab |
241 // should be closed. | 241 // should be closed. |
242 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); | 242 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); |
243 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); | 243 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); |
244 EXPECT_FALSE(browser()->instant()->is_active()); | 244 EXPECT_FALSE(browser()->instant()->is_active()); |
245 } | 245 } |
246 | 246 |
| 247 // Verifies the page was told a non-zero height. |
| 248 // TODO: when we nuke the old api and fix 66104, this test should load |
| 249 // search.html. |
| 250 IN_PROC_BROWSER_TEST_F(InstantTest, ValidHeight) { |
| 251 ASSERT_TRUE(test_server()->Start()); |
| 252 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("old_api.html")); |
| 253 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"a")); |
| 254 // The preview should be active. |
| 255 ASSERT_TRUE(browser()->instant()->is_active()); |
| 256 // And the height should be valid. |
| 257 TabContents* tab = browser()->instant()->GetPreviewContents()->tab_contents(); |
| 258 ASSERT_NO_FATAL_FAILURE( |
| 259 CheckBoolValueFromJavascript(true, "window.validHeight", tab)); |
| 260 |
| 261 // Check that searchbox height was also set. |
| 262 std::wstring script = |
| 263 L"window.domAutomationController.send(window.chrome.searchBox.height)"; |
| 264 int height; |
| 265 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
| 266 tab->render_view_host(), std::wstring(), script, &height)); |
| 267 EXPECT_GT(height, 0); |
| 268 } |
| 269 |
247 // Verify that the onsubmit event is dispatched upon pressing enter. | 270 // Verify that the onsubmit event is dispatched upon pressing enter. |
248 // TODO(sky): Disabled, http://crbug.com/62940. | 271 // TODO(sky): Disabled, http://crbug.com/62940. |
249 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnSubmitEvent) { | 272 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnSubmitEvent) { |
250 ASSERT_TRUE(test_server()->Start()); | 273 ASSERT_TRUE(test_server()->Start()); |
251 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 274 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
252 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 275 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
253 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 276 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
254 | 277 |
255 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); | 278 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); |
256 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_RETURN)); | 279 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_RETURN)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // Check that the value is reflected and oncancel is called. | 319 // Check that the value is reflected and oncancel is called. |
297 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 320 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
298 true, "window.chrome.sv", contents)); | 321 true, "window.chrome.sv", contents)); |
299 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( | 322 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( |
300 "abc", "window.chrome.searchBox.value", contents)); | 323 "abc", "window.chrome.searchBox.value", contents)); |
301 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 324 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
302 false, "window.chrome.searchBox.verbatim", contents)); | 325 false, "window.chrome.searchBox.verbatim", contents)); |
303 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 326 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
304 1, "window.oncancelcalls", contents)); | 327 1, "window.oncancelcalls", contents)); |
305 } | 328 } |
OLD | NEW |