Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_local_storage_helper.cc
blob2c17d57b487c3fb5d4fbdaffa8fbe5715497869d
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(
13 Profile* profile)
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());
24 callback_ = callback;
27 void MockBrowsingDataLocalStorageHelper::DeleteOrigin(
28 const GURL& origin) {
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/");
38 response_.push_back(
39 BrowsingDataLocalStorageHelper::LocalStorageInfo(
40 kOrigin1, 1, base::Time()));
41 origins_[kOrigin1] = true;
42 response_.push_back(
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_)
54 pair.second = true;
57 bool MockBrowsingDataLocalStorageHelper::AllDeleted() {
58 for (const auto& pair : origins_) {
59 if (pair.second)
60 return false;
62 return true;