| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_match.h" | 8 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 9 #include "chrome/browser/autocomplete/extension_app_provider.h" | 9 #include "chrome/browser/autocomplete/extension_app_provider.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ExtensionAppProviderTest::RunTest( | 86 void ExtensionAppProviderTest::RunTest( |
| 87 test_data* keyword_cases, | 87 test_data* keyword_cases, |
| 88 int num_cases) { | 88 int num_cases) { |
| 89 ACMatches matches; | 89 ACMatches matches; |
| 90 for (int i = 0; i < num_cases; ++i) { | 90 for (int i = 0; i < num_cases; ++i) { |
| 91 AutocompleteInput input(keyword_cases[i].input, base::string16::npos, | 91 AutocompleteInput input(keyword_cases[i].input, base::string16::npos, |
| 92 base::string16(), GURL(), | 92 base::string16(), GURL(), |
| 93 AutocompleteInput::INVALID_SPEC, true, | 93 metrics::OmniboxEventProto::INVALID_SPEC, true, |
| 94 false, true, true); | 94 false, true, true); |
| 95 app_provider_->Start(input, false); | 95 app_provider_->Start(input, false); |
| 96 EXPECT_TRUE(app_provider_->done()); | 96 EXPECT_TRUE(app_provider_->done()); |
| 97 matches = app_provider_->matches(); | 97 matches = app_provider_->matches(); |
| 98 EXPECT_EQ(keyword_cases[i].num_results, matches.size()) | 98 EXPECT_EQ(keyword_cases[i].num_results, matches.size()) |
| 99 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input; | 99 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input; |
| 100 if (matches.size() == keyword_cases[i].num_results) { | 100 if (matches.size() == keyword_cases[i].num_results) { |
| 101 for (size_t j = 0; j < keyword_cases[i].num_results; ++j) | 101 for (size_t j = 0; j < keyword_cases[i].num_results; ++j) |
| 102 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url); | 102 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url); |
| 103 } | 103 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 134 const char* name; | 134 const char* name; |
| 135 const char* match_contents; | 135 const char* match_contents; |
| 136 } cases[] = { | 136 } cases[] = { |
| 137 { "Test", "Test" }, | 137 { "Test", "Test" }, |
| 138 { "Test \n Test", "Test Test" }, | 138 { "Test \n Test", "Test Test" }, |
| 139 { "Test\r\t\nTest", "TestTest" }, | 139 { "Test\r\t\nTest", "TestTest" }, |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 AutocompleteInput input(ASCIIToUTF16("Test"), base::string16::npos, | 142 AutocompleteInput input(ASCIIToUTF16("Test"), base::string16::npos, |
| 143 base::string16(), GURL(), | 143 base::string16(), GURL(), |
| 144 AutocompleteInput::INVALID_SPEC, true, true, | 144 metrics::OmniboxEventProto::INVALID_SPEC, true, true, |
| 145 true, false); | 145 true, false); |
| 146 base::string16 url(ASCIIToUTF16("http://example.com")); | 146 base::string16 url(ASCIIToUTF16("http://example.com")); |
| 147 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 147 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 148 ExtensionAppProvider::ExtensionApp extension_app = | 148 ExtensionAppProvider::ExtensionApp extension_app = |
| 149 {ASCIIToUTF16(cases[i].name), url, true}; | 149 {ASCIIToUTF16(cases[i].name), url, true}; |
| 150 AutocompleteMatch match = | 150 AutocompleteMatch match = |
| 151 app_provider_->CreateAutocompleteMatch(input, | 151 app_provider_->CreateAutocompleteMatch(input, |
| 152 extension_app, | 152 extension_app, |
| 153 0, | 153 0, |
| 154 base::string16::npos); | 154 base::string16::npos); |
| 155 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); | 155 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |