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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 7 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 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_chrome_user_manager.h" 9 #include "chrome/browser/chromeos/login/users/fake_chrome_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"
11 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 11 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
12 #include "chrome/browser/chromeos/policy/consumer_management_service.h" 12 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
13 #include "chrome/browser/chromeos/policy/consumer_management_stage.h" 13 #include "chrome/browser/chromeos/policy/consumer_management_stage.h"
14 #include "chrome/browser/chromeos/policy/fake_consumer_management_service.h" 14 #include "chrome/browser/chromeos/policy/fake_consumer_management_service.h"
15 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile_manager.h" 16 #include "chrome/test/base/testing_profile_manager.h"
17 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace { 20 namespace {
20 const char* kTestOwner = "test.owner@chromium.org.test"; 21 const char* kTestOwner = "test.owner@chromium.org.test";
21 const char* kTestUser = "test.user@chromium.org.test"; 22 const char* kTestUser = "test.user@chromium.org.test";
22 } 23 }
23 24
24 namespace policy { 25 namespace policy {
25 26
26 class ConsumerEnrollmentHandlerFactoryTest : public testing::Test { 27 class ConsumerEnrollmentHandlerFactoryTest : public testing::Test {
(...skipping 18 matching lines...) Expand all
45 // Set up FakeChromeUserManager. 46 // Set up FakeChromeUserManager.
46 fake_user_manager_->AddUser(kTestOwner); 47 fake_user_manager_->AddUser(kTestOwner);
47 fake_user_manager_->AddUser(kTestUser); 48 fake_user_manager_->AddUser(kTestUser);
48 fake_user_manager_->set_owner_email(kTestOwner); 49 fake_user_manager_->set_owner_email(kTestOwner);
49 } 50 }
50 51
51 void SetUp() override { 52 void SetUp() override {
52 ASSERT_TRUE(testing_profile_manager_->SetUp()); 53 ASSERT_TRUE(testing_profile_manager_->SetUp());
53 } 54 }
54 55
56 content::TestBrowserThreadBundle thread_bundle_;
55 FakeConsumerManagementService* fake_service_; 57 FakeConsumerManagementService* fake_service_;
56 chromeos::FakeChromeUserManager* fake_user_manager_; 58 chromeos::FakeChromeUserManager* fake_user_manager_;
57 chromeos::ScopedUserManagerEnabler scoped_user_manager_enabler_; 59 chromeos::ScopedUserManagerEnabler scoped_user_manager_enabler_;
58 scoped_ptr<TestingProfileManager> testing_profile_manager_; 60 scoped_ptr<TestingProfileManager> testing_profile_manager_;
59 }; 61 };
60 62
61 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsCreated) { 63 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsCreated) {
62 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner); 64 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner);
63 EXPECT_TRUE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 65 EXPECT_TRUE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
64 } 66 }
65 67
66 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsNotCreatedForNonOwner) { 68 TEST_F(ConsumerEnrollmentHandlerFactoryTest, ServiceIsNotCreatedForNonOwner) {
67 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestUser); 69 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestUser);
68 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 70 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
69 } 71 }
70 72
71 TEST_F(ConsumerEnrollmentHandlerFactoryTest, 73 TEST_F(ConsumerEnrollmentHandlerFactoryTest,
72 ServiceIsNotCreatedIfItHasNothingToDo) { 74 ServiceIsNotCreatedIfItHasNothingToDo) {
73 fake_service_->SetStatusAndStage( 75 fake_service_->SetStatusAndStage(
74 ConsumerManagementService::STATUS_UNENROLLED, 76 ConsumerManagementService::STATUS_UNENROLLED,
75 ConsumerManagementStage::None()); 77 ConsumerManagementStage::None());
76 78
77 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner); 79 Profile* profile = testing_profile_manager_->CreateTestingProfile(kTestOwner);
78 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile)); 80 EXPECT_FALSE(ConsumerEnrollmentHandlerFactory::GetForBrowserContext(profile));
79 } 81 }
80 82
81 } // namespace policy 83 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698