OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_channel_id_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_channel_id_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 MockBrowsingDataChannelIDHelper::MockBrowsingDataChannelIDHelper() | 10 MockBrowsingDataChannelIDHelper::MockBrowsingDataChannelIDHelper() |
10 : BrowsingDataChannelIDHelper() {} | 11 : BrowsingDataChannelIDHelper() {} |
11 | 12 |
12 MockBrowsingDataChannelIDHelper:: | 13 MockBrowsingDataChannelIDHelper:: |
13 ~MockBrowsingDataChannelIDHelper() {} | 14 ~MockBrowsingDataChannelIDHelper() {} |
14 | 15 |
15 void MockBrowsingDataChannelIDHelper::StartFetching( | 16 void MockBrowsingDataChannelIDHelper::StartFetching( |
16 const FetchResultCallback& callback) { | 17 const FetchResultCallback& callback) { |
| 18 ASSERT_FALSE(callback.is_null()); |
| 19 ASSERT_TRUE(callback_.is_null()); |
17 callback_ = callback; | 20 callback_ = callback; |
18 } | 21 } |
19 | 22 |
20 void MockBrowsingDataChannelIDHelper::DeleteChannelID( | 23 void MockBrowsingDataChannelIDHelper::DeleteChannelID( |
21 const std::string& server_id) { | 24 const std::string& server_id) { |
22 CHECK(channel_ids_.find(server_id) != channel_ids_.end()); | 25 ASSERT_FALSE(callback_.is_null()); |
| 26 ASSERT_TRUE(channel_ids_.find(server_id) != channel_ids_.end()); |
23 channel_ids_[server_id] = false; | 27 channel_ids_[server_id] = false; |
24 } | 28 } |
25 | 29 |
26 void MockBrowsingDataChannelIDHelper::AddChannelIDSample( | 30 void MockBrowsingDataChannelIDHelper::AddChannelIDSample( |
27 const std::string& server_id) { | 31 const std::string& server_id) { |
28 DCHECK(channel_ids_.find(server_id) == channel_ids_.end()); | 32 ASSERT_TRUE(channel_ids_.find(server_id) == channel_ids_.end()); |
29 channel_id_list_.push_back( | 33 channel_id_list_.push_back( |
30 net::ChannelIDStore::ChannelID( | 34 net::ChannelIDStore::ChannelID( |
31 server_id, base::Time(), base::Time(), "key", "cert")); | 35 server_id, base::Time(), base::Time(), "key", "cert")); |
32 channel_ids_[server_id] = true; | 36 channel_ids_[server_id] = true; |
33 } | 37 } |
34 | 38 |
35 void MockBrowsingDataChannelIDHelper::Notify() { | 39 void MockBrowsingDataChannelIDHelper::Notify() { |
36 net::ChannelIDStore::ChannelIDList channel_id_list; | 40 net::ChannelIDStore::ChannelIDList channel_id_list; |
37 for (net::ChannelIDStore::ChannelIDList::iterator i = | 41 for (net::ChannelIDStore::ChannelIDList::iterator i = |
38 channel_id_list_.begin(); | 42 channel_id_list_.begin(); |
(...skipping 12 matching lines...) Expand all Loading... |
51 } | 55 } |
52 | 56 |
53 bool MockBrowsingDataChannelIDHelper::AllDeleted() { | 57 bool MockBrowsingDataChannelIDHelper::AllDeleted() { |
54 for (std::map<const std::string, bool>::const_iterator i = | 58 for (std::map<const std::string, bool>::const_iterator i = |
55 channel_ids_.begin(); | 59 channel_ids_.begin(); |
56 i != channel_ids_.end(); ++i) | 60 i != channel_ids_.end(); ++i) |
57 if (i->second) | 61 if (i->second) |
58 return false; | 62 return false; |
59 return true; | 63 return true; |
60 } | 64 } |
OLD | NEW |