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 "testing/gtest/include/gtest/gtest.h"
11 MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper(
13 : BrowsingDataLocalStorageHelper(profile
) {
16 MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() {
19 void MockBrowsingDataLocalStorageHelper::StartFetching(
20 const base::Callback
<void(const std::list
<LocalStorageInfo
>&)>& callback
) {
21 ASSERT_FALSE(callback
.is_null());
22 ASSERT_TRUE(callback_
.is_null());
26 void MockBrowsingDataLocalStorageHelper::DeleteOrigin(
28 ASSERT_FALSE(callback_
.is_null());
29 ASSERT_TRUE(origins_
.find(origin
) != origins_
.end());
30 last_deleted_origin_
= origin
;
31 origins_
[origin
] = false;
34 void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() {
35 const GURL
kOrigin1("http://host1:1/");
36 const GURL
kOrigin2("http://host2:2/");
38 BrowsingDataLocalStorageHelper::LocalStorageInfo(
39 kOrigin1
, 1, base::Time()));
40 origins_
[kOrigin1
] = true;
42 BrowsingDataLocalStorageHelper::LocalStorageInfo(
43 kOrigin2
, 2, base::Time()));
44 origins_
[kOrigin2
] = true;
47 void MockBrowsingDataLocalStorageHelper::Notify() {
48 callback_
.Run(response_
);
51 void MockBrowsingDataLocalStorageHelper::Reset() {
52 for (std::map
<const GURL
, bool>::iterator i
= origins_
.begin();
53 i
!= origins_
.end(); ++i
)
57 bool MockBrowsingDataLocalStorageHelper::AllDeleted() {
58 for (std::map
<const GURL
, bool>::const_iterator i
=
59 origins_
.begin(); i
!= origins_
.end(); ++i
)