| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/format_macros.h" | 6 #include "base/format_macros.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_input.h" | 10 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 base::string16 AutocompleteResultAsString(const AutocompleteResult& result) { | 39 base::string16 AutocompleteResultAsString(const AutocompleteResult& result) { |
| 40 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); | 40 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); |
| 41 for (size_t i = 0; i < result.size(); ++i) { | 41 for (size_t i = 0; i < result.size(); ++i) { |
| 42 AutocompleteMatch match = result.match_at(i); | 42 AutocompleteMatch match = result.match_at(i); |
| 43 output.append(base::StringPrintf("[\"%s\" by \"%s\"] ", | 43 output.append(base::StringPrintf("[\"%s\" by \"%s\"] ", |
| 44 UTF16ToUTF8(match.contents).c_str(), | 44 base::UTF16ToUTF8(match.contents).c_str(), |
| 45 match.provider->GetName())); | 45 match.provider->GetName())); |
| 46 } | 46 } |
| 47 return UTF8ToUTF16(output); | 47 return base::UTF8ToUTF16(output); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 class AutocompleteBrowserTest : public ExtensionBrowserTest { | 52 class AutocompleteBrowserTest : public ExtensionBrowserTest { |
| 53 protected: | 53 protected: |
| 54 void WaitForTemplateURLServiceToLoad() { | 54 void WaitForTemplateURLServiceToLoad() { |
| 55 ui_test_utils::WaitForTemplateURLServiceToLoad( | 55 ui_test_utils::WaitForTemplateURLServiceToLoad( |
| 56 TemplateURLServiceFactory::GetForProfile(browser()->profile())); | 56 TemplateURLServiceFactory::GetForProfile(browser()->profile())); |
| 57 } | 57 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 71 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 72 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 72 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 73 return; | 73 return; |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 WaitForTemplateURLServiceToLoad(); | 76 WaitForTemplateURLServiceToLoad(); |
| 77 LocationBar* location_bar = GetLocationBar(); | 77 LocationBar* location_bar = GetLocationBar(); |
| 78 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 78 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
| 79 | 79 |
| 80 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 80 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 81 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 81 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 82 omnibox_view->GetText()); |
| 82 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across | 83 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across |
| 83 // platforms. | 84 // platforms. |
| 84 | 85 |
| 85 location_bar->FocusLocation(true); | 86 location_bar->FocusLocation(true); |
| 86 | 87 |
| 87 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 88 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 88 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 89 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 90 omnibox_view->GetText()); |
| 89 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 91 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 90 | 92 |
| 91 omnibox_view->SetUserText(ASCIIToUTF16("chrome")); | 93 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); |
| 92 | 94 |
| 93 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 95 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 94 EXPECT_EQ(ASCIIToUTF16("chrome"), omnibox_view->GetText()); | 96 EXPECT_EQ(base::ASCIIToUTF16("chrome"), omnibox_view->GetText()); |
| 95 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 97 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 96 | 98 |
| 97 omnibox_view->RevertAll(); | 99 omnibox_view->RevertAll(); |
| 98 | 100 |
| 99 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 101 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 100 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 102 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 103 omnibox_view->GetText()); |
| 101 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 104 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 102 | 105 |
| 103 omnibox_view->SetUserText(ASCIIToUTF16("chrome")); | 106 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); |
| 104 location_bar->Revert(); | 107 location_bar->Revert(); |
| 105 | 108 |
| 106 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 109 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 107 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 110 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 111 omnibox_view->GetText()); |
| 108 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 112 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 109 } | 113 } |
| 110 | 114 |
| 111 // Autocomplete test is flaky on ChromeOS. | 115 // Autocomplete test is flaky on ChromeOS. |
| 112 // http://crbug.com/52928 | 116 // http://crbug.com/52928 |
| 113 #if defined(OS_CHROMEOS) | 117 #if defined(OS_CHROMEOS) |
| 114 #define MAYBE_Autocomplete DISABLED_Autocomplete | 118 #define MAYBE_Autocomplete DISABLED_Autocomplete |
| 115 #else | 119 #else |
| 116 #define MAYBE_Autocomplete Autocomplete | 120 #define MAYBE_Autocomplete Autocomplete |
| 117 #endif | 121 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 130 HistoryServiceFactory::GetForProfile(browser()->profile(), | 134 HistoryServiceFactory::GetForProfile(browser()->profile(), |
| 131 Profile::EXPLICIT_ACCESS)); | 135 Profile::EXPLICIT_ACCESS)); |
| 132 | 136 |
| 133 LocationBar* location_bar = GetLocationBar(); | 137 LocationBar* location_bar = GetLocationBar(); |
| 134 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 138 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
| 135 AutocompleteController* autocomplete_controller = GetAutocompleteController(); | 139 AutocompleteController* autocomplete_controller = GetAutocompleteController(); |
| 136 | 140 |
| 137 { | 141 { |
| 138 omnibox_view->model()->SetInputInProgress(true); | 142 omnibox_view->model()->SetInputInProgress(true); |
| 139 autocomplete_controller->Start(AutocompleteInput( | 143 autocomplete_controller->Start(AutocompleteInput( |
| 140 ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), GURL(), | 144 base::ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), |
| 141 AutocompleteInput::NTP, true, false, true, | 145 GURL(), AutocompleteInput::NTP, true, false, true, |
| 142 AutocompleteInput::SYNCHRONOUS_MATCHES)); | 146 AutocompleteInput::SYNCHRONOUS_MATCHES)); |
| 143 | 147 |
| 144 EXPECT_TRUE(autocomplete_controller->done()); | 148 EXPECT_TRUE(autocomplete_controller->done()); |
| 145 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 149 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 146 EXPECT_TRUE(omnibox_view->GetText().empty()); | 150 EXPECT_TRUE(omnibox_view->GetText().empty()); |
| 147 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 151 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 148 const AutocompleteResult& result = autocomplete_controller->result(); | 152 const AutocompleteResult& result = autocomplete_controller->result(); |
| 149 // We get two matches because we have a provider for extension apps and the | 153 // We get two matches because we have a provider for extension apps and the |
| 150 // Chrome Web Store is a built-in Extension app. For this test, we only care | 154 // Chrome Web Store is a built-in Extension app. For this test, we only care |
| 151 // about the other match existing. | 155 // about the other match existing. |
| 152 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); | 156 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); |
| 153 AutocompleteMatch match = result.match_at(0); | 157 AutocompleteMatch match = result.match_at(0); |
| 154 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type); | 158 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type); |
| 155 EXPECT_FALSE(match.deletable); | 159 EXPECT_FALSE(match.deletable); |
| 156 } | 160 } |
| 157 | 161 |
| 158 { | 162 { |
| 159 location_bar->Revert(); | 163 location_bar->Revert(); |
| 160 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 164 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 161 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 165 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 166 omnibox_view->GetText()); |
| 162 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 167 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 163 const AutocompleteResult& result = autocomplete_controller->result(); | 168 const AutocompleteResult& result = autocomplete_controller->result(); |
| 164 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); | 169 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); |
| 165 } | 170 } |
| 166 } | 171 } |
| 167 | 172 |
| 168 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { | 173 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { |
| 169 #if defined(OS_WIN) && defined(USE_ASH) | 174 #if defined(OS_WIN) && defined(USE_ASH) |
| 170 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 175 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 171 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 176 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 172 return; | 177 return; |
| 173 #endif | 178 #endif |
| 174 | 179 |
| 175 WaitForTemplateURLServiceToLoad(); | 180 WaitForTemplateURLServiceToLoad(); |
| 176 // http://code.google.com/p/chromium/issues/detail?id=38385 | 181 // http://code.google.com/p/chromium/issues/detail?id=38385 |
| 177 // Make sure that tabbing away from an empty omnibox causes a revert | 182 // Make sure that tabbing away from an empty omnibox causes a revert |
| 178 // and select all. | 183 // and select all. |
| 179 LocationBar* location_bar = GetLocationBar(); | 184 LocationBar* location_bar = GetLocationBar(); |
| 180 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 185 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
| 181 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 186 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 187 omnibox_view->GetText()); |
| 182 omnibox_view->SetUserText(base::string16()); | 188 omnibox_view->SetUserText(base::string16()); |
| 183 content::WindowedNotificationObserver observer( | 189 content::WindowedNotificationObserver observer( |
| 184 content::NOTIFICATION_LOAD_STOP, | 190 content::NOTIFICATION_LOAD_STOP, |
| 185 content::NotificationService::AllSources()); | 191 content::NotificationService::AllSources()); |
| 186 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), | 192 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), |
| 187 content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 193 content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 188 observer.Wait(); | 194 observer.Wait(); |
| 189 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 195 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 196 omnibox_view->GetText()); |
| 190 chrome::CloseTab(browser()); | 197 chrome::CloseTab(browser()); |
| 191 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 198 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 199 omnibox_view->GetText()); |
| 192 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 200 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 193 } | 201 } |
| 194 | 202 |
| 195 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { | 203 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { |
| 196 #if defined(OS_WIN) && defined(USE_ASH) | 204 #if defined(OS_WIN) && defined(USE_ASH) |
| 197 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 205 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 198 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 206 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 199 return; | 207 return; |
| 200 #endif | 208 #endif |
| 201 | 209 |
| 202 WaitForTemplateURLServiceToLoad(); | 210 WaitForTemplateURLServiceToLoad(); |
| 203 LocationBar* location_bar = GetLocationBar(); | 211 LocationBar* location_bar = GetLocationBar(); |
| 204 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 212 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
| 205 | 213 |
| 206 // Focus search when omnibox is blank | 214 // Focus search when omnibox is blank |
| 207 { | 215 { |
| 208 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 216 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 209 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); | 217 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), |
| 218 omnibox_view->GetText()); |
| 210 | 219 |
| 211 location_bar->FocusSearch(); | 220 location_bar->FocusSearch(); |
| 212 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 221 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 213 EXPECT_EQ(ASCIIToUTF16("?"), omnibox_view->GetText()); | 222 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); |
| 214 | 223 |
| 215 size_t selection_start, selection_end; | 224 size_t selection_start, selection_end; |
| 216 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 225 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
| 217 EXPECT_EQ(1U, selection_start); | 226 EXPECT_EQ(1U, selection_start); |
| 218 EXPECT_EQ(1U, selection_end); | 227 EXPECT_EQ(1U, selection_end); |
| 219 } | 228 } |
| 220 | 229 |
| 221 // Focus search when omnibox is _not_ alread in forced query mode. | 230 // Focus search when omnibox is _not_ alread in forced query mode. |
| 222 { | 231 { |
| 223 omnibox_view->SetUserText(ASCIIToUTF16("foo")); | 232 omnibox_view->SetUserText(base::ASCIIToUTF16("foo")); |
| 224 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 233 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 225 EXPECT_EQ(ASCIIToUTF16("foo"), omnibox_view->GetText()); | 234 EXPECT_EQ(base::ASCIIToUTF16("foo"), omnibox_view->GetText()); |
| 226 | 235 |
| 227 location_bar->FocusSearch(); | 236 location_bar->FocusSearch(); |
| 228 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 237 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 229 EXPECT_EQ(ASCIIToUTF16("?"), omnibox_view->GetText()); | 238 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); |
| 230 | 239 |
| 231 size_t selection_start, selection_end; | 240 size_t selection_start, selection_end; |
| 232 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 241 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
| 233 EXPECT_EQ(1U, selection_start); | 242 EXPECT_EQ(1U, selection_start); |
| 234 EXPECT_EQ(1U, selection_end); | 243 EXPECT_EQ(1U, selection_end); |
| 235 } | 244 } |
| 236 | 245 |
| 237 // Focus search when omnibox _is_ already in forced query mode, but no query | 246 // Focus search when omnibox _is_ already in forced query mode, but no query |
| 238 // has been typed. | 247 // has been typed. |
| 239 { | 248 { |
| 240 omnibox_view->SetUserText(ASCIIToUTF16("?")); | 249 omnibox_view->SetUserText(base::ASCIIToUTF16("?")); |
| 241 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 250 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 242 EXPECT_EQ(ASCIIToUTF16("?"), omnibox_view->GetText()); | 251 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); |
| 243 | 252 |
| 244 location_bar->FocusSearch(); | 253 location_bar->FocusSearch(); |
| 245 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 254 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 246 EXPECT_EQ(ASCIIToUTF16("?"), omnibox_view->GetText()); | 255 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); |
| 247 | 256 |
| 248 size_t selection_start, selection_end; | 257 size_t selection_start, selection_end; |
| 249 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 258 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
| 250 EXPECT_EQ(1U, selection_start); | 259 EXPECT_EQ(1U, selection_start); |
| 251 EXPECT_EQ(1U, selection_end); | 260 EXPECT_EQ(1U, selection_end); |
| 252 } | 261 } |
| 253 | 262 |
| 254 // Focus search when omnibox _is_ already in forced query mode, and some query | 263 // Focus search when omnibox _is_ already in forced query mode, and some query |
| 255 // has been typed. | 264 // has been typed. |
| 256 { | 265 { |
| 257 omnibox_view->SetUserText(ASCIIToUTF16("?foo")); | 266 omnibox_view->SetUserText(base::ASCIIToUTF16("?foo")); |
| 258 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 267 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 259 EXPECT_EQ(ASCIIToUTF16("?foo"), omnibox_view->GetText()); | 268 EXPECT_EQ(base::ASCIIToUTF16("?foo"), omnibox_view->GetText()); |
| 260 | 269 |
| 261 location_bar->FocusSearch(); | 270 location_bar->FocusSearch(); |
| 262 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 271 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 263 EXPECT_EQ(ASCIIToUTF16("?foo"), omnibox_view->GetText()); | 272 EXPECT_EQ(base::ASCIIToUTF16("?foo"), omnibox_view->GetText()); |
| 264 | 273 |
| 265 size_t selection_start, selection_end; | 274 size_t selection_start, selection_end; |
| 266 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 275 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
| 267 EXPECT_EQ(1U, std::min(selection_start, selection_end)); | 276 EXPECT_EQ(1U, std::min(selection_start, selection_end)); |
| 268 EXPECT_EQ(4U, std::max(selection_start, selection_end)); | 277 EXPECT_EQ(4U, std::max(selection_start, selection_end)); |
| 269 } | 278 } |
| 270 | 279 |
| 271 // Focus search when omnibox is in forced query mode with leading whitespace. | 280 // Focus search when omnibox is in forced query mode with leading whitespace. |
| 272 { | 281 { |
| 273 omnibox_view->SetUserText(ASCIIToUTF16(" ?foo")); | 282 omnibox_view->SetUserText(base::ASCIIToUTF16(" ?foo")); |
| 274 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 283 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 275 EXPECT_EQ(ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); | 284 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); |
| 276 | 285 |
| 277 location_bar->FocusSearch(); | 286 location_bar->FocusSearch(); |
| 278 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 287 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
| 279 EXPECT_EQ(ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); | 288 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); |
| 280 | 289 |
| 281 size_t selection_start, selection_end; | 290 size_t selection_start, selection_end; |
| 282 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 291 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
| 283 EXPECT_EQ(4U, std::min(selection_start, selection_end)); | 292 EXPECT_EQ(4U, std::min(selection_start, selection_end)); |
| 284 EXPECT_EQ(7U, std::max(selection_start, selection_end)); | 293 EXPECT_EQ(7U, std::max(selection_start, selection_end)); |
| 285 } | 294 } |
| 286 } | 295 } |
| OLD | NEW |