Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_channel_id_helper_unittest.cc

Issue 508223002: Remove Profile dependency from browsing_data_channel_id_helper.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browsing_data_channel_id_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 scoped_ptr<TestingProfile> testing_profile_; 62 scoped_ptr<TestingProfile> testing_profile_;
63 63
64 net::ChannelIDStore::ChannelIDList channel_id_list_; 64 net::ChannelIDStore::ChannelIDList channel_id_list_;
65 65
66 int ssl_config_changed_count_; 66 int ssl_config_changed_count_;
67 }; 67 };
68 68
69 TEST_F(BrowsingDataChannelIDHelperTest, FetchData) { 69 TEST_F(BrowsingDataChannelIDHelperTest, FetchData) {
70 CreateChannelIDsForTest(); 70 CreateChannelIDsForTest();
71 scoped_refptr<BrowsingDataChannelIDHelper> helper( 71 scoped_refptr<BrowsingDataChannelIDHelper> helper(
72 BrowsingDataChannelIDHelper::Create(testing_profile_.get())); 72 BrowsingDataChannelIDHelper::Create(
73 testing_profile_->GetRequestContext()));
73 74
74 helper->StartFetching( 75 helper->StartFetching(
75 base::Bind(&BrowsingDataChannelIDHelperTest::FetchCallback, 76 base::Bind(&BrowsingDataChannelIDHelperTest::FetchCallback,
76 base::Unretained(this))); 77 base::Unretained(this)));
77 78
78 // Blocks until BrowsingDataChannelIDHelperTest::FetchCallback is 79 // Blocks until BrowsingDataChannelIDHelperTest::FetchCallback is
79 // notified. 80 // notified.
80 base::RunLoop().RunUntilIdle(); 81 base::RunLoop().RunUntilIdle();
81 82
82 ASSERT_EQ(2UL, channel_id_list_.size()); 83 ASSERT_EQ(2UL, channel_id_list_.size());
83 net::ChannelIDStore::ChannelIDList::const_iterator it = 84 net::ChannelIDStore::ChannelIDList::const_iterator it =
84 channel_id_list_.begin(); 85 channel_id_list_.begin();
85 86
86 // Correct because fetching channel_id_list_ will get them out in the 87 // Correct because fetching channel_id_list_ will get them out in the
87 // same order CreateChannelIDsForTest put them in. 88 // same order CreateChannelIDsForTest put them in.
88 ASSERT_TRUE(it != channel_id_list_.end()); 89 ASSERT_TRUE(it != channel_id_list_.end());
89 EXPECT_EQ("https://www.google.com:443", it->server_identifier()); 90 EXPECT_EQ("https://www.google.com:443", it->server_identifier());
90 91
91 ASSERT_TRUE(++it != channel_id_list_.end()); 92 ASSERT_TRUE(++it != channel_id_list_.end());
92 EXPECT_EQ("https://www.youtube.com:443", it->server_identifier()); 93 EXPECT_EQ("https://www.youtube.com:443", it->server_identifier());
93 94
94 ASSERT_TRUE(++it == channel_id_list_.end()); 95 ASSERT_TRUE(++it == channel_id_list_.end());
95 96
96 EXPECT_EQ(0, ssl_config_changed_count_); 97 EXPECT_EQ(0, ssl_config_changed_count_);
97 } 98 }
98 99
99 TEST_F(BrowsingDataChannelIDHelperTest, DeleteChannelID) { 100 TEST_F(BrowsingDataChannelIDHelperTest, DeleteChannelID) {
100 CreateChannelIDsForTest(); 101 CreateChannelIDsForTest();
101 scoped_refptr<BrowsingDataChannelIDHelper> helper( 102 scoped_refptr<BrowsingDataChannelIDHelper> helper(
102 BrowsingDataChannelIDHelper::Create(testing_profile_.get())); 103 BrowsingDataChannelIDHelper::Create(
104 testing_profile_->GetRequestContext()));
103 105
104 helper->DeleteChannelID("https://www.google.com:443"); 106 helper->DeleteChannelID("https://www.google.com:443");
105 107
106 helper->StartFetching( 108 helper->StartFetching(
107 base::Bind(&BrowsingDataChannelIDHelperTest::FetchCallback, 109 base::Bind(&BrowsingDataChannelIDHelperTest::FetchCallback,
108 base::Unretained(this))); 110 base::Unretained(this)));
109 base::RunLoop().RunUntilIdle(); 111 base::RunLoop().RunUntilIdle();
110 112
111 EXPECT_EQ(1, ssl_config_changed_count_); 113 EXPECT_EQ(1, ssl_config_changed_count_);
112 ASSERT_EQ(1UL, channel_id_list_.size()); 114 ASSERT_EQ(1UL, channel_id_list_.size());
(...skipping 22 matching lines...) Expand all
135 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper( 137 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper(
136 new CannedBrowsingDataChannelIDHelper()); 138 new CannedBrowsingDataChannelIDHelper());
137 139
138 ASSERT_TRUE(helper->empty()); 140 ASSERT_TRUE(helper->empty());
139 helper->AddChannelID(net::ChannelIDStore::ChannelID( 141 helper->AddChannelID(net::ChannelIDStore::ChannelID(
140 origin, base::Time(), base::Time(), "key", "cert")); 142 origin, base::Time(), base::Time(), "key", "cert"));
141 ASSERT_FALSE(helper->empty()); 143 ASSERT_FALSE(helper->empty());
142 helper->Reset(); 144 helper->Reset();
143 ASSERT_TRUE(helper->empty()); 145 ASSERT_TRUE(helper->empty());
144 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698