| OLD | NEW |
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "chrome/browser/chromeos/login/user_manager.h" | 7 #include "chrome/browser/chromeos/login/user_manager.h" |
| 8 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 8 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 9 #include "chrome/browser/chromeos/settings/cros_settings.h" | 9 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 10 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 11 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 11 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "content/public/browser/notification_service.h" | |
| 15 #include "content/public/test/mock_notification_observer.h" | |
| 16 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 17 |
| 20 namespace em = enterprise_management; | 18 namespace em = enterprise_management; |
| 21 | 19 |
| 22 namespace chromeos { | 20 namespace chromeos { |
| 23 | 21 |
| 24 class LoginScreenPolicyTest : public policy::DevicePolicyCrosBrowserTest { | 22 class LoginScreenPolicyTest : public policy::DevicePolicyCrosBrowserTest { |
| 25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 23 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 26 command_line->AppendSwitch(switches::kLoginManager); | 24 command_line->AppendSwitch(switches::kLoginManager); |
| 27 command_line->AppendSwitch(::switches::kEnableManagedUsers); | 25 command_line->AppendSwitch(::switches::kEnableManagedUsers); |
| 28 } | 26 } |
| 29 | 27 |
| 30 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 28 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 31 InstallOwnerKey(); | 29 InstallOwnerKey(); |
| 32 MarkAsEnterpriseOwned(); | 30 MarkAsEnterpriseOwned(); |
| 33 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); | 31 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 34 } | 32 } |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, DisableSupervisedUsers) { | 35 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, DisableSupervisedUsers) { |
| 38 EXPECT_FALSE(chromeos::UserManager::Get()->AreLocallyManagedUsersAllowed()); | 36 EXPECT_FALSE(chromeos::UserManager::Get()->AreLocallyManagedUsersAllowed()); |
| 39 | 37 |
| 40 content::WindowedNotificationObserver windowed_observer( | 38 scoped_refptr<content::MessageLoopRunner> runner( |
| 41 chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, | 39 new content::MessageLoopRunner); |
| 42 content::NotificationService::AllSources()); | 40 scoped_ptr<CrosSettings::ObserverSubscription> subscription( |
| 43 chromeos::CrosSettings::Get()->AddSettingsObserver( | 41 chromeos::CrosSettings::Get()->AddSettingsObserver( |
| 44 chromeos::kAccountsPrefSupervisedUsersEnabled, &windowed_observer); | 42 chromeos::kAccountsPrefSupervisedUsersEnabled, |
| 43 runner->QuitClosure())); |
| 44 |
| 45 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 45 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
| 46 proto.mutable_supervised_users_settings()->set_supervised_users_enabled(true); | 46 proto.mutable_supervised_users_settings()->set_supervised_users_enabled(true); |
| 47 RefreshDevicePolicy(); | 47 RefreshDevicePolicy(); |
| 48 windowed_observer.Wait(); | 48 |
| 49 runner->Run(); |
| 49 | 50 |
| 50 EXPECT_TRUE(chromeos::UserManager::Get()->AreLocallyManagedUsersAllowed()); | 51 EXPECT_TRUE(chromeos::UserManager::Get()->AreLocallyManagedUsersAllowed()); |
| 51 | |
| 52 chromeos::CrosSettings::Get()->RemoveSettingsObserver( | |
| 53 chromeos::kAccountsPrefSupervisedUsersEnabled, &windowed_observer); | |
| 54 } | 52 } |
| 55 | 53 |
| 56 } // namespace chromeos | 54 } // namespace chromeos |
| OLD | NEW |