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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 // Instant should not be current (it's still loading). | 235 // Instant should not be current (it's still loading). |
236 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 236 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
237 | 237 |
238 // When the response comes back that the page doesn't support instant the tab | 238 // When the response comes back that the page doesn't support instant the tab |
239 // should be closed. | 239 // should be closed. |
240 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); | 240 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); |
241 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); | 241 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); |
242 EXPECT_FALSE(browser()->instant()->is_active()); | 242 EXPECT_FALSE(browser()->instant()->is_active()); |
243 } | 243 } |
244 | 244 |
245 // Verifies the page was told a non-zero height. | |
246 IN_PROC_BROWSER_TEST_F(InstantTest, ValidHeight) { | |
247 ASSERT_TRUE(test_server()->Start()); | |
248 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("old_api.html")); | |
249 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"a")); | |
250 // The preview should be active. | |
251 ASSERT_TRUE(browser()->instant()->is_active()); | |
252 // And the height should be valid. | |
253 ASSERT_NO_FATAL_FAILURE( | |
254 CheckBoolValueFromJavascript( | |
255 true, "window.validHeight", | |
tonyg
2010/12/11 00:44:17
What do you think about replacing this with a test
| |
256 browser()->instant()->GetPreviewContents()->tab_contents())); | |
257 } | |
258 | |
245 // Verify that the onsubmit event is dispatched upon pressing enter. | 259 // Verify that the onsubmit event is dispatched upon pressing enter. |
246 // TODO(sky): Disabled, http://crbug.com/62940. | 260 // TODO(sky): Disabled, http://crbug.com/62940. |
247 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnSubmitEvent) { | 261 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_OnSubmitEvent) { |
248 ASSERT_TRUE(test_server()->Start()); | 262 ASSERT_TRUE(test_server()->Start()); |
249 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 263 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
250 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 264 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
251 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 265 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
252 | 266 |
253 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); | 267 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); |
254 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_RETURN)); | 268 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_RETURN)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 // Check that the value is reflected and oncancel is called. | 308 // Check that the value is reflected and oncancel is called. |
295 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 309 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
296 true, "window.chrome.sv", contents)); | 310 true, "window.chrome.sv", contents)); |
297 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( | 311 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( |
298 "abc", "window.chrome.searchBox.value", contents)); | 312 "abc", "window.chrome.searchBox.value", contents)); |
299 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 313 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
300 false, "window.chrome.searchBox.verbatim", contents)); | 314 false, "window.chrome.searchBox.verbatim", contents)); |
301 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 315 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
302 1, "window.oncancelcalls", contents)); | 316 1, "window.oncancelcalls", contents)); |
303 } | 317 } |
OLD | NEW |