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

Side by Side Diff: components/ssl_config/ssl_config_service_manager_pref_unittest.cc

Issue 2226063002: Add a ScopedFeatureList class for testing and start using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in previous patchset. Created 4 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
« no previous file with comments | « components/ssl_config/BUILD.gn ('k') | components/subresource_filter/core/browser/BUILD.gn » ('j') | 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/scoped_feature_list.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "components/prefs/testing_pref_service.h" 15 #include "components/prefs/testing_pref_service.h"
15 #include "components/ssl_config/ssl_config_prefs.h" 16 #include "components/ssl_config/ssl_config_prefs.h"
16 #include "components/ssl_config/ssl_config_service_manager.h" 17 #include "components/ssl_config/ssl_config_service_manager.h"
17 #include "components/ssl_config/ssl_config_switches.h" 18 #include "components/ssl_config/ssl_config_switches.h"
18 #include "net/ssl/ssl_config.h" 19 #include "net/ssl/ssl_config.h"
19 #include "net/ssl/ssl_config_service.h" 20 #include "net/ssl/ssl_config_service.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 175
175 SSLConfig ssl_config; 176 SSLConfig ssl_config;
176 config_service->GetSSLConfig(&ssl_config); 177 config_service->GetSSLConfig(&ssl_config);
177 // The command-line option must not have been honored. 178 // The command-line option must not have been honored.
178 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); 179 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min);
179 } 180 }
180 181
181 // Tests that DHE may be re-enabled via features. 182 // Tests that DHE may be re-enabled via features.
182 TEST_F(SSLConfigServiceManagerPrefTest, DHEFeature) { 183 TEST_F(SSLConfigServiceManagerPrefTest, DHEFeature) {
183 // Toggle the feature. 184 // Toggle the feature.
184 base::FeatureList::ClearInstanceForTesting(); 185 base::test::ScopedFeatureList scoped_feature_list;
185 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 186 scoped_feature_list.InitFromCommandLine("DHECiphers", std::string());
186 feature_list->InitializeFromCommandLine("DHECiphers", std::string());
187 base::FeatureList::SetInstance(std::move(feature_list));
188 187
189 TestingPrefServiceSimple local_state; 188 TestingPrefServiceSimple local_state;
190 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); 189 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
191 190
192 std::unique_ptr<SSLConfigServiceManager> config_manager( 191 std::unique_ptr<SSLConfigServiceManager> config_manager(
193 SSLConfigServiceManager::CreateDefaultManager( 192 SSLConfigServiceManager::CreateDefaultManager(
194 &local_state, base::ThreadTaskRunnerHandle::Get())); 193 &local_state, base::ThreadTaskRunnerHandle::Get()));
195 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 194 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
196 ASSERT_TRUE(config_service.get()); 195 ASSERT_TRUE(config_service.get());
197 196
198 // The feature should have switched the default version_fallback_min value. 197 // The feature should have switched the default version_fallback_min value.
199 SSLConfig ssl_config; 198 SSLConfig ssl_config;
200 config_service->GetSSLConfig(&ssl_config); 199 config_service->GetSSLConfig(&ssl_config);
201 EXPECT_TRUE(ssl_config.dhe_enabled); 200 EXPECT_TRUE(ssl_config.dhe_enabled);
202 } 201 }
OLDNEW
« no previous file with comments | « components/ssl_config/BUILD.gn ('k') | components/subresource_filter/core/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698