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

Side by Side Diff: chrome/browser/intents/web_intents_registry_unittest.cc

Issue 8417043: Add webkit_glue namespace. Improve some variable and test names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_value_serializer.h" 6 #include "base/json/json_value_serializer.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/intents/web_intents_registry.h" 10 #include "chrome/browser/intents/web_intents_registry.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 WebIntentsRegistry registry_; 139 WebIntentsRegistry registry_;
140 ScopedTempDir temp_dir_; 140 ScopedTempDir temp_dir_;
141 }; 141 };
142 142
143 // Simple consumer for WebIntentsRegistry notifications. Stores result data and 143 // Simple consumer for WebIntentsRegistry notifications. Stores result data and
144 // terminates UI thread when callback is invoked. 144 // terminates UI thread when callback is invoked.
145 class TestConsumer: public WebIntentsRegistry::Consumer { 145 class TestConsumer: public WebIntentsRegistry::Consumer {
146 public: 146 public:
147 virtual void OnIntentsQueryDone( 147 virtual void OnIntentsQueryDone(
148 WebIntentsRegistry::QueryID id, 148 WebIntentsRegistry::QueryID id,
149 const std::vector<WebIntentServiceData>& services) { 149 const std::vector<webkit_glue::WebIntentServiceData>& services) {
150 DCHECK(id == expected_id_); 150 DCHECK(id == expected_id_);
151 services_ = services; 151 services_ = services;
152 152
153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
154 MessageLoop::current()->Quit(); 154 MessageLoop::current()->Quit();
155 } 155 }
156 156
157 // Wait for the UI message loop to terminate - happens when OnIntesQueryDone 157 // Wait for the UI message loop to terminate - happens when OnIntesQueryDone
158 // is invoked. 158 // is invoked.
159 void WaitForData() { 159 void WaitForData() {
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
161 MessageLoop::current()->Run(); 161 MessageLoop::current()->Run();
162 } 162 }
163 163
164 WebIntentsRegistry::QueryID expected_id_; // QueryID callback is tied to. 164 // QueryID callback is tied to.
165 std::vector<WebIntentServiceData> services_; // Result data from callback. 165 WebIntentsRegistry::QueryID expected_id_;
166
167 // Result data from callback.
168 std::vector<webkit_glue::WebIntentServiceData> services_;
166 }; 169 };
167 170
168 TEST_F(WebIntentsRegistryTest, BasicTests) { 171 TEST_F(WebIntentsRegistryTest, BasicTests) {
169 WebIntentServiceData service; 172 webkit_glue::WebIntentServiceData service;
170 service.service_url = GURL("http://google.com"); 173 service.service_url = GURL("http://google.com");
171 service.action = ASCIIToUTF16("share"); 174 service.action = ASCIIToUTF16("share");
172 service.type = ASCIIToUTF16("image/*"); 175 service.type = ASCIIToUTF16("image/*");
173 service.title = ASCIIToUTF16("Google's Sharing Service"); 176 service.title = ASCIIToUTF16("Google's Sharing Service");
174 177
175 registry_.RegisterIntentProvider(service); 178 registry_.RegisterIntentProvider(service);
176 179
177 service.type = ASCIIToUTF16("video/*"); 180 service.type = ASCIIToUTF16("video/*");
178 registry_.RegisterIntentProvider(service); 181 registry_.RegisterIntentProvider(service);
179 182
(...skipping 15 matching lines...) Expand all
195 service.type = ASCIIToUTF16("image/*"); 198 service.type = ASCIIToUTF16("image/*");
196 registry_.UnregisterIntentProvider(service); 199 registry_.UnregisterIntentProvider(service);
197 200
198 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"), 201 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"),
199 &consumer); 202 &consumer);
200 consumer.WaitForData(); 203 consumer.WaitForData();
201 EXPECT_EQ(1U, consumer.services_.size()); 204 EXPECT_EQ(1U, consumer.services_.size());
202 } 205 }
203 206
204 TEST_F(WebIntentsRegistryTest, GetAllIntents) { 207 TEST_F(WebIntentsRegistryTest, GetAllIntents) {
205 WebIntentServiceData service; 208 webkit_glue::WebIntentServiceData service;
206 service.service_url = GURL("http://google.com"); 209 service.service_url = GURL("http://google.com");
207 service.action = ASCIIToUTF16("share"); 210 service.action = ASCIIToUTF16("share");
208 service.type = ASCIIToUTF16("image/*"); 211 service.type = ASCIIToUTF16("image/*");
209 service.title = ASCIIToUTF16("Google's Sharing Service"); 212 service.title = ASCIIToUTF16("Google's Sharing Service");
210 registry_.RegisterIntentProvider(service); 213 registry_.RegisterIntentProvider(service);
211 214
212 service.action = ASCIIToUTF16("search"); 215 service.action = ASCIIToUTF16("search");
213 registry_.RegisterIntentProvider(service); 216 registry_.RegisterIntentProvider(service);
214 217
215 TestConsumer consumer; 218 TestConsumer consumer;
(...skipping 29 matching lines...) Expand all
245 consumer.expected_id_ = registry_.GetIntentProviders( 248 consumer.expected_id_ = registry_.GetIntentProviders(
246 ASCIIToUTF16("http://webintents.org/edit"),&consumer); 249 ASCIIToUTF16("http://webintents.org/edit"),&consumer);
247 consumer.WaitForData(); 250 consumer.WaitForData();
248 ASSERT_EQ(1U, consumer.services_.size()); 251 ASSERT_EQ(1U, consumer.services_.size());
249 } 252 }
250 253
251 TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) { 254 TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) {
252 extensions_.push_back(LoadAndExpectSuccess("intent_valid.json")); 255 extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
253 extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json")); 256 extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
254 257
255 WebIntentServiceData service; 258 webkit_glue::WebIntentServiceData service;
256 service.service_url = GURL("http://somewhere.com/intent/edit.html"); 259 service.service_url = GURL("http://somewhere.com/intent/edit.html");
257 service.action = ASCIIToUTF16("http://webintents.org/edit"); 260 service.action = ASCIIToUTF16("http://webintents.org/edit");
258 service.type = ASCIIToUTF16("image/*"); 261 service.type = ASCIIToUTF16("image/*");
259 service.title = ASCIIToUTF16("Image Editing Service"); 262 service.title = ASCIIToUTF16("Image Editing Service");
260 registry_.RegisterIntentProvider(service); 263 registry_.RegisterIntentProvider(service);
261 264
262 TestConsumer consumer; 265 TestConsumer consumer;
263 consumer.expected_id_ = registry_.GetIntentProviders( 266 consumer.expected_id_ = registry_.GetIntentProviders(
264 ASCIIToUTF16("http://webintents.org/edit"),&consumer); 267 ASCIIToUTF16("http://webintents.org/edit"),&consumer);
265 consumer.WaitForData(); 268 consumer.WaitForData();
266 ASSERT_EQ(2U, consumer.services_.size()); 269 ASSERT_EQ(2U, consumer.services_.size());
267 270
268 consumer.expected_id_ = registry_.GetIntentProviders( 271 consumer.expected_id_ = registry_.GetIntentProviders(
269 ASCIIToUTF16("http://webintents.org/share"),&consumer); 272 ASCIIToUTF16("http://webintents.org/share"),&consumer);
270 consumer.WaitForData(); 273 consumer.WaitForData();
271 ASSERT_EQ(1U, consumer.services_.size()); 274 ASSERT_EQ(1U, consumer.services_.size());
272 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698