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

Side by Side Diff: chrome/browser/extensions/api/browsing_data/browsing_data_test.cc

Issue 2171383002: Deprecate the CallbackSubscription in BrowsingDataRemover (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize masks to -1 Created 4 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/browsing_data/browsing_data_remover_unittest.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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/pattern.h" 10 #include "base/strings/pattern.h"
(...skipping 28 matching lines...) Expand all
39 "\"appcache\": true, \"cache\": true, \"cookies\": true, " 39 "\"appcache\": true, \"cache\": true, \"cookies\": true, "
40 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, " 40 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
41 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, " 41 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
42 "\"serverBoundCertificates\": true, \"passwords\": true, " 42 "\"serverBoundCertificates\": true, \"passwords\": true, "
43 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, " 43 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, "
44 "\"webSQL\": true" 44 "\"webSQL\": true"
45 "}]"; 45 "}]";
46 46
47 class ExtensionBrowsingDataTest : public InProcessBrowserTest { 47 class ExtensionBrowsingDataTest : public InProcessBrowserTest {
48 public: 48 public:
49 base::Time GetBeginTime() { 49 const base::Time& GetBeginTime() {
50 return called_with_details_->removal_begin; 50 return remover_->GetLastUsedBeginTime();
51 } 51 }
52 52
53 int GetRemovalMask() { 53 int GetRemovalMask() {
54 return called_with_details_->removal_mask; 54 return remover_->GetLastUsedRemovalMask();
55 } 55 }
56 56
57 int GetOriginTypeMask() { 57 int GetOriginTypeMask() {
58 return called_with_details_->origin_type_mask; 58 return remover_->GetLastUsedOriginTypeMask();
59 } 59 }
60 60
61 protected: 61 protected:
62 void SetUpOnMainThread() override { 62 void SetUpOnMainThread() override {
63 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); 63 remover_ =
64 callback_subscription_ = 64 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile());
65 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
66 base::Bind(&ExtensionBrowsingDataTest::NotifyWithDetails,
67 base::Unretained(this)));
68 }
69
70 // Callback for browsing data removal events.
71 void NotifyWithDetails(
72 const BrowsingDataRemover::NotificationDetails& details) {
73 // We're not taking ownership of the details object, but storing a copy of
74 // it locally.
75 called_with_details_.reset(
76 new BrowsingDataRemover::NotificationDetails(details));
77 } 65 }
78 66
79 int GetAsMask(const base::DictionaryValue* dict, std::string path, 67 int GetAsMask(const base::DictionaryValue* dict, std::string path,
80 int mask_value) { 68 int mask_value) {
81 bool result; 69 bool result;
82 EXPECT_TRUE(dict->GetBoolean(path, &result)) << "for " << path; 70 EXPECT_TRUE(dict->GetBoolean(path, &result)) << "for " << path;
83 return result ? mask_value : 0; 71 return result ? mask_value : 0;
84 } 72 }
85 73
86 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask( 74 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 function.get(), args, browser())) << " for " << args; 237 function.get(), args, browser())) << " for " << args;
250 } else { 238 } else {
251 EXPECT_TRUE(base::MatchPattern( 239 EXPECT_TRUE(base::MatchPattern(
252 RunFunctionAndReturnError(function.get(), args, browser()), 240 RunFunctionAndReturnError(function.get(), args, browser()),
253 extension_browsing_data_api_constants::kDeleteProhibitedError)) 241 extension_browsing_data_api_constants::kDeleteProhibitedError))
254 << " for " << args; 242 << " for " << args;
255 } 243 }
256 } 244 }
257 245
258 private: 246 private:
259 std::unique_ptr<BrowsingDataRemover::NotificationDetails> 247 // Cached pointer to BrowsingDataRemover for access to testing methods.
260 called_with_details_; 248 BrowsingDataRemover* remover_;
261
262 BrowsingDataRemover::CallbackSubscription callback_subscription_;
263 }; 249 };
264 250
265 } // namespace 251 } // namespace
266 252
267 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) { 253 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) {
268 BrowsingDataRemover* browsing_data_remover = 254 BrowsingDataRemover* browsing_data_remover =
269 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); 255 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile());
270 browsing_data_remover->SetRemoving(true); 256 browsing_data_remover->SetRemoving(true);
271 scoped_refptr<BrowsingDataRemoveFunction> function = 257 scoped_refptr<BrowsingDataRemoveFunction> function =
272 new BrowsingDataRemoveFunction(); 258 new BrowsingDataRemoveFunction();
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 522
537 SetPrefsAndVerifySettings( 523 SetPrefsAndVerifySettings(
538 BrowsingDataRemover::REMOVE_COOKIES | 524 BrowsingDataRemover::REMOVE_COOKIES |
539 BrowsingDataRemover::REMOVE_HISTORY | 525 BrowsingDataRemover::REMOVE_HISTORY |
540 BrowsingDataRemover::REMOVE_DOWNLOADS, 526 BrowsingDataRemover::REMOVE_DOWNLOADS,
541 UNPROTECTED_WEB, 527 UNPROTECTED_WEB,
542 site_data_no_plugins | 528 site_data_no_plugins |
543 BrowsingDataRemover::REMOVE_HISTORY | 529 BrowsingDataRemover::REMOVE_HISTORY |
544 BrowsingDataRemover::REMOVE_DOWNLOADS); 530 BrowsingDataRemover::REMOVE_DOWNLOADS);
545 } 531 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698