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_file_system_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 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper(
16 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
19 void MockBrowsingDataFileSystemHelper::StartFetching(
20 const FetchCallback
& callback
) {
21 ASSERT_FALSE(callback
.is_null());
22 ASSERT_TRUE(callback_
.is_null());
26 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
28 ASSERT_FALSE(callback_
.is_null());
29 std::string key
= origin
.spec();
30 ASSERT_TRUE(ContainsKey(file_systems_
, key
));
31 last_deleted_origin_
= origin
;
32 file_systems_
[key
] = false;
35 void MockBrowsingDataFileSystemHelper::AddFileSystem(
36 const GURL
& origin
, bool has_persistent
, bool has_temporary
,
38 BrowsingDataFileSystemHelper::FileSystemInfo
info(origin
);
40 info
.usage_map
[storage::kFileSystemTypePersistent
] = 0;
42 info
.usage_map
[storage::kFileSystemTypeTemporary
] = 0;
44 info
.usage_map
[storage::kFileSystemTypeSyncable
] = 0;
45 response_
.push_back(info
);
46 file_systems_
[origin
.spec()] = true;
49 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() {
50 AddFileSystem(GURL("http://fshost1:1/"), false, true, false);
51 AddFileSystem(GURL("http://fshost2:2/"), true, false, true);
52 AddFileSystem(GURL("http://fshost3:3/"), true, true, true);
55 void MockBrowsingDataFileSystemHelper::Notify() {
56 callback_
.Run(response_
);
59 void MockBrowsingDataFileSystemHelper::Reset() {
60 for (auto& pair
: file_systems_
)
64 bool MockBrowsingDataFileSystemHelper::AllDeleted() {
65 for (const auto& pair
: file_systems_
) {