| OLD | NEW |
| 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/ui/search/instant_test_utils.h" | 5 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 void InstantTestBase::PressEnterAndWaitForNavigation() { | 113 void InstantTestBase::PressEnterAndWaitForNavigation() { |
| 114 content::WindowedNotificationObserver nav_observer( | 114 content::WindowedNotificationObserver nav_observer( |
| 115 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 115 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 116 content::NotificationService::AllSources()); | 116 content::NotificationService::AllSources()); |
| 117 browser_->window()->GetLocationBar()->AcceptInput(); | 117 browser_->window()->GetLocationBar()->AcceptInput(); |
| 118 nav_observer.Wait(); | 118 nav_observer.Wait(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void InstantTestBase::PressEnterAndWaitForFrameLoad() { |
| 122 content::WindowedNotificationObserver nav_observer( |
| 123 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 124 content::NotificationService::AllSources()); |
| 125 browser_->window()->GetLocationBar()->AcceptInput(); |
| 126 nav_observer.Wait(); |
| 127 } |
| 128 |
| 121 bool InstantTestBase::GetBoolFromJS(content::WebContents* contents, | 129 bool InstantTestBase::GetBoolFromJS(content::WebContents* contents, |
| 122 const std::string& script, | 130 const std::string& script, |
| 123 bool* result) { | 131 bool* result) { |
| 124 return content::ExecuteScriptAndExtractBool( | 132 return content::ExecuteScriptAndExtractBool( |
| 125 contents, WrapScript(script), result); | 133 contents, WrapScript(script), result); |
| 126 } | 134 } |
| 127 | 135 |
| 128 bool InstantTestBase::GetIntFromJS(content::WebContents* contents, | 136 bool InstantTestBase::GetIntFromJS(content::WebContents* contents, |
| 129 const std::string& script, | 137 const std::string& script, |
| 130 int* result) { | 138 int* result) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); | 171 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); |
| 164 } | 172 } |
| 165 | 173 |
| 166 base::string16 InstantTestBase::GetBlueText() { | 174 base::string16 InstantTestBase::GetBlueText() { |
| 167 size_t start = 0, end = 0; | 175 size_t start = 0, end = 0; |
| 168 omnibox()->GetSelectionBounds(&start, &end); | 176 omnibox()->GetSelectionBounds(&start, &end); |
| 169 if (start > end) | 177 if (start > end) |
| 170 std::swap(start, end); | 178 std::swap(start, end); |
| 171 return omnibox()->GetText().substr(start, end - start); | 179 return omnibox()->GetText().substr(start, end - start); |
| 172 } | 180 } |
| OLD | NEW |