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

Side by Side Diff: chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc

Issue 2084153003: Remove the test-only X509Certificate constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/ash/session_state_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" 14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" 16 #include "chrome/browser/chromeos/policy/policy_cert_service.h"
17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
18 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" 18 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" 19 #include "chrome/browser/chromeos/profiles/profile_helper.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/testing_browser_process.h" 21 #include "chrome/test/base/testing_browser_process.h"
22 #include "chrome/test/base/testing_profile_manager.h" 22 #include "chrome/test/base/testing_profile_manager.h"
23 #include "components/signin/core/account_id/account_id.h" 23 #include "components/signin/core/account_id/account_id.h"
24 #include "components/user_manager/user_manager.h" 24 #include "components/user_manager/user_manager.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "net/cert/x509_certificate.h" 26 #include "net/cert/x509_certificate.h"
27 #include "net/test/cert_test_util.h"
28 #include "net/test/test_data_directory.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 30
29 namespace chromeos { 31 namespace chromeos {
30 32
31 namespace { 33 namespace {
32 34
33 const char* kUser = "user@test.com"; 35 const char* kUser = "user@test.com";
34 36
35 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once 37 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once
36 // we've ensured the profile has been shut down. 38 // we've ensured the profile has been shut down.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 g_policy_cert_verifier_for_factory = cert_verifier_.get(); 218 g_policy_cert_verifier_for_factory = cert_verifier_.get();
217 ASSERT_TRUE( 219 ASSERT_TRUE(
218 policy::PolicyCertServiceFactory::GetInstance()->SetTestingFactoryAndUse( 220 policy::PolicyCertServiceFactory::GetInstance()->SetTestingFactoryAndUse(
219 user_profile_, CreateTestPolicyCertService)); 221 user_profile_, CreateTestPolicyCertService));
220 policy::PolicyCertService* service = 222 policy::PolicyCertService* service =
221 policy::PolicyCertServiceFactory::GetForProfile(user_profile_); 223 policy::PolicyCertServiceFactory::GetForProfile(user_profile_);
222 ASSERT_TRUE(service); 224 ASSERT_TRUE(service);
223 225
224 EXPECT_FALSE(service->has_policy_certificates()); 226 EXPECT_FALSE(service->has_policy_certificates());
225 net::CertificateList certificates; 227 net::CertificateList certificates;
226 certificates.push_back(new net::X509Certificate( 228 certificates.push_back(
227 "subject", "issuer", base::Time(), base::Time())); 229 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"));
228 service->OnTrustAnchorsChanged(certificates); 230 service->OnTrustAnchorsChanged(certificates);
229 EXPECT_TRUE(service->has_policy_certificates()); 231 EXPECT_TRUE(service->has_policy_certificates());
230 EXPECT_FALSE( 232 EXPECT_FALSE(
231 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy()); 233 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy());
232 234
233 // Flush tasks posted to IO. 235 // Flush tasks posted to IO.
234 base::RunLoop().RunUntilIdle(); 236 base::RunLoop().RunUntilIdle();
235 } 237 }
236 238
237 // Make sure adding users to multiprofiles disabled by reaching maximum 239 // Make sure adding users to multiprofiles disabled by reaching maximum
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 prefs::kMultiProfileUserBehavior, 289 prefs::kMultiProfileUserBehavior,
288 chromeos::MultiProfileUserController::kBehaviorNotAllowed); 290 chromeos::MultiProfileUserController::kBehaviorNotAllowed);
289 user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b")); 291 user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b"));
290 EXPECT_FALSE( 292 EXPECT_FALSE(
291 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); 293 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error));
292 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, 294 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER,
293 add_user_error); 295 add_user_error);
294 } 296 }
295 297
296 } // namespace chromeos 298 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698