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/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 6 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
7 #include "chrome/common/extensions/api/omnibox.h" | 7 #include "chrome/common/extensions/api/omnibox.h" |
8 #include "chrome/common/extensions/value_builder.h" | 8 #include "chrome/common/extensions/value_builder.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 namespace omnibox = api::omnibox; | 14 namespace omnibox = api::omnibox; |
15 namespace SendSuggestions = omnibox::SendSuggestions; | 15 namespace SendSuggestions = omnibox::SendSuggestions; |
| 16 namespace SetDefaultSuggestion = omnibox::SetDefaultSuggestion; |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const int kNone = ACMatchClassification::NONE; | 20 const int kNone = ACMatchClassification::NONE; |
20 const int kUrl = ACMatchClassification::URL; | 21 const int kUrl = ACMatchClassification::URL; |
21 const int kMatch = ACMatchClassification::MATCH; | 22 const int kMatch = ACMatchClassification::MATCH; |
22 const int kDim = ACMatchClassification::DIM; | 23 const int kDim = ACMatchClassification::DIM; |
23 | 24 |
24 void CompareClassification(const ACMatchClassifications& expected, | 25 void CompareClassification(const ACMatchClassifications& expected, |
25 const ACMatchClassifications& actual) { | 26 const ACMatchClassifications& actual) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 styles_expected.push_back(ACMatchClassification(5, kNone)); | 226 styles_expected.push_back(ACMatchClassification(5, kNone)); |
226 | 227 |
227 scoped_ptr<SendSuggestions::Params> params( | 228 scoped_ptr<SendSuggestions::Params> params( |
228 SendSuggestions::Params::Create(*list)); | 229 SendSuggestions::Params::Create(*list)); |
229 EXPECT_TRUE(params); | 230 EXPECT_TRUE(params); |
230 EXPECT_TRUE(params->suggest_results[0].get()); | 231 EXPECT_TRUE(params->suggest_results[0].get()); |
231 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 232 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( |
232 *params->suggest_results[0])); | 233 *params->suggest_results[0])); |
233 } | 234 } |
234 | 235 |
| 236 // 0123456789 |
| 237 // uuuuu |
| 238 // + mmmmm |
| 239 // + mmm |
| 240 // + ddd |
| 241 // + ddd |
| 242 // = 77777nnnnn |
| 243 TEST(ExtensionOmniboxTest, DefaultSuggestResult) { |
| 244 // Default suggestions should not have a content parameter. |
| 245 scoped_ptr<ListValue> list = ListBuilder() |
| 246 .Append(DictionaryBuilder() |
| 247 .Set("description", "description") |
| 248 .Set("descriptionStyles", ListBuilder() |
| 249 .Append(DictionaryBuilder() |
| 250 .Set("type", "url") |
| 251 .Set("offset", 0) |
| 252 .Set("length", 5)) |
| 253 .Append(DictionaryBuilder() |
| 254 .Set("type", "match") |
| 255 .Set("offset", 0) |
| 256 .Set("length", 5)) |
| 257 .Append(DictionaryBuilder() |
| 258 .Set("type", "match") |
| 259 .Set("offset", 0) |
| 260 .Set("length", 3)) |
| 261 .Append(DictionaryBuilder() |
| 262 .Set("type", "dim") |
| 263 .Set("offset", 2) |
| 264 .Set("length", 3)) |
| 265 .Append(DictionaryBuilder() |
| 266 .Set("type", "dim") |
| 267 .Set("offset", 0) |
| 268 .Set("length", 3)))).Build(); |
| 269 |
| 270 scoped_ptr<SetDefaultSuggestion::Params> params( |
| 271 SetDefaultSuggestion::Params::Create(*list)); |
| 272 EXPECT_TRUE(params); |
| 273 } |
| 274 |
235 } // namespace extensions | 275 } // namespace extensions |
OLD | NEW |