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 "testing/gtest/include/gtest/gtest.h"
11 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper(
15 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
18 void MockBrowsingDataFileSystemHelper::StartFetching(
19 const base::Callback
<void(const std::list
<FileSystemInfo
>&)>& callback
) {
20 ASSERT_FALSE(callback
.is_null());
21 ASSERT_TRUE(callback_
.is_null());
25 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
27 ASSERT_FALSE(callback_
.is_null());
28 std::string key
= origin
.spec();
29 ASSERT_TRUE(file_systems_
.find(key
) != file_systems_
.end());
30 last_deleted_origin_
= origin
;
31 file_systems_
[key
] = false;
34 void MockBrowsingDataFileSystemHelper::AddFileSystem(
35 const GURL
& origin
, bool has_persistent
, bool has_temporary
,
37 BrowsingDataFileSystemHelper::FileSystemInfo
info(origin
);
39 info
.usage_map
[storage::kFileSystemTypePersistent
] = 0;
41 info
.usage_map
[storage::kFileSystemTypeTemporary
] = 0;
43 info
.usage_map
[storage::kFileSystemTypeSyncable
] = 0;
44 response_
.push_back(info
);
45 file_systems_
[origin
.spec()] = true;
48 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() {
49 AddFileSystem(GURL("http://fshost1:1/"), false, true, false);
50 AddFileSystem(GURL("http://fshost2:2/"), true, false, true);
51 AddFileSystem(GURL("http://fshost3:3/"), true, true, true);
54 void MockBrowsingDataFileSystemHelper::Notify() {
55 callback_
.Run(response_
);
58 void MockBrowsingDataFileSystemHelper::Reset() {
59 for (std::map
<const std::string
, bool>::iterator i
= file_systems_
.begin();
60 i
!= file_systems_
.end(); ++i
)
64 bool MockBrowsingDataFileSystemHelper::AllDeleted() {
65 for (std::map
<const std::string
, bool>::const_iterator i
=
66 file_systems_
.begin();
67 i
!= file_systems_
.end(); ++i
) {