Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 10 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 ACMatchClassifications styles_expected; | 72 ACMatchClassifications styles_expected; |
| 73 styles_expected.push_back(ACMatchClassification(0, kNone)); | 73 styles_expected.push_back(ACMatchClassification(0, kNone)); |
| 74 styles_expected.push_back(ACMatchClassification(1, kMatch)); | 74 styles_expected.push_back(ACMatchClassification(1, kMatch)); |
| 75 styles_expected.push_back(ACMatchClassification(5, kNone)); | 75 styles_expected.push_back(ACMatchClassification(5, kNone)); |
| 76 styles_expected.push_back(ACMatchClassification(6, kDim)); | 76 styles_expected.push_back(ACMatchClassification(6, kDim)); |
| 77 styles_expected.push_back(ACMatchClassification(9, kNone)); | 77 styles_expected.push_back(ACMatchClassification(9, kNone)); |
| 78 | 78 |
| 79 scoped_ptr<SendSuggestions::Params> params( | 79 scoped_ptr<SendSuggestions::Params> params( |
| 80 SendSuggestions::Params::Create(*list)); | 80 SendSuggestions::Params::Create(*list)); |
| 81 EXPECT_TRUE(params); | 81 EXPECT_TRUE(params); |
| 82 EXPECT_TRUE(params->suggest_results[0].get()); | |
|
lazyboy
2016/03/25 17:57:07
Here and in other places: should keep an equivalen
Devlin
2016/03/29 20:20:35
Done, though note that's not an equivalent check -
| |
| 83 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 82 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( |
| 84 *params->suggest_results[0])); | 83 params->suggest_results[0])); |
| 85 | 84 |
| 86 // Same input, but swap the order. Ensure it still works. | 85 // Same input, but swap the order. Ensure it still works. |
| 87 scoped_ptr<base::ListValue> swap_list = | 86 scoped_ptr<base::ListValue> swap_list = |
| 88 ListBuilder() | 87 ListBuilder() |
| 89 .Append(42) | 88 .Append(42) |
| 90 .Append(ListBuilder() | 89 .Append(ListBuilder() |
| 91 .Append(DictionaryBuilder() | 90 .Append(DictionaryBuilder() |
| 92 .Set("content", "content") | 91 .Set("content", "content") |
| 93 .Set("description", "description") | 92 .Set("description", "description") |
| 94 .Set("descriptionStyles", | 93 .Set("descriptionStyles", |
| 95 ListBuilder() | 94 ListBuilder() |
| 96 .Append(DictionaryBuilder() | 95 .Append(DictionaryBuilder() |
| 97 .Set("type", "dim") | 96 .Set("type", "dim") |
| 98 .Set("offset", 6) | 97 .Set("offset", 6) |
| 99 .Set("length", 3) | 98 .Set("length", 3) |
| 100 .Build()) | 99 .Build()) |
| 101 .Append(DictionaryBuilder() | 100 .Append(DictionaryBuilder() |
| 102 .Set("type", "match") | 101 .Set("type", "match") |
| 103 .Set("offset", 1) | 102 .Set("offset", 1) |
| 104 .Set("length", 4) | 103 .Set("length", 4) |
| 105 .Build()) | 104 .Build()) |
| 106 .Build()) | 105 .Build()) |
| 107 .Build()) | 106 .Build()) |
| 108 .Build()) | 107 .Build()) |
| 109 .Build(); | 108 .Build(); |
| 110 | 109 |
| 111 scoped_ptr<SendSuggestions::Params> swapped_params( | 110 scoped_ptr<SendSuggestions::Params> swapped_params( |
| 112 SendSuggestions::Params::Create(*swap_list)); | 111 SendSuggestions::Params::Create(*swap_list)); |
| 113 EXPECT_TRUE(swapped_params); | 112 EXPECT_TRUE(swapped_params); |
| 114 EXPECT_TRUE(swapped_params->suggest_results[0].get()); | 113 CompareClassification( |
| 115 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 114 styles_expected, |
| 116 *swapped_params->suggest_results[0])); | 115 StyleTypesToACMatchClassifications(swapped_params->suggest_results[0])); |
| 117 } | 116 } |
| 118 | 117 |
| 119 // 0123456789 | 118 // 0123456789 |
| 120 // uuuuu | 119 // uuuuu |
| 121 // + dd | 120 // + dd |
| 122 // + mm | 121 // + mm |
| 123 // + mmmm | 122 // + mmmm |
| 124 // + dd | 123 // + dd |
| 125 // = 3773unnnn66 | 124 // = 3773unnnn66 |
| 126 TEST(ExtensionOmniboxTest, DescriptionStylesCombine) { | 125 TEST(ExtensionOmniboxTest, DescriptionStylesCombine) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch)); | 166 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch)); |
| 168 styles_expected.push_back(ACMatchClassification(1, kUrl | kMatch | kDim)); | 167 styles_expected.push_back(ACMatchClassification(1, kUrl | kMatch | kDim)); |
| 169 styles_expected.push_back(ACMatchClassification(3, kUrl | kMatch)); | 168 styles_expected.push_back(ACMatchClassification(3, kUrl | kMatch)); |
| 170 styles_expected.push_back(ACMatchClassification(4, kUrl)); | 169 styles_expected.push_back(ACMatchClassification(4, kUrl)); |
| 171 styles_expected.push_back(ACMatchClassification(5, kNone)); | 170 styles_expected.push_back(ACMatchClassification(5, kNone)); |
| 172 styles_expected.push_back(ACMatchClassification(9, kMatch | kDim)); | 171 styles_expected.push_back(ACMatchClassification(9, kMatch | kDim)); |
| 173 | 172 |
| 174 scoped_ptr<SendSuggestions::Params> params( | 173 scoped_ptr<SendSuggestions::Params> params( |
| 175 SendSuggestions::Params::Create(*list)); | 174 SendSuggestions::Params::Create(*list)); |
| 176 EXPECT_TRUE(params); | 175 EXPECT_TRUE(params); |
| 177 EXPECT_TRUE(params->suggest_results[0].get()); | |
| 178 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 176 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( |
| 179 *params->suggest_results[0])); | 177 params->suggest_results[0])); |
| 180 | 178 |
| 181 // Try moving the "dim/match" style pair at offset 9. Output should be the | 179 // Try moving the "dim/match" style pair at offset 9. Output should be the |
| 182 // same. | 180 // same. |
| 183 scoped_ptr<base::ListValue> moved_list = | 181 scoped_ptr<base::ListValue> moved_list = |
| 184 ListBuilder() | 182 ListBuilder() |
| 185 .Append(42) | 183 .Append(42) |
| 186 .Append(ListBuilder() | 184 .Append(ListBuilder() |
| 187 .Append(DictionaryBuilder() | 185 .Append(DictionaryBuilder() |
| 188 .Set("content", "content") | 186 .Set("content", "content") |
| 189 .Set("description", "description") | 187 .Set("description", "description") |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 215 .Set("length", 2) | 213 .Set("length", 2) |
| 216 .Build()) | 214 .Build()) |
| 217 .Build()) | 215 .Build()) |
| 218 .Build()) | 216 .Build()) |
| 219 .Build()) | 217 .Build()) |
| 220 .Build(); | 218 .Build(); |
| 221 | 219 |
| 222 scoped_ptr<SendSuggestions::Params> moved_params( | 220 scoped_ptr<SendSuggestions::Params> moved_params( |
| 223 SendSuggestions::Params::Create(*moved_list)); | 221 SendSuggestions::Params::Create(*moved_list)); |
| 224 EXPECT_TRUE(moved_params); | 222 EXPECT_TRUE(moved_params); |
| 225 EXPECT_TRUE(moved_params->suggest_results[0].get()); | |
| 226 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 223 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( |
| 227 *moved_params->suggest_results[0])); | 224 moved_params->suggest_results[0])); |
| 228 } | 225 } |
| 229 | 226 |
| 230 // 0123456789 | 227 // 0123456789 |
| 231 // uuuuu | 228 // uuuuu |
| 232 // + mmmmm | 229 // + mmmmm |
| 233 // + mmm | 230 // + mmm |
| 234 // + ddd | 231 // + ddd |
| 235 // + ddd | 232 // + ddd |
| 236 // = 77777nnnnn | 233 // = 77777nnnnn |
| 237 TEST(ExtensionOmniboxTest, DescriptionStylesCombine2) { | 234 TEST(ExtensionOmniboxTest, DescriptionStylesCombine2) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 .Build()) | 271 .Build()) |
| 275 .Build(); | 272 .Build(); |
| 276 | 273 |
| 277 ACMatchClassifications styles_expected; | 274 ACMatchClassifications styles_expected; |
| 278 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch | kDim)); | 275 styles_expected.push_back(ACMatchClassification(0, kUrl | kMatch | kDim)); |
| 279 styles_expected.push_back(ACMatchClassification(5, kNone)); | 276 styles_expected.push_back(ACMatchClassification(5, kNone)); |
| 280 | 277 |
| 281 scoped_ptr<SendSuggestions::Params> params( | 278 scoped_ptr<SendSuggestions::Params> params( |
| 282 SendSuggestions::Params::Create(*list)); | 279 SendSuggestions::Params::Create(*list)); |
| 283 EXPECT_TRUE(params); | 280 EXPECT_TRUE(params); |
| 284 EXPECT_TRUE(params->suggest_results[0].get()); | |
| 285 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( | 281 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( |
| 286 *params->suggest_results[0])); | 282 params->suggest_results[0])); |
| 287 } | 283 } |
| 288 | 284 |
| 289 // 0123456789 | 285 // 0123456789 |
| 290 // uuuuu | 286 // uuuuu |
| 291 // + mmmmm | 287 // + mmmmm |
| 292 // + mmm | 288 // + mmm |
| 293 // + ddd | 289 // + ddd |
| 294 // + ddd | 290 // + ddd |
| 295 // = 77777nnnnn | 291 // = 77777nnnnn |
| 296 TEST(ExtensionOmniboxTest, DefaultSuggestResult) { | 292 TEST(ExtensionOmniboxTest, DefaultSuggestResult) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 .Build()) | 325 .Build()) |
| 330 .Build()) | 326 .Build()) |
| 331 .Build(); | 327 .Build(); |
| 332 | 328 |
| 333 scoped_ptr<SetDefaultSuggestion::Params> params( | 329 scoped_ptr<SetDefaultSuggestion::Params> params( |
| 334 SetDefaultSuggestion::Params::Create(*list)); | 330 SetDefaultSuggestion::Params::Create(*list)); |
| 335 EXPECT_TRUE(params); | 331 EXPECT_TRUE(params); |
| 336 } | 332 } |
| 337 | 333 |
| 338 } // namespace extensions | 334 } // namespace extensions |
| OLD | NEW |