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

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: Rename to use "ServiceDefaults" as the method subject. 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
« no previous file with comments | « chrome/browser/webdata/web_intents_table.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const string16 test_action =
26 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); 26 ASCIIToUTF16("http://webintents.org/intents/share");
27 string16 test_scheme = ASCIIToUTF16("mailto"); 27 const string16 test_action_2 =
28 string16 test_scheme_2 = ASCIIToUTF16("web+poodles"); 28 ASCIIToUTF16("http://webintents.org/intents/view");
29 GURL test_url("http://google.com/"); 29 const string16 test_scheme = ASCIIToUTF16("mailto");
30 GURL test_url_fake("http://fakegoogle.com/"); 30 const string16 test_scheme_2 = ASCIIToUTF16("web+poodles");
31 string16 test_title = ASCIIToUTF16("Test WebIntent"); 31 const GURL test_url("http://google.com/");
32 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2"); 32 const GURL test_url_fake("http://fakegoogle.com/");
33 string16 mime_image = ASCIIToUTF16("image/*"); 33 const GURL test_service_url("http://jiggle.com/dojiggle");
34 string16 mime_video = ASCIIToUTF16("video/*"); 34 const GURL test_service_url_2("http://waddle.com/waddler");
35 const string16 test_title = ASCIIToUTF16("Test WebIntent");
36 const string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2");
37 const string16 mime_image = ASCIIToUTF16("image/*");
38 const string16 mime_video = ASCIIToUTF16("video/*");
35 39
36 WebIntentServiceData MakeActionService(const GURL& url, 40 WebIntentServiceData MakeActionService(const GURL& url,
37 const string16& action, 41 const string16& action,
38 const string16& type, 42 const string16& type,
39 const string16& title) { 43 const string16& title) {
40 WebIntentServiceData service; 44 WebIntentServiceData service;
41 service.service_url = url; 45 service.service_url = url;
42 service.action = action; 46 service.action = action;
43 service.type = type; 47 service.type = type;
44 service.title = title; 48 service.title = title;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 292
289 defaults.clear(); 293 defaults.clear();
290 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults)); 294 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults));
291 ASSERT_EQ(1U, defaults.size()); 295 ASSERT_EQ(1U, defaults.size());
292 296
293 defaults.clear(); 297 defaults.clear();
294 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); 298 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
295 ASSERT_EQ(1U, defaults.size()); 299 ASSERT_EQ(1U, defaults.size());
296 } 300 }
297 301
302 TEST_F(WebIntentsTableTest, RemoveDefaultServicesForServiceURL) {
303 DefaultWebIntentService s0;
304 s0.action = test_action;
305 s0.type = mime_image;
306 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
307 s0.url_pattern.Parse(test_url.spec()));
308 s0.user_date = 1;
309 s0.suppression = 4;
310 s0.service_url = test_service_url.spec();
311 ASSERT_TRUE(IntentsTable()->SetDefaultService(s0));
312
313 DefaultWebIntentService s1;
314 s1.action = test_action_2;
315 s1.type = mime_image;
316 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
317 s1.url_pattern.Parse(test_url.spec()));
318 s1.user_date = 1;
319 s1.suppression = 4;
320 s1.service_url = test_service_url.spec();
321 ASSERT_TRUE(IntentsTable()->SetDefaultService(s1));
322
323 DefaultWebIntentService s2;
324 s2.action = test_action_2;
325 s2.type = mime_image;
326 ASSERT_EQ(URLPattern::PARSE_SUCCESS,
327 s2.url_pattern.Parse(test_url.spec()));
328 s2.user_date = 1;
329 s2.suppression = 4;
330 s2.service_url = test_service_url_2.spec();
331 ASSERT_TRUE(IntentsTable()->SetDefaultService(s2));
332
333 std::vector<DefaultWebIntentService> defaults;
334 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
335 ASSERT_EQ(3U, defaults.size());
336
337 ASSERT_TRUE(IntentsTable()->RemoveServiceDefaults(test_service_url));
338
339 defaults.clear();
340 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults));
341 ASSERT_EQ(1U, defaults.size());
342 EXPECT_EQ(test_service_url_2.spec(), defaults[0].service_url);
343 }
344
298 } // namespace 345 } // namespace
OLDNEW
« no previous file with comments | « 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