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

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

Issue 2230533002: Delete dead consumer enrollment code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/policy/consumer_management_notifier_factory.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/browser_process_platform_part.h"
10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
12 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
13 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
14 #include "chrome/browser/chromeos/policy/consumer_management_stage.h"
15 #include "chrome/browser/chromeos/policy/fake_consumer_management_service.h"
16 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/testing_profile_manager.h"
18 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 namespace {
22 const char* kTestOwner = "test.owner@chromium.org.test";
23 const char* kTestUser = "test.user@chromium.org.test";
24 }
25
26 namespace policy {
27
28 class ConsumerManagementNotifierFactoryTest : public testing::Test {
29 public:
30 ConsumerManagementNotifierFactoryTest()
31 : fake_service_(new FakeConsumerManagementService()),
32 fake_user_manager_(new chromeos::FakeChromeUserManager()),
33 scoped_user_manager_enabler_(fake_user_manager_),
34 testing_profile_manager_(
35 new TestingProfileManager(TestingBrowserProcess::GetGlobal())) {
36 // Set up FakeConsumerManagementService.
37 fake_service_->SetStatusAndStage(
38 ConsumerManagementService::STATUS_UNENROLLED,
39 ConsumerManagementStage::None());
40
41 // Inject fake objects.
42 BrowserPolicyConnectorChromeOS* connector =
43 g_browser_process->platform_part()->browser_policy_connector_chromeos();
44 connector->SetConsumerManagementServiceForTesting(
45 base::WrapUnique(fake_service_));
46
47 // Set up FakeChromeUserManager.
48 fake_user_manager_->AddUser(AccountId::FromUserEmail(kTestOwner));
49 fake_user_manager_->AddUser(AccountId::FromUserEmail(kTestUser));
50 fake_user_manager_->set_owner_id(AccountId::FromUserEmail(kTestOwner));
51 }
52
53 void SetUp() override {
54 ASSERT_TRUE(testing_profile_manager_->SetUp());
55 }
56
57 content::TestBrowserThreadBundle thread_bundle_;
58 FakeConsumerManagementService* fake_service_;
59 chromeos::FakeChromeUserManager* fake_user_manager_;
60 chromeos::ScopedUserManagerEnabler scoped_user_manager_enabler_;
61 std::unique_ptr<TestingProfileManager> testing_profile_manager_;
62 };
63
64 TEST_F(ConsumerManagementNotifierFactoryTest, ServiceIsCreated) {
65 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner);
66 EXPECT_TRUE(
67 ConsumerManagementNotifierFactory::GetForBrowserContext(profile));
68 }
69
70 TEST_F(ConsumerManagementNotifierFactoryTest,
71 ServiceIsNotCreatedForNonOwner) {
72 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestUser);
73 EXPECT_FALSE(
74 ConsumerManagementNotifierFactory::GetForBrowserContext(profile));
75 }
76
77 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698