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

Side by Side Diff: chrome/browser/chromeos/policy/consumer_enrollment_handler_factory_unittest.cc

Issue 733613005: Move the notification part out of ConsumerEnrollmentHandler so that it can be reused for unenrollme… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enroll
Patch Set: Added a check for UserManager. Created 6 years, 1 month 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 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/chromeos/policy/consumer_enrollment_handler_factory.h" 5 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/browser_process_platform_part.h" 8 #include "chrome/browser/browser_process_platform_part.h"
9 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 9 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
10 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 10 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
(...skipping 13 matching lines...) Expand all
24 24
25 class ConsumerEnrollmentHandlerFactoryTest : public testing::Test { 25 class ConsumerEnrollmentHandlerFactoryTest : public testing::Test {
26 public: 26 public:
27 ConsumerEnrollmentHandlerFactoryTest() 27 ConsumerEnrollmentHandlerFactoryTest()
28 : fake_service_(new FakeConsumerManagementService()), 28 : fake_service_(new FakeConsumerManagementService()),
29 fake_user_manager_(new chromeos::FakeUserManager()), 29 fake_user_manager_(new chromeos::FakeUserManager()),
30 scoped_user_manager_enabler_(fake_user_manager_), 30 scoped_user_manager_enabler_(fake_user_manager_),
31 testing_profile_manager_(new TestingProfileManager( 31 testing_profile_manager_(new TestingProfileManager(
32 TestingBrowserProcess::GetGlobal())) { 32 TestingBrowserProcess::GetGlobal())) {
33 // Set up FakeConsumerManagementService. 33 // Set up FakeConsumerManagementService.
34 fake_service_->set_status(ConsumerManagementService::STATUS_ENROLLING); 34 fake_service_->SetStatusAndEnrollmentStage(
35 fake_service_->SetEnrollmentStage( 35 ConsumerManagementService::STATUS_ENROLLING,
36 ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED); 36 ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED);
37 37
38 // Inject fake objects. 38 // Inject fake objects.
39 BrowserPolicyConnectorChromeOS* connector = 39 BrowserPolicyConnectorChromeOS* connector =
40 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 40 g_browser_process->platform_part()->browser_policy_connector_chromeos();
41 connector->SetConsumerManagementServiceForTesting( 41 connector->SetConsumerManagementServiceForTesting(
42 make_scoped_ptr(fake_service_)); 42 make_scoped_ptr(fake_service_));
43 43
44 // Set up FakeUserManager. 44 // Set up FakeUserManager.
45 fake_user_manager_->AddUser(kTestOwner); 45 fake_user_manager_->AddUser(kTestOwner);
(...skipping 16 matching lines...) Expand all
62 EXPECT_TRUE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 62 EXPECT_TRUE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
63 } 63 }
64 64
65 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsNotCreatedForNonOwner) { 65 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsNotCreatedForNonOwner) {
66 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestUser); 66 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestUser);
67 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 67 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
68 } 68 }
69 69
70 TEST_F(ConsumerEnrollmentHandlerFactoryTest, 70 TEST_F(ConsumerEnrollmentHandlerFactoryTest,
71 ServiceIsNotCreatedIfItHasNothingToDo) { 71 ServiceIsNotCreatedIfItHasNothingToDo) {
72 fake_service_->set_status(ConsumerManagementService::STATUS_UNENROLLED); 72 fake_service_->SetStatusAndEnrollmentStage(
73 fake_service_->SetEnrollmentStage( 73 ConsumerManagementService::STATUS_UNENROLLED,
74 ConsumerManagementService::ENROLLMENT_STAGE_NONE); 74 ConsumerManagementService::ENROLLMENT_STAGE_NONE);
75 75
76 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner); 76 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner);
77 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 77 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
78 } 78 }
79 79
80 } // namespace policy 80 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698