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.h" | 6 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 url_db->AddURL(info); | 80 url_db->AddURL(info); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 void ExtensionAppProviderTest::RunTest( | 84 void ExtensionAppProviderTest::RunTest( |
85 test_data* keyword_cases, | 85 test_data* keyword_cases, |
86 int num_cases) { | 86 int num_cases) { |
87 ACMatches matches; | 87 ACMatches matches; |
88 for (int i = 0; i < num_cases; ++i) { | 88 for (int i = 0; i < num_cases; ++i) { |
89 AutocompleteInput input(keyword_cases[i].input, string16::npos, string16(), | 89 AutocompleteInput input(keyword_cases[i].input, string16::npos, string16(), |
90 true, false, true, AutocompleteInput::ALL_MATCHES); | 90 GURL(), true, false, true, |
| 91 AutocompleteInput::ALL_MATCHES); |
91 app_provider_->Start(input, false); | 92 app_provider_->Start(input, false); |
92 EXPECT_TRUE(app_provider_->done()); | 93 EXPECT_TRUE(app_provider_->done()); |
93 matches = app_provider_->matches(); | 94 matches = app_provider_->matches(); |
94 EXPECT_EQ(keyword_cases[i].num_results, matches.size()) | 95 EXPECT_EQ(keyword_cases[i].num_results, matches.size()) |
95 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input; | 96 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input; |
96 if (matches.size() == keyword_cases[i].num_results) { | 97 if (matches.size() == keyword_cases[i].num_results) { |
97 for (size_t j = 0; j < keyword_cases[i].num_results; ++j) | 98 for (size_t j = 0; j < keyword_cases[i].num_results; ++j) |
98 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url); | 99 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url); |
99 } | 100 } |
100 } | 101 } |
(...skipping 28 matching lines...) Expand all Loading... |
129 struct TestData { | 130 struct TestData { |
130 const char* name; | 131 const char* name; |
131 const char* match_contents; | 132 const char* match_contents; |
132 } cases[] = { | 133 } cases[] = { |
133 { "Test", "Test" }, | 134 { "Test", "Test" }, |
134 { "Test \n Test", "Test Test" }, | 135 { "Test \n Test", "Test Test" }, |
135 { "Test\r\t\nTest", "TestTest" }, | 136 { "Test\r\t\nTest", "TestTest" }, |
136 }; | 137 }; |
137 | 138 |
138 AutocompleteInput input(ASCIIToUTF16("Test"), string16::npos, string16(), | 139 AutocompleteInput input(ASCIIToUTF16("Test"), string16::npos, string16(), |
139 true, true, true, AutocompleteInput::BEST_MATCH); | 140 GURL(), true, true, true, |
| 141 AutocompleteInput::BEST_MATCH); |
140 string16 url(ASCIIToUTF16("http://example.com")); | 142 string16 url(ASCIIToUTF16("http://example.com")); |
141 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 143 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
142 ExtensionAppProvider::ExtensionApp extension_app = | 144 ExtensionAppProvider::ExtensionApp extension_app = |
143 {ASCIIToUTF16(cases[i].name), url, true}; | 145 {ASCIIToUTF16(cases[i].name), url, true}; |
144 AutocompleteMatch match = | 146 AutocompleteMatch match = |
145 app_provider_->CreateAutocompleteMatch(input, | 147 app_provider_->CreateAutocompleteMatch(input, |
146 extension_app, | 148 extension_app, |
147 0, | 149 0, |
148 string16::npos); | 150 string16::npos); |
149 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); | 151 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); |
150 } | 152 } |
151 } | 153 } |
OLD | NEW |