| 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/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" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "net/ssl/channel_id_service.h" | 12 #include "net/ssl/channel_id_service.h" |
| 13 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 | 18 |
| 19 class BrowsingDataChannelIDHelperTest | 19 class BrowsingDataChannelIDHelperTest |
| 20 : public testing::Test, | 20 : public testing::Test, |
| 21 public net::SSLConfigService::Observer { | 21 public net::SSLConfigService::Observer { |
| 22 public: | 22 public: |
| 23 BrowsingDataChannelIDHelperTest() : ssl_config_changed_count_(0) { | 23 BrowsingDataChannelIDHelperTest() : ssl_config_changed_count_(0) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void SetUp() override { | 26 void SetUp() override { |
| 27 testing_profile_.reset(new TestingProfile()); | 27 testing_profile_.reset(new TestingProfile()); |
| 28 | 28 |
| 29 testing_profile_->GetSSLConfigService()->AddObserver(this); | 29 testing_profile_->GetSSLConfigService()->AddObserver(this); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void TearDown() override { | 32 void TearDown() override { |
| 33 testing_profile_->GetSSLConfigService()->RemoveObserver(this); | 33 testing_profile_->GetSSLConfigService()->RemoveObserver(this); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void CreateChannelIDsForTest() { | 36 void CreateChannelIDsForTest() { |
| 37 net::URLRequestContext* context = | 37 net::URLRequestContext* context = |
| 38 testing_profile_->GetRequestContext()->GetURLRequestContext(); | 38 testing_profile_->GetRequestContext()->GetURLRequestContext(); |
| 39 net::ChannelIDStore* channel_id_store = | 39 net::ChannelIDStore* channel_id_store = |
| 40 context->channel_id_service()->GetChannelIDStore(); | 40 context->channel_id_service()->GetChannelIDStore(); |
| 41 channel_id_store->SetChannelID("https://www.google.com:443", | 41 channel_id_store->SetChannelID("https://www.google.com:443", |
| 42 base::Time(), base::Time(), | 42 base::Time(), base::Time(), |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper( | 135 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper( |
| 136 new CannedBrowsingDataChannelIDHelper()); | 136 new CannedBrowsingDataChannelIDHelper()); |
| 137 | 137 |
| 138 ASSERT_TRUE(helper->empty()); | 138 ASSERT_TRUE(helper->empty()); |
| 139 helper->AddChannelID(net::ChannelIDStore::ChannelID( | 139 helper->AddChannelID(net::ChannelIDStore::ChannelID( |
| 140 origin, base::Time(), base::Time(), "key", "cert")); | 140 origin, base::Time(), base::Time(), "key", "cert")); |
| 141 ASSERT_FALSE(helper->empty()); | 141 ASSERT_FALSE(helper->empty()); |
| 142 helper->Reset(); | 142 helper->Reset(); |
| 143 ASSERT_TRUE(helper->empty()); | 143 ASSERT_TRUE(helper->empty()); |
| 144 } | 144 } |
| OLD | NEW |