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

Side by Side Diff: net/base/ssl_config_service_unittest.cc

Issue 10830272: Tweak the tests to match the original intention. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/base/ssl_config_service.h" 5 #include "net/base/ssl_config_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 virtual ~MockSSLConfigServiceObserver() {} 43 virtual ~MockSSLConfigServiceObserver() {}
44 44
45 MOCK_METHOD0(OnSSLConfigChanged, void()); 45 MOCK_METHOD0(OnSSLConfigChanged, void());
46 }; 46 };
47 47
48 } // namespace 48 } // namespace
49 49
50 TEST(SSLConfigServiceTest, NoChangesWontNotifyObservers) { 50 TEST(SSLConfigServiceTest, NoChangesWontNotifyObservers) {
51 SSLConfig initial_config; 51 SSLConfig initial_config;
52 initial_config.rev_checking_enabled = true; 52 initial_config.rev_checking_enabled = true;
53 initial_config.false_start_enabled = false;
53 initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3; 54 initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3;
54 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1; 55 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1;
55 56
56 scoped_refptr<MockSSLConfigService> mock_service( 57 scoped_refptr<MockSSLConfigService> mock_service(
57 new MockSSLConfigService(initial_config)); 58 new MockSSLConfigService(initial_config));
58 MockSSLConfigServiceObserver observer; 59 MockSSLConfigServiceObserver observer;
59 mock_service->AddObserver(&observer); 60 mock_service->AddObserver(&observer);
60 61
61 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(0); 62 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(0);
62 mock_service->SetSSLConfig(initial_config); 63 mock_service->SetSSLConfig(initial_config);
63 64
64 mock_service->RemoveObserver(&observer); 65 mock_service->RemoveObserver(&observer);
65 } 66 }
66 67
67 TEST(SSLConfigServiceTest, ConfigUpdatesNotifyObservers) { 68 TEST(SSLConfigServiceTest, ConfigUpdatesNotifyObservers) {
68 SSLConfig initial_config; 69 SSLConfig initial_config;
69 initial_config.rev_checking_enabled = true; 70 initial_config.rev_checking_enabled = true;
71 initial_config.false_start_enabled = false;
70 initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3; 72 initial_config.version_min = SSL_PROTOCOL_VERSION_SSL3;
71 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1; 73 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1;
72 74
73 scoped_refptr<MockSSLConfigService> mock_service( 75 scoped_refptr<MockSSLConfigService> mock_service(
74 new MockSSLConfigService(initial_config)); 76 new MockSSLConfigService(initial_config));
75 MockSSLConfigServiceObserver observer; 77 MockSSLConfigServiceObserver observer;
76 mock_service->AddObserver(&observer); 78 mock_service->AddObserver(&observer);
77 79
78 // Test that the basic boolean preferences trigger updates. 80 // Test that the basic boolean preferences trigger updates.
wtc 2012/08/11 20:50:44 Originally the SSL version range were controlled b
79 initial_config.rev_checking_enabled = false; 81 initial_config.rev_checking_enabled = false;
80 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); 82 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
81 mock_service->SetSSLConfig(initial_config); 83 mock_service->SetSSLConfig(initial_config);
82 84
85 initial_config.false_start_enabled = true;
86 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
87 mock_service->SetSSLConfig(initial_config);
88
89 // Test that changing the SSL version range triggers updates.
83 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1; 90 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1;
84 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); 91 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
85 mock_service->SetSSLConfig(initial_config); 92 mock_service->SetSSLConfig(initial_config);
86 93
87 initial_config.version_max = SSL_PROTOCOL_VERSION_SSL3; 94 initial_config.version_max = SSL_PROTOCOL_VERSION_SSL3;
88 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); 95 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
89 mock_service->SetSSLConfig(initial_config); 96 mock_service->SetSSLConfig(initial_config);
90 97
91 // Test that disabling certain cipher suites triggers an update. 98 // Test that disabling certain cipher suites triggers an update.
92 std::vector<uint16> disabled_ciphers; 99 std::vector<uint16> disabled_ciphers;
(...skipping 15 matching lines...) Expand all
108 // cipher suites disabled, triggers an update. 115 // cipher suites disabled, triggers an update.
109 disabled_ciphers.pop_back(); 116 disabled_ciphers.pop_back();
110 initial_config.disabled_cipher_suites = disabled_ciphers; 117 initial_config.disabled_cipher_suites = disabled_ciphers;
111 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); 118 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1);
112 mock_service->SetSSLConfig(initial_config); 119 mock_service->SetSSLConfig(initial_config);
113 120
114 mock_service->RemoveObserver(&observer); 121 mock_service->RemoveObserver(&observer);
115 } 122 }
116 123
117 } // namespace net 124 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698