| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/autocomplete_input.h" | 5 #include "components/omnibox/autocomplete_input.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "components/metrics/proto/omnibox_event.pb.h" | 11 #include "components/metrics/proto/omnibox_event.pb.h" |
| 12 #include "components/metrics/proto/omnibox_input_type.pb.h" | 12 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 13 #include "components/omnibox/test_scheme_classifier.h" | 13 #include "components/omnibox/test_scheme_classifier.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "url/url_parse.h" | 15 #include "url/url_parse.h" |
| 16 #include "url/url_util.h" | |
| 17 | 16 |
| 18 using base::ASCIIToUTF16; | 17 using base::ASCIIToUTF16; |
| 19 using metrics::OmniboxEventProto; | 18 using metrics::OmniboxEventProto; |
| 20 | 19 |
| 21 TEST(AutocompleteInputTest, InputType) { | 20 TEST(AutocompleteInputTest, InputType) { |
| 22 // TODO(mukai): Fix this scheme setup. | |
| 23 url::AddStandardScheme("chrome"); | |
| 24 url::AddStandardScheme("chrome-devtools"); | |
| 25 url::AddStandardScheme("chrome-search"); | |
| 26 | |
| 27 struct test_data { | 21 struct test_data { |
| 28 const base::string16 input; | 22 const base::string16 input; |
| 29 const metrics::OmniboxInputType::Type type; | 23 const metrics::OmniboxInputType::Type type; |
| 30 } input_cases[] = { | 24 } input_cases[] = { |
| 31 { base::string16(), metrics::OmniboxInputType::INVALID }, | 25 { base::string16(), metrics::OmniboxInputType::INVALID }, |
| 32 { ASCIIToUTF16("?"), metrics::OmniboxInputType::FORCED_QUERY }, | 26 { ASCIIToUTF16("?"), metrics::OmniboxInputType::FORCED_QUERY }, |
| 33 { ASCIIToUTF16("?foo"), metrics::OmniboxInputType::FORCED_QUERY }, | 27 { ASCIIToUTF16("?foo"), metrics::OmniboxInputType::FORCED_QUERY }, |
| 34 { ASCIIToUTF16("?foo bar"), metrics::OmniboxInputType::FORCED_QUERY }, | 28 { ASCIIToUTF16("?foo bar"), metrics::OmniboxInputType::FORCED_QUERY }, |
| 35 { ASCIIToUTF16("?http://foo.com/bar"), | 29 { ASCIIToUTF16("?http://foo.com/bar"), |
| 36 metrics::OmniboxInputType::FORCED_QUERY }, | 30 metrics::OmniboxInputType::FORCED_QUERY }, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 AutocompleteInput input(input_cases[i].input, | 271 AutocompleteInput input(input_cases[i].input, |
| 278 input_cases[i].cursor_position, | 272 input_cases[i].cursor_position, |
| 279 base::string16(), GURL(), | 273 base::string16(), GURL(), |
| 280 OmniboxEventProto::INVALID_SPEC, | 274 OmniboxEventProto::INVALID_SPEC, |
| 281 true, false, true, true, TestSchemeClassifier()); | 275 true, false, true, true, TestSchemeClassifier()); |
| 282 EXPECT_EQ(input_cases[i].normalized_input, input.text()); | 276 EXPECT_EQ(input_cases[i].normalized_input, input.text()); |
| 283 EXPECT_EQ(input_cases[i].normalized_cursor_position, | 277 EXPECT_EQ(input_cases[i].normalized_cursor_position, |
| 284 input.cursor_position()); | 278 input.cursor_position()); |
| 285 } | 279 } |
| 286 } | 280 } |
| OLD | NEW |