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

Unified Diff: net/base/ssl_config_service_unittest.cc

Issue 12680003: net: split net/ssl out of net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/ssl_config_service_defaults.cc ('k') | net/base/ssl_connection_status_flags.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ssl_config_service_unittest.cc
diff --git a/net/base/ssl_config_service_unittest.cc b/net/base/ssl_config_service_unittest.cc
deleted file mode 100644
index a0d85db8bf394ff5d4438bd979e069a134fc8cff..0000000000000000000000000000000000000000
--- a/net/base/ssl_config_service_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/ssl_config_service.h"
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-
-namespace {
-
-class MockSSLConfigService : public SSLConfigService {
- public:
- explicit MockSSLConfigService(const SSLConfig& config) : config_(config) {}
-
- // SSLConfigService implementation
- virtual void GetSSLConfig(SSLConfig* config) OVERRIDE {
- *config = config_;
- }
-
- // Sets the SSLConfig to be returned by GetSSLConfig and processes any
- // updates.
- void SetSSLConfig(const SSLConfig& config) {
- SSLConfig old_config = config_;
- config_ = config;
- ProcessConfigUpdate(old_config, config_);
- }
-
- private:
- virtual ~MockSSLConfigService() {}
-
- SSLConfig config_;
-};
-
-class MockSSLConfigServiceObserver : public SSLConfigService::Observer {
- public:
- MockSSLConfigServiceObserver() {}
- virtual ~MockSSLConfigServiceObserver() {}
-
- MOCK_METHOD0(OnSSLConfigChanged, void());
-};
-
-} // namespace
-
-TEST(SSLConfigServiceTest, NoChangesWontNotifyObservers) {
- SSLConfig initial_config;
- initial_config.rev_checking_enabled = true;
- initial_config.false_start_enabled = false;
- initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3;
- initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1;
-
- scoped_refptr<MockSSLConfigService> mock_service(
- new MockSSLConfigService(initial_config));
- MockSSLConfigServiceObserver observer;
- mock_service->AddObserver(&observer);
-
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(0);
- mock_service->SetSSLConfig(initial_config);
-
- mock_service->RemoveObserver(&observer);
-}
-
-TEST(SSLConfigServiceTest, ConfigUpdatesNotifyObservers) {
- SSLConfig initial_config;
- initial_config.rev_checking_enabled = true;
- initial_config.false_start_enabled = false;
- initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3;
- initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1;
-
- scoped_refptr<MockSSLConfigService> mock_service(
- new MockSSLConfigService(initial_config));
- MockSSLConfigServiceObserver observer;
- mock_service->AddObserver(&observer);
-
- // Test that the basic boolean preferences trigger updates.
- initial_config.rev_checking_enabled = false;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- initial_config.false_start_enabled = true;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- // Test that changing the SSL version range triggers updates.
- initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- initial_config.version_max = SSL_PROTOCOL_VERSION_SSL3;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- // Test that disabling certain cipher suites triggers an update.
- std::vector<uint16> disabled_ciphers;
- disabled_ciphers.push_back(0x0004u);
- disabled_ciphers.push_back(0xBEEFu);
- disabled_ciphers.push_back(0xDEADu);
- initial_config.disabled_cipher_suites = disabled_ciphers;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- // Ensure that changing a disabled cipher suite, while still maintaining
- // sorted order, triggers an update.
- disabled_ciphers[1] = 0xCAFEu;
- initial_config.disabled_cipher_suites = disabled_ciphers;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- // Ensure that removing a disabled cipher suite, while still keeping some
- // cipher suites disabled, triggers an update.
- disabled_ciphers.pop_back();
- initial_config.disabled_cipher_suites = disabled_ciphers;
- EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
- mock_service->SetSSLConfig(initial_config);
-
- mock_service->RemoveObserver(&observer);
-}
-
-} // namespace net
« no previous file with comments | « net/base/ssl_config_service_defaults.cc ('k') | net/base/ssl_connection_status_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698