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
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h"
7 #include "base/callback.h"
8 #include "base/logging.h"
9 #include "base/stl_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper(
14 : BrowsingDataLocalStorageHelper(profile
) {
17 MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() {
20 void MockBrowsingDataLocalStorageHelper::StartFetching(
21 const FetchCallback
& callback
) {
22 ASSERT_FALSE(callback
.is_null());
23 ASSERT_TRUE(callback_
.is_null());
27 void MockBrowsingDataLocalStorageHelper::DeleteOrigin(
29 ASSERT_FALSE(callback_
.is_null());
30 ASSERT_TRUE(ContainsKey(origins_
, origin
));
31 last_deleted_origin_
= origin
;
32 origins_
[origin
] = false;
35 void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() {
36 const GURL
kOrigin1("http://host1:1/");
37 const GURL
kOrigin2("http://host2:2/");
39 BrowsingDataLocalStorageHelper::LocalStorageInfo(
40 kOrigin1
, 1, base::Time()));
41 origins_
[kOrigin1
] = true;
43 BrowsingDataLocalStorageHelper::LocalStorageInfo(
44 kOrigin2
, 2, base::Time()));
45 origins_
[kOrigin2
] = true;
48 void MockBrowsingDataLocalStorageHelper::Notify() {
49 callback_
.Run(response_
);
52 void MockBrowsingDataLocalStorageHelper::Reset() {
53 for (auto& pair
: origins_
)
57 bool MockBrowsingDataLocalStorageHelper::AllDeleted() {
58 for (const auto& pair
: origins_
) {