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_database_helper.h"
7 #include "base/callback.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 MockBrowsingDataDatabaseHelper::MockBrowsingDataDatabaseHelper(
12 : BrowsingDataDatabaseHelper(profile
) {
15 MockBrowsingDataDatabaseHelper::~MockBrowsingDataDatabaseHelper() {
18 void MockBrowsingDataDatabaseHelper::StartFetching(
19 const base::Callback
<void(const std::list
<DatabaseInfo
>&)>& callback
) {
20 ASSERT_FALSE(callback
.is_null());
21 ASSERT_TRUE(callback_
.is_null());
25 void MockBrowsingDataDatabaseHelper::DeleteDatabase(
26 const std::string
& origin
,
27 const std::string
& name
) {
28 ASSERT_FALSE(callback_
.is_null());
29 std::string key
= origin
+ ":" + name
;
30 ASSERT_TRUE(databases_
.find(key
) != databases_
.end());
31 last_deleted_origin_
= origin
;
32 last_deleted_db_
= name
;
33 databases_
[key
] = false;
36 void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() {
37 storage::DatabaseIdentifier id1
=
38 storage::DatabaseIdentifier::Parse("http_gdbhost1_1");
39 response_
.push_back(BrowsingDataDatabaseHelper::DatabaseInfo(
40 id1
, "db1", "description 1", 1, base::Time()));
41 databases_
["http_gdbhost1_1:db1"] = true;
42 storage::DatabaseIdentifier id2
=
43 storage::DatabaseIdentifier::Parse("http_gdbhost2_2");
44 response_
.push_back(BrowsingDataDatabaseHelper::DatabaseInfo(
45 id2
, "db2", "description 2", 2, base::Time()));
46 databases_
["http_gdbhost2_2:db2"] = true;
49 void MockBrowsingDataDatabaseHelper::Notify() {
50 callback_
.Run(response_
);
53 void MockBrowsingDataDatabaseHelper::Reset() {
54 for (std::map
<const std::string
, bool>::iterator i
= databases_
.begin();
55 i
!= databases_
.end(); ++i
)
59 bool MockBrowsingDataDatabaseHelper::AllDeleted() {
60 for (std::map
<const std::string
, bool>::const_iterator i
= databases_
.begin();
61 i
!= databases_
.end(); ++i
)