OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h" |
6 | 6 |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 using content::BrowserThread; | 10 using content::BrowserThread; |
10 | 11 |
11 MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile) | 12 MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile) |
12 : BrowsingDataQuotaHelper(BrowserThread::GetMessageLoopProxyForThread( | 13 : BrowsingDataQuotaHelper(BrowserThread::GetMessageLoopProxyForThread( |
13 BrowserThread::IO).get()) {} | 14 BrowserThread::IO).get()) {} |
14 | 15 |
15 MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {} | 16 MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {} |
16 | 17 |
17 void MockBrowsingDataQuotaHelper::StartFetching( | 18 void MockBrowsingDataQuotaHelper::StartFetching( |
18 const FetchResultCallback& callback) { | 19 const FetchResultCallback& callback) { |
| 20 ASSERT_FALSE(callback.is_null()); |
| 21 ASSERT_TRUE(callback_.is_null()); |
19 callback_ = callback; | 22 callback_ = callback; |
20 } | 23 } |
21 | 24 |
22 void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) { | 25 void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) { |
23 } | 26 } |
24 | 27 |
25 void MockBrowsingDataQuotaHelper::AddHost( | 28 void MockBrowsingDataQuotaHelper::AddHost( |
26 const std::string& host, | 29 const std::string& host, |
27 int64 temporary_usage, | 30 int64 temporary_usage, |
28 int64 persistent_usage, | 31 int64 persistent_usage, |
29 int64 syncable_usage) { | 32 int64 syncable_usage) { |
30 response_.push_back(QuotaInfo( | 33 response_.push_back(QuotaInfo( |
31 host, | 34 host, |
32 temporary_usage, | 35 temporary_usage, |
33 persistent_usage, | 36 persistent_usage, |
34 syncable_usage)); | 37 syncable_usage)); |
35 } | 38 } |
36 | 39 |
37 void MockBrowsingDataQuotaHelper::AddQuotaSamples() { | 40 void MockBrowsingDataQuotaHelper::AddQuotaSamples() { |
38 AddHost("quotahost1", 1, 2, 1); | 41 AddHost("quotahost1", 1, 2, 1); |
39 AddHost("quotahost2", 10, 20, 10); | 42 AddHost("quotahost2", 10, 20, 10); |
40 } | 43 } |
41 | 44 |
42 void MockBrowsingDataQuotaHelper::Notify() { | 45 void MockBrowsingDataQuotaHelper::Notify() { |
43 CHECK_EQ(false, callback_.is_null()); | |
44 callback_.Run(response_); | 46 callback_.Run(response_); |
45 callback_.Reset(); | 47 callback_.Reset(); |
46 response_.clear(); | 48 response_.clear(); |
47 } | 49 } |
OLD | NEW |