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