Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_unittest.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 23 matching lines...) Expand all
34 } // namespace 34 } // namespace
35 35
36 // Test output key: n = character with no styling, d = dim, m = match, u = url 36 // Test output key: n = character with no styling, d = dim, m = match, u = url
37 // u = 1, m = 2, d = 4. u+d = 5, etc. 37 // u = 1, m = 2, d = 4. u+d = 5, etc.
38 38
39 // 0123456789 39 // 0123456789
40 // mmmm 40 // mmmm
41 // + ddd 41 // + ddd
42 // = nmmmmndddn 42 // = nmmmmndddn
43 TEST(ExtensionOmniboxTest, DescriptionStylesSimple) { 43 TEST(ExtensionOmniboxTest, DescriptionStylesSimple) {
44 scoped_ptr<ListValue> list = ListBuilder() 44 scoped_ptr<base::ListValue> list = ListBuilder()
45 .Append(42) 45 .Append(42)
46 .Append(ListBuilder() 46 .Append(ListBuilder()
47 .Append(DictionaryBuilder() 47 .Append(DictionaryBuilder()
48 .Set("content", "content") 48 .Set("content", "content")
49 .Set("description", "description") 49 .Set("description", "description")
50 .Set("descriptionStyles", ListBuilder() 50 .Set("descriptionStyles", ListBuilder()
51 .Append(DictionaryBuilder() 51 .Append(DictionaryBuilder()
52 .Set("type", "match") 52 .Set("type", "match")
53 .Set("offset", 1) 53 .Set("offset", 1)
54 .Set("length", 4)) 54 .Set("length", 4))
(...skipping 10 matching lines...) Expand all
65 styles_expected.push_back(ACMatchClassification(9, kNone)); 65 styles_expected.push_back(ACMatchClassification(9, kNone));
66 66
67 scoped_ptr<SendSuggestions::Params> params( 67 scoped_ptr<SendSuggestions::Params> params(
68 SendSuggestions::Params::Create(*list)); 68 SendSuggestions::Params::Create(*list));
69 EXPECT_TRUE(params); 69 EXPECT_TRUE(params);
70 EXPECT_TRUE(params->suggest_results[0].get()); 70 EXPECT_TRUE(params->suggest_results[0].get());
71 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( 71 CompareClassification(styles_expected, StyleTypesToACMatchClassifications(
72 *params->suggest_results[0])); 72 *params->suggest_results[0]));
73 73
74 // Same input, but swap the order. Ensure it still works. 74 // Same input, but swap the order. Ensure it still works.
75 scoped_ptr<ListValue> swap_list = ListBuilder() 75 scoped_ptr<base::ListValue> swap_list = ListBuilder()
76 .Append(42) 76 .Append(42)
77 .Append(ListBuilder() 77 .Append(ListBuilder()
78 .Append(DictionaryBuilder() 78 .Append(DictionaryBuilder()
79 .Set("content", "content") 79 .Set("content", "content")
80 .Set("description", "description") 80 .Set("description", "description")
81 .Set("descriptionStyles", ListBuilder() 81 .Set("descriptionStyles", ListBuilder()
82 .Append(DictionaryBuilder() 82 .Append(DictionaryBuilder()
83 .Set("type", "dim") 83 .Set("type", "dim")
84 .Set("offset", 6) 84 .Set("offset", 6)
85 .Set("length", 3)) 85 .Set("length", 3))
(...skipping 11 matching lines...) Expand all
97 } 97 }
98 98
99 // 0123456789 99 // 0123456789
100 // uuuuu 100 // uuuuu
101 // + dd 101 // + dd
102 // + mm 102 // + mm
103 // + mmmm 103 // + mmmm
104 // + dd 104 // + dd
105 // = 3773unnnn66 105 // = 3773unnnn66
106 TEST(ExtensionOmniboxTest, DescriptionStylesCombine) { 106 TEST(ExtensionOmniboxTest, DescriptionStylesCombine) {
107 scoped_ptr<ListValue> list = ListBuilder() 107 scoped_ptr<base::ListValue> list = ListBuilder()
108 .Append(42) 108 .Append(42)
109 .Append(ListBuilder() 109 .Append(ListBuilder()
110 .Append(DictionaryBuilder() 110 .Append(DictionaryBuilder()
111 .Set("content", "content") 111 .Set("content", "content")
112 .Set("description", "description") 112 .Set("description", "description")
113 .Set("descriptionStyles", ListBuilder() 113 .Set("descriptionStyles", ListBuilder()
114 .Append(DictionaryBuilder() 114 .Append(DictionaryBuilder()
115 .Set("type", "url") 115 .Set("type", "url")
116 .Set("offset", 0) 116 .Set("offset", 0)
117 .Set("length", 5)) 117 .Set("length", 5))
(...skipping 24 matching lines...) Expand all
142 142
143 scoped_ptr<SendSuggestions::Params> params( 143 scoped_ptr<SendSuggestions::Params> params(
144 SendSuggestions::Params::Create(*list)); 144 SendSuggestions::Params::Create(*list));
145 EXPECT_TRUE(params); 145 EXPECT_TRUE(params);
146 EXPECT_TRUE(params->suggest_results[0].get()); 146 EXPECT_TRUE(params->suggest_results[0].get());
147 CompareClassification(styles_expected, StyleTypesToACMatchClassifications( 147 CompareClassification(styles_expected, StyleTypesToACMatchClassifications(
148 *params->suggest_results[0])); 148 *params->suggest_results[0]));
149 149
150 // Try moving the "dim/match" style pair at offset 9. Output should be the 150 // Try moving the "dim/match" style pair at offset 9. Output should be the
151 // same. 151 // same.
152 scoped_ptr<ListValue> moved_list = ListBuilder() 152 scoped_ptr<base::ListValue> moved_list = ListBuilder()
153 .Append(42) 153 .Append(42)
154 .Append(ListBuilder() 154 .Append(ListBuilder()
155 .Append(DictionaryBuilder() 155 .Append(DictionaryBuilder()
156 .Set("content", "content") 156 .Set("content", "content")
157 .Set("description", "description") 157 .Set("description", "description")
158 .Set("descriptionStyles", ListBuilder() 158 .Set("descriptionStyles", ListBuilder()
159 .Append(DictionaryBuilder() 159 .Append(DictionaryBuilder()
160 .Set("type", "url") 160 .Set("type", "url")
161 .Set("offset", 0) 161 .Set("offset", 0)
162 .Set("length", 5)) 162 .Set("length", 5))
(...skipping 23 matching lines...) Expand all
186 } 186 }
187 187
188 // 0123456789 188 // 0123456789
189 // uuuuu 189 // uuuuu
190 // + mmmmm 190 // + mmmmm
191 // + mmm 191 // + mmm
192 // + ddd 192 // + ddd
193 // + ddd 193 // + ddd
194 // = 77777nnnnn 194 // = 77777nnnnn
195 TEST(ExtensionOmniboxTest, DescriptionStylesCombine2) { 195 TEST(ExtensionOmniboxTest, DescriptionStylesCombine2) {
196 scoped_ptr<ListValue> list = ListBuilder() 196 scoped_ptr<base::ListValue> list = ListBuilder()
197 .Append(42) 197 .Append(42)
198 .Append(ListBuilder() 198 .Append(ListBuilder()
199 .Append(DictionaryBuilder() 199 .Append(DictionaryBuilder()
200 .Set("content", "content") 200 .Set("content", "content")
201 .Set("description", "description") 201 .Set("description", "description")
202 .Set("descriptionStyles", ListBuilder() 202 .Set("descriptionStyles", ListBuilder()
203 .Append(DictionaryBuilder() 203 .Append(DictionaryBuilder()
204 .Set("type", "url") 204 .Set("type", "url")
205 .Set("offset", 0) 205 .Set("offset", 0)
206 .Set("length", 5)) 206 .Set("length", 5))
(...skipping 28 matching lines...) Expand all
235 235
236 // 0123456789 236 // 0123456789
237 // uuuuu 237 // uuuuu
238 // + mmmmm 238 // + mmmmm
239 // + mmm 239 // + mmm
240 // + ddd 240 // + ddd
241 // + ddd 241 // + ddd
242 // = 77777nnnnn 242 // = 77777nnnnn
243 TEST(ExtensionOmniboxTest, DefaultSuggestResult) { 243 TEST(ExtensionOmniboxTest, DefaultSuggestResult) {
244 // Default suggestions should not have a content parameter. 244 // Default suggestions should not have a content parameter.
245 scoped_ptr<ListValue> list = ListBuilder() 245 scoped_ptr<base::ListValue> list = ListBuilder()
246 .Append(DictionaryBuilder() 246 .Append(DictionaryBuilder()
247 .Set("description", "description") 247 .Set("description", "description")
248 .Set("descriptionStyles", ListBuilder() 248 .Set("descriptionStyles", ListBuilder()
249 .Append(DictionaryBuilder() 249 .Append(DictionaryBuilder()
250 .Set("type", "url") 250 .Set("type", "url")
251 .Set("offset", 0) 251 .Set("offset", 0)
252 .Set("length", 5)) 252 .Set("length", 5))
253 .Append(DictionaryBuilder() 253 .Append(DictionaryBuilder()
254 .Set("type", "match") 254 .Set("type", "match")
255 .Set("offset", 0) 255 .Set("offset", 0)
(...skipping 10 matching lines...) Expand all
266 .Set("type", "dim") 266 .Set("type", "dim")
267 .Set("offset", 0) 267 .Set("offset", 0)
268 .Set("length", 3)))).Build(); 268 .Set("length", 3)))).Build();
269 269
270 scoped_ptr<SetDefaultSuggestion::Params> params( 270 scoped_ptr<SetDefaultSuggestion::Params> params(
271 SetDefaultSuggestion::Params::Create(*list)); 271 SetDefaultSuggestion::Params::Create(*list));
272 EXPECT_TRUE(params); 272 EXPECT_TRUE(params);
273 } 273 }
274 274
275 } // namespace extensions 275 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698