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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 1776903002: Refactor BrowsingDataRemover to mock out WebappRegistry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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.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 "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "net/ssl/channel_id_store.h" 69 #include "net/ssl/channel_id_store.h"
70 #include "net/ssl/ssl_client_cert_type.h" 70 #include "net/ssl/ssl_client_cert_type.h"
71 #include "net/url_request/url_request_context.h" 71 #include "net/url_request/url_request_context.h"
72 #include "net/url_request/url_request_context_getter.h" 72 #include "net/url_request/url_request_context_getter.h"
73 #include "testing/gmock/include/gmock/gmock.h" 73 #include "testing/gmock/include/gmock/gmock.h"
74 #include "testing/gtest/include/gtest/gtest.h" 74 #include "testing/gtest/include/gtest/gtest.h"
75 #include "third_party/skia/include/core/SkBitmap.h" 75 #include "third_party/skia/include/core/SkBitmap.h"
76 #include "ui/gfx/favicon_size.h" 76 #include "ui/gfx/favicon_size.h"
77 #include "url/origin.h" 77 #include "url/origin.h"
78 78
79 #if BUILDFLAG(ANDROID_JAVA_UI)
80 #include "chrome/browser/android/webapps/webapp_registry.h"
81 #endif
82
79 #if defined(OS_CHROMEOS) 83 #if defined(OS_CHROMEOS)
80 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 84 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
81 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 85 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
82 #include "chrome/browser/chromeos/settings/cros_settings.h" 86 #include "chrome/browser/chromeos/settings/cros_settings.h"
83 #include "chrome/browser/chromeos/settings/device_settings_service.h" 87 #include "chrome/browser/chromeos/settings/device_settings_service.h"
84 #include "chromeos/dbus/dbus_thread_manager.h" 88 #include "chromeos/dbus/dbus_thread_manager.h"
85 #include "chromeos/dbus/mock_cryptohome_client.h" 89 #include "chromeos/dbus/mock_cryptohome_client.h"
86 #include "components/signin/core/account_id/account_id.h" 90 #include "components/signin/core/account_id/account_id.h"
87 #endif 91 #endif
88 92
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 private: 257 private:
254 void AsyncRunCallback(const base::Closure& callback) { 258 void AsyncRunCallback(const base::Closure& callback) {
255 callback.Run(); 259 callback.Run();
256 } 260 }
257 261
258 StoragePartitionRemovalData storage_partition_removal_data_; 262 StoragePartitionRemovalData storage_partition_removal_data_;
259 263
260 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); 264 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition);
261 }; 265 };
262 266
267 #if BUILDFLAG(ANDROID_JAVA_UI)
268 class TestWebappRegistry : public WebappRegistry {
269 public:
270 TestWebappRegistry() : WebappRegistry() { }
271
272 void UnregisterWebapps(const base::Closure& callback) override {
273 // Mocks out a JNI call and runs the callback.
274 callback.Run();
gone 2016/03/10 00:18:06 Should this be a delayed task, like with the real
dominickn 2016/03/10 00:30:45 My reasoning was that I wanted to block as little
gone 2016/03/10 00:45:07 Although the Java calls won't work, I'd normally a
275 }
276 };
277 #endif
278
263 // Custom matcher to test the equivalence of two URL filters. Since those are 279 // Custom matcher to test the equivalence of two URL filters. Since those are
264 // blackbox predicates, we can only approximate the equivalence by testing 280 // blackbox predicates, we can only approximate the equivalence by testing
265 // whether the filter give the same answer for several URLs. This is currently 281 // whether the filter give the same answer for several URLs. This is currently
266 // good enough for our testing purposes, to distinguish whitelists 282 // good enough for our testing purposes, to distinguish whitelists
267 // and blacklists, empty and non-empty filters and such. 283 // and blacklists, empty and non-empty filters and such.
268 // TODO(msramek): BrowsingDataRemover and some of its backends support URL 284 // TODO(msramek): BrowsingDataRemover and some of its backends support URL
269 // filters, but its constructor currently only takes a single URL and constructs 285 // filters, but its constructor currently only takes a single URL and constructs
270 // its own url filter. If an url filter was directly passed to 286 // its own url filter. If an url filter was directly passed to
271 // BrowsingDataRemover (what should eventually be the case), we can use the same 287 // BrowsingDataRemover (what should eventually be the case), we can use the same
272 // instance in the test as well, and thus simply test base::Callback::Equals() 288 // instance in the test as well, and thus simply test base::Callback::Equals()
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 951
936 class BrowsingDataRemoverTest : public testing::Test { 952 class BrowsingDataRemoverTest : public testing::Test {
937 public: 953 public:
938 BrowsingDataRemoverTest() 954 BrowsingDataRemoverTest()
939 : profile_(new TestingProfile()), 955 : profile_(new TestingProfile()),
940 clear_domain_reliability_tester_(GetProfile()) { 956 clear_domain_reliability_tester_(GetProfile()) {
941 callback_subscription_ = 957 callback_subscription_ =
942 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 958 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
943 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails, 959 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails,
944 base::Unretained(this))); 960 base::Unretained(this)));
961
962 #if BUILDFLAG(ANDROID_JAVA_UI)
963 BrowsingDataRemover* remover =
964 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get());
965 remover->OverrideWebappRegistryForTesting(
966 scoped_ptr<WebappRegistry>(new TestWebappRegistry()));
967 #endif
945 } 968 }
946 969
947 ~BrowsingDataRemoverTest() override {} 970 ~BrowsingDataRemoverTest() override {}
948 971
949 void TearDown() override { 972 void TearDown() override {
950 #if defined(ENABLE_EXTENSIONS) 973 #if defined(ENABLE_EXTENSIONS)
951 mock_policy_ = nullptr; 974 mock_policy_ = nullptr;
952 #endif 975 #endif
953 976
954 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor 977 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) 2299 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _))
2277 .WillOnce(Return(password_manager::PasswordStoreChangeList())); 2300 .WillOnce(Return(password_manager::PasswordStoreChangeList()));
2278 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) 2301 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl())
2279 .WillOnce(Return(password_manager::PasswordStoreChangeList())); 2302 .WillOnce(Return(password_manager::PasswordStoreChangeList()));
2280 2303
2281 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, 2304 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING,
2282 BrowsingDataRemover::REMOVE_COOKIES | 2305 BrowsingDataRemover::REMOVE_COOKIES |
2283 BrowsingDataRemover::REMOVE_PASSWORDS, 2306 BrowsingDataRemover::REMOVE_PASSWORDS,
2284 false); 2307 false);
2285 } 2308 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698