| 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 "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" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void InstantTestBase::FocusOmnibox() { | 111 void InstantTestBase::FocusOmnibox() { |
| 112 // If the omnibox already has focus, just notify Instant. | 112 // If the omnibox already has focus, just notify Instant. |
| 113 if (omnibox()->model()->has_focus()) { | 113 if (omnibox()->model()->has_focus()) { |
| 114 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE, | 114 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE, |
| 115 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 115 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
| 116 } else { | 116 } else { |
| 117 browser_->window()->GetLocationBar()->FocusLocation(false); | 117 browser_->window()->GetLocationBar()->FocusLocation(false); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 void InstantTestBase::FocusOmniboxAndWaitForInstantSupport() { | 121 void InstantTestBase::FocusOmniboxAndWaitForInstantOverlaySupport() { |
| 122 content::WindowedNotificationObserver observer( | 122 content::WindowedNotificationObserver observer( |
| 123 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, | 123 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, |
| 124 content::NotificationService::AllSources()); | 124 content::NotificationService::AllSources()); |
| 125 FocusOmnibox(); | 125 FocusOmnibox(); |
| 126 observer.Wait(); | 126 observer.Wait(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void InstantTestBase::FocusOmniboxAndWaitForInstantExtendedSupport() { | 129 void InstantTestBase::FocusOmniboxAndWaitForInstantOverlayAndNTPSupport() { |
| 130 content::WindowedNotificationObserver ntp_observer( | 130 content::WindowedNotificationObserver ntp_observer( |
| 131 chrome::NOTIFICATION_INSTANT_NTP_SUPPORT_DETERMINED, | 131 chrome::NOTIFICATION_INSTANT_NTP_SUPPORT_DETERMINED, |
| 132 content::NotificationService::AllSources()); | 132 content::NotificationService::AllSources()); |
| 133 content::WindowedNotificationObserver overlay_observer( | 133 content::WindowedNotificationObserver overlay_observer( |
| 134 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, | 134 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, |
| 135 content::NotificationService::AllSources()); | 135 content::NotificationService::AllSources()); |
| 136 FocusOmnibox(); | 136 FocusOmnibox(); |
| 137 ntp_observer.Wait(); | 137 ntp_observer.Wait(); |
| 138 overlay_observer.Wait(); | 138 overlay_observer.Wait(); |
| 139 } | 139 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 size_t start = 0, end = 0; | 217 size_t start = 0, end = 0; |
| 218 omnibox()->GetSelectionBounds(&start, &end); | 218 omnibox()->GetSelectionBounds(&start, &end); |
| 219 if (start > end) | 219 if (start > end) |
| 220 std::swap(start, end); | 220 std::swap(start, end); |
| 221 return omnibox()->GetText().substr(start, end - start); | 221 return omnibox()->GetText().substr(start, end - start); |
| 222 } | 222 } |
| 223 | 223 |
| 224 string16 InstantTestBase::GetGrayText() { | 224 string16 InstantTestBase::GetGrayText() { |
| 225 return omnibox()->GetInstantSuggestion(); | 225 return omnibox()->GetInstantSuggestion(); |
| 226 } | 226 } |
| OLD | NEW |