| 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_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/browser_window.h" | 11 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/instant/instant_controller.h" | 12 #include "chrome/browser/instant/instant_controller.h" |
| 13 #include "chrome/browser/location_bar.h" | 13 #include "chrome/browser/location_bar.h" |
| 14 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/renderer_host/render_view_host.h" | 15 #include "chrome/browser/renderer_host/render_view_host.h" |
| 16 #include "chrome/browser/search_engines/template_url.h" | 16 #include "chrome/browser/search_engines/template_url.h" |
| 17 #include "chrome/browser/search_engines/template_url_model.h" | 17 #include "chrome/browser/search_engines/template_url_model.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 18 #include "chrome/browser/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/in_process_browser_test.h" | 22 #include "chrome/test/in_process_browser_test.h" |
| 22 #include "chrome/test/ui_test_utils.h" | 23 #include "chrome/test/ui_test_utils.h" |
| 23 | 24 |
| 24 | 25 |
| 25 class InstantTest : public InProcessBrowserTest { | 26 class InstantTest : public InProcessBrowserTest { |
| 26 public: | 27 public: |
| 27 InstantTest() | 28 InstantTest() |
| 28 : location_bar_(NULL), | 29 : location_bar_(NULL), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 62 |
| 62 // Type a character to get instant to trigger. | 63 // Type a character to get instant to trigger. |
| 63 void SetupLocationBar() { | 64 void SetupLocationBar() { |
| 64 location_bar_ = browser()->window()->GetLocationBar(); | 65 location_bar_ = browser()->window()->GetLocationBar(); |
| 65 ASSERT_TRUE(location_bar_); | 66 ASSERT_TRUE(location_bar_); |
| 66 location_bar_->location_entry()->SetUserText(L"a"); | 67 location_bar_->location_entry()->SetUserText(L"a"); |
| 67 } | 68 } |
| 68 | 69 |
| 69 // Wait for instant to load and ensure it is in the state we expect. | 70 // Wait for instant to load and ensure it is in the state we expect. |
| 70 void SetupPreview() { | 71 void SetupPreview() { |
| 71 preview_ = browser()->instant()->GetPreviewContents(); | 72 preview_ = browser()->instant()->GetPreviewContents()->tab_contents(); |
| 72 ASSERT_TRUE(preview_); | 73 ASSERT_TRUE(preview_); |
| 73 ui_test_utils::WaitForNavigation(&preview_->controller()); | 74 ui_test_utils::WaitForNavigation(&preview_->controller()); |
| 74 | 75 |
| 75 // Verify the initial setup of the search box. | 76 // Verify the initial setup of the search box. |
| 76 ASSERT_TRUE(browser()->instant()); | 77 ASSERT_TRUE(browser()->instant()); |
| 77 EXPECT_TRUE(browser()->instant()->IsShowingInstant()); | 78 EXPECT_TRUE(browser()->instant()->IsShowingInstant()); |
| 78 EXPECT_FALSE(browser()->instant()->is_active()); | 79 EXPECT_FALSE(browser()->instant()->is_active()); |
| 79 | 80 |
| 80 // When the page loads, the initial searchBox values are set and no events | 81 // When the page loads, the initial searchBox values are set and no events |
| 81 // have been called. | 82 // have been called. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // Check that the value is reflected and oncancel is called. | 241 // Check that the value is reflected and oncancel is called. |
| 241 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 242 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
| 242 true, "window.chrome.sv", contents)); | 243 true, "window.chrome.sv", contents)); |
| 243 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( | 244 EXPECT_NO_FATAL_FAILURE(CheckStringValueFromJavascript( |
| 244 "abc", "window.chrome.searchBox.value", contents)); | 245 "abc", "window.chrome.searchBox.value", contents)); |
| 245 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( | 246 EXPECT_NO_FATAL_FAILURE(CheckBoolValueFromJavascript( |
| 246 false, "window.chrome.searchBox.verbatim", contents)); | 247 false, "window.chrome.searchBox.verbatim", contents)); |
| 247 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( | 248 EXPECT_NO_FATAL_FAILURE(CheckIntValueFromJavascript( |
| 248 1, "window.oncancelcalls", contents)); | 249 1, "window.oncancelcalls", contents)); |
| 249 } | 250 } |
| OLD | NEW |