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

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

Issue 2206953002: Use mojo for WebappRegistry. Base URL: https://chromium.googlesource.com/chromium/src.git@java-interface-registry
Patch Set: 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.cc ('k') | chrome/chrome_browser.gypi » ('j') | 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 <memory> 10 #include <memory>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #include "net/ssl/ssl_client_cert_type.h" 82 #include "net/ssl/ssl_client_cert_type.h"
83 #include "net/url_request/url_request_context.h" 83 #include "net/url_request/url_request_context.h"
84 #include "net/url_request/url_request_context_getter.h" 84 #include "net/url_request/url_request_context_getter.h"
85 #include "testing/gmock/include/gmock/gmock.h" 85 #include "testing/gmock/include/gmock/gmock.h"
86 #include "testing/gtest/include/gtest/gtest.h" 86 #include "testing/gtest/include/gtest/gtest.h"
87 #include "third_party/skia/include/core/SkBitmap.h" 87 #include "third_party/skia/include/core/SkBitmap.h"
88 #include "ui/gfx/favicon_size.h" 88 #include "ui/gfx/favicon_size.h"
89 #include "url/origin.h" 89 #include "url/origin.h"
90 90
91 #if BUILDFLAG(ANDROID_JAVA_UI) 91 #if BUILDFLAG(ANDROID_JAVA_UI)
92 #include "chrome/browser/android/webapps/webapp_registry.h" 92 #include "chrome/browser/android/webapps/webapp_registry.mojom.h"
93 #include "mojo/public/cpp/bindings/strong_binding.h"
93 #endif 94 #endif
94 95
95 #if defined(OS_CHROMEOS) 96 #if defined(OS_CHROMEOS)
96 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 97 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
97 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 98 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
98 #include "chrome/browser/chromeos/settings/cros_settings.h" 99 #include "chrome/browser/chromeos/settings/cros_settings.h"
99 #include "chrome/browser/chromeos/settings/device_settings_service.h" 100 #include "chrome/browser/chromeos/settings/device_settings_service.h"
100 #include "chromeos/dbus/dbus_thread_manager.h" 101 #include "chromeos/dbus/dbus_thread_manager.h"
101 #include "chromeos/dbus/mock_cryptohome_client.h" 102 #include "chromeos/dbus/mock_cryptohome_client.h"
102 #include "components/signin/core/account_id/account_id.h" 103 #include "components/signin/core/account_id/account_id.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 void AsyncRunCallback(const base::Closure& callback) { 300 void AsyncRunCallback(const base::Closure& callback) {
300 callback.Run(); 301 callback.Run();
301 } 302 }
302 303
303 StoragePartitionRemovalData storage_partition_removal_data_; 304 StoragePartitionRemovalData storage_partition_removal_data_;
304 305
305 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); 306 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition);
306 }; 307 };
307 308
308 #if BUILDFLAG(ANDROID_JAVA_UI) 309 #if BUILDFLAG(ANDROID_JAVA_UI)
309 class TestWebappRegistry : public WebappRegistry { 310 class TestWebappRegistry : public mojom::WebappRegistry {
310 public: 311 public:
311 TestWebappRegistry() : WebappRegistry() { } 312 explicit TestWebappRegistry(mojom::WebappRegistryRequest request)
313 : binding_(this, std::move(request)) {}
312 314
313 void UnregisterWebapps(const base::Closure& callback) override { 315 void UnregisterAllWebapps(const base::Closure& callback) override {
314 // Mocks out a JNI call and runs the callback as a delayed task. 316 callback.Run();
315 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, callback,
316 base::TimeDelta::FromMilliseconds(10));
317 } 317 }
318 318
319 void ClearWebappHistory(const base::Closure& callback) override { 319 void ClearWebappHistory(const base::Closure& callback) override {
320 // Mocks out a JNI call and runs the callback as a delayed task. 320 callback.Run();
321 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, callback,
322 base::TimeDelta::FromMilliseconds(10));
323 } 321 }
322
323 mojo::StrongBinding<mojom::WebappRegistry> binding_;
324 }; 324 };
325 #endif 325 #endif
326 326
327 // Custom matcher to test the equivalence of two URL filters. Since those are 327 // Custom matcher to test the equivalence of two URL filters. Since those are
328 // blackbox predicates, we can only approximate the equivalence by testing 328 // blackbox predicates, we can only approximate the equivalence by testing
329 // whether the filter give the same answer for several URLs. This is currently 329 // whether the filter give the same answer for several URLs. This is currently
330 // good enough for our testing purposes, to distinguish whitelists 330 // good enough for our testing purposes, to distinguish whitelists
331 // and blacklists, empty and non-empty filters and such. 331 // and blacklists, empty and non-empty filters and such.
332 // TODO(msramek): BrowsingDataRemover and some of its backends support URL 332 // TODO(msramek): BrowsingDataRemover and some of its backends support URL
333 // filters, but its constructor currently only takes a single URL and constructs 333 // filters, but its constructor currently only takes a single URL and constructs
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1022
1023 class BrowsingDataRemoverTest : public testing::Test { 1023 class BrowsingDataRemoverTest : public testing::Test {
1024 public: 1024 public:
1025 BrowsingDataRemoverTest() 1025 BrowsingDataRemoverTest()
1026 : profile_(new TestingProfile()), 1026 : profile_(new TestingProfile()),
1027 clear_domain_reliability_tester_(GetProfile()) { 1027 clear_domain_reliability_tester_(GetProfile()) {
1028 remover_ = 1028 remover_ =
1029 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); 1029 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get());
1030 1030
1031 #if BUILDFLAG(ANDROID_JAVA_UI) 1031 #if BUILDFLAG(ANDROID_JAVA_UI)
1032 remover_->OverrideWebappRegistryForTesting( 1032 mojom::WebappRegistryPtr webapp_registry;
1033 std::unique_ptr<WebappRegistry>(new TestWebappRegistry())); 1033 new TestWebappRegistry(mojo::GetProxy(&webapp_registry));
1034 remover_->OverrideWebappRegistryForTesting(std::move(webapp_registry));
1034 #endif 1035 #endif
1035 } 1036 }
1036 1037
1037 ~BrowsingDataRemoverTest() override {} 1038 ~BrowsingDataRemoverTest() override {}
1038 1039
1039 void TearDown() override { 1040 void TearDown() override {
1040 #if defined(ENABLE_EXTENSIONS) 1041 #if defined(ENABLE_EXTENSIONS)
1041 mock_policy_ = nullptr; 1042 mock_policy_ = nullptr;
1042 #endif 1043 #endif
1043 1044
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( 2586 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate(
2586 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 2587 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
2587 base::Bind(&MatchPrimaryPattern, http_pattern)); 2588 base::Bind(&MatchPrimaryPattern, http_pattern));
2588 // Verify we only have one, and it's url1. 2589 // Verify we only have one, and it's url1.
2589 host_content_settings_map->GetSettingsForOneType( 2590 host_content_settings_map->GetSettingsForOneType(
2590 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); 2591 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings);
2591 EXPECT_EQ(1u, host_settings.size()); 2592 EXPECT_EQ(1u, host_settings.size());
2592 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), 2593 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1),
2593 host_settings[0].primary_pattern); 2594 host_settings[0].primary_pattern);
2594 } 2595 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698