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

Side by Side Diff: chrome/browser/webdata/web_intents_table_unittest.cc

Issue 10824212: Add support for unregistering web intents default by service_url. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Do test setup verification prior to verifying remove/unregister support. Created 8 years, 4 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
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/intents/default_web_intent_service.h" 13 #include "chrome/browser/intents/default_web_intent_service.h"
14 #include "chrome/browser/webdata/web_database.h" 14 #include "chrome/browser/webdata/web_database.h"
15 #include "chrome/browser/webdata/web_intents_table.h" 15 #include "chrome/browser/webdata/web_intents_table.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/glue/web_intent_service_data.h" 19 #include "webkit/glue/web_intent_service_data.h"
20 20
21 using webkit_glue::WebIntentServiceData; 21 using webkit_glue::WebIntentServiceData;
22 22
23 namespace { 23 namespace {
24 24
25 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share"); 25 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share");
James Hawkins 2012/08/08 16:22:37 These should all be const.
Steve McKay 2012/08/08 17:54:42 Done.
26 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); 26 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view");
27 string16 test_scheme = ASCIIToUTF16("mailto"); 27 string16 test_scheme = ASCIIToUTF16("mailto");
28 string16 test_scheme_2 = ASCIIToUTF16("web+poodles"); 28 string16 test_scheme_2 = ASCIIToUTF16("web+poodles");
29 GURL test_url("http://google.com/"); 29 GURL test_url("http://google.com/");
30 GURL test_url_fake("http://fakegoogle.com/"); 30 GURL test_url_fake("http://fakegoogle.com/");
31 GURL test_service_url("http://jiggle.com/dojiggle");
32 GURL test_service_url_2("http://waddle.com/waddler");
31 string16 test_title = ASCIIToUTF16("Test WebIntent"); 33 string16 test_title = ASCIIToUTF16("Test WebIntent");
32 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2"); 34 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2");
33 string16 mime_image = ASCIIToUTF16("image/*"); 35 string16 mime_image = ASCIIToUTF16("image/*");
34 string16 mime_video = ASCIIToUTF16("video/*"); 36 string16 mime_video = ASCIIToUTF16("video/*");
35 37
36 WebIntentServiceData MakeActionService(const GURL& url, 38 WebIntentServiceData MakeActionService(const GURL& url,
37 const string16& action, 39 const string16& action,
38 const string16& type, 40 const string16& type,
39 const string16& title) { 41 const string16& title) {
40 WebIntentServiceData service; 42 WebIntentServiceData service;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 290
289 defaults.clear(); 291 defaults.clear();
290 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults)); 292 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults));
291 ASSERT_EQ(1U, defaults.size()); 293 ASSERT_EQ(1U, defaults.size());
292 294
293 defaults.clear(); 295 defaults.clear();
294 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); 296 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
295 ASSERT_EQ(1U, defaults.size()); 297 ASSERT_EQ(1U, defaults.size());
296 } 298 }
297 299
300 TEST_F(WebIntentsTableTest, RemoveDefaultServicesForServiceURL) {
301 DefaultWebIntentService s0;
302 s0.action = test_action;
303 s0.type = mime_image;
304 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
305 s0.url_pattern.Parse(test_url.spec()));
306 s0.user_date = 1;
307 s0.suppression = 4;
308 s0.service_url = test_service_url.spec();
309 ASSERT_TRUE(IntentsTable()->SetDefaultService(s0));
310
311 DefaultWebIntentService s1;
312 s1.action = test_action_2;
313 s1.type = mime_image;
314 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
315 s1.url_pattern.Parse(test_url.spec()));
316 s1.user_date = 1;
317 s1.suppression = 4;
318 s1.service_url = test_service_url.spec();
319 ASSERT_TRUE(IntentsTable()->SetDefaultService(s1));
320
321 DefaultWebIntentService s2;
322 s2.action = test_action_2;
323 s2.type = mime_image;
324 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
325 s2.url_pattern.Parse(test_url.spec()));
326 s2.user_date = 1;
327 s2.suppression = 4;
328 s2.service_url = test_service_url_2.spec();
329 ASSERT_TRUE(IntentsTable()->SetDefaultService(s2));
330
331 std::vector<DefaultWebIntentService> defaults;
332 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
333 ASSERT_EQ(3U, defaults.size());
334
335 ASSERT_TRUE(IntentsTable()->RemoveDefaultServicesForServiceURL(
336 test_service_url));
337
338 defaults.clear();
339 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
340 ASSERT_EQ(1U, defaults.size());
341 EXPECT_EQ(test_service_url_2.spec(), defaults[0].service_url);
342 }
343
298 } // namespace 344 } // namespace
OLDNEW
« chrome/browser/webdata/web_data_service.cc ('K') | « chrome/browser/webdata/web_intents_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698