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 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/omnibox/location_bar.h" | 24 #include "chrome/browser/ui/omnibox/location_bar.h" |
25 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 25 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
26 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 26 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
30 #include "chrome/test/base/in_process_browser_test.h" | 30 #include "chrome/test/base/in_process_browser_test.h" |
31 #include "chrome/test/base/test_switches.h" | 31 #include "chrome/test/base/test_switches.h" |
32 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
| 33 #include "components/metrics/proto/omnibox_event.pb.h" |
33 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 base::string16 AutocompleteResultAsString(const AutocompleteResult& result) { | 40 base::string16 AutocompleteResultAsString(const AutocompleteResult& result) { |
40 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); | 41 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); |
41 for (size_t i = 0; i < result.size(); ++i) { | 42 for (size_t i = 0; i < result.size(); ++i) { |
42 AutocompleteMatch match = result.match_at(i); | 43 AutocompleteMatch match = result.match_at(i); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Profile::EXPLICIT_ACCESS)); | 132 Profile::EXPLICIT_ACCESS)); |
132 | 133 |
133 LocationBar* location_bar = GetLocationBar(); | 134 LocationBar* location_bar = GetLocationBar(); |
134 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 135 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
135 AutocompleteController* autocomplete_controller = GetAutocompleteController(); | 136 AutocompleteController* autocomplete_controller = GetAutocompleteController(); |
136 | 137 |
137 { | 138 { |
138 omnibox_view->model()->SetInputInProgress(true); | 139 omnibox_view->model()->SetInputInProgress(true); |
139 autocomplete_controller->Start(AutocompleteInput( | 140 autocomplete_controller->Start(AutocompleteInput( |
140 base::ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), | 141 base::ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), |
141 GURL(), AutocompleteInput::NTP, true, false, true, false)); | 142 GURL(), metrics::OmniboxEventProto::NTP, true, false, true, false)); |
142 | 143 |
143 EXPECT_TRUE(autocomplete_controller->done()); | 144 EXPECT_TRUE(autocomplete_controller->done()); |
144 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 145 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
145 EXPECT_TRUE(omnibox_view->GetText().empty()); | 146 EXPECT_TRUE(omnibox_view->GetText().empty()); |
146 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 147 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
147 const AutocompleteResult& result = autocomplete_controller->result(); | 148 const AutocompleteResult& result = autocomplete_controller->result(); |
148 // We get two matches because we have a provider for extension apps and the | 149 // We get two matches because we have a provider for extension apps and the |
149 // Chrome Web Store is a built-in Extension app. For this test, we only care | 150 // Chrome Web Store is a built-in Extension app. For this test, we only care |
150 // about the other match existing. | 151 // about the other match existing. |
151 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); | 152 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 location_bar->FocusSearch(); | 278 location_bar->FocusSearch(); |
278 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 279 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
279 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); | 280 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); |
280 | 281 |
281 size_t selection_start, selection_end; | 282 size_t selection_start, selection_end; |
282 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 283 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
283 EXPECT_EQ(4U, std::min(selection_start, selection_end)); | 284 EXPECT_EQ(4U, std::min(selection_start, selection_end)); |
284 EXPECT_EQ(7U, std::max(selection_start, selection_end)); | 285 EXPECT_EQ(7U, std::max(selection_start, selection_end)); |
285 } | 286 } |
286 } | 287 } |
OLD | NEW |