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

Side by Side Diff: chrome/browser/chromeos/login/login_screen_policy_browsertest.cc

Issue 2816543004: Login screen IME policy does not apply in user session (Closed)
Patch Set: Fixed browsertests. Created 3 years, 8 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 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 "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/login/login_wizard.h"
9 #include "chrome/browser/chromeos/login/startup_utils.h" 10 #include "chrome/browser/chromeos/login/startup_utils.h"
11 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 12 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
11 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 13 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
15 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
16 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
17 #include "chromeos/settings/cros_settings_names.h" 19 #include "chromeos/settings/cros_settings_names.h"
20 #include "components/prefs/pref_service.h"
21 #include "components/prefs/scoped_user_pref_update.h"
18 #include "components/user_manager/user_manager.h" 22 #include "components/user_manager/user_manager.h"
19 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/base/ime/chromeos/input_method_manager.h" 25 #include "ui/base/ime/chromeos/input_method_manager.h"
22 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
24 28
25 namespace em = enterprise_management; 29 namespace em = enterprise_management;
26 30
31 namespace {
32 const char kTestUser[] = "test-user@example.com";
33 } // namespace
34
27 namespace chromeos { 35 namespace chromeos {
28 36
29 class LoginScreenPolicyTest : public policy::DevicePolicyCrosBrowserTest { 37 class LoginScreenPolicyTest : public policy::DevicePolicyCrosBrowserTest {
30 public: 38 public:
31 void RefreshDevicePolicyAndWaitForSettingChange( 39 void RefreshDevicePolicyAndWaitForSettingChange(
32 const char* cros_setting_name); 40 const char* cros_setting_name);
33 41
34 protected: 42 protected:
35 void SetUpCommandLine(base::CommandLine* command_line) override { 43 void SetUpCommandLine(base::CommandLine* command_line) override {
36 command_line->AppendSwitch(switches::kLoginManager); 44 command_line->AppendSwitch(switches::kLoginManager);
37 command_line->AppendSwitch(switches::kForceLoginManagerInTests); 45 command_line->AppendSwitch(switches::kForceLoginManagerInTests);
38 } 46 }
39 47
48 void SetUpOnMainThread() override {
49 policy::DevicePolicyCrosBrowserTest::SetUpOnMainThread();
50 }
51
40 void SetUpInProcessBrowserTestFixture() override { 52 void SetUpInProcessBrowserTestFixture() override {
41 InstallOwnerKey(); 53 InstallOwnerKey();
42 MarkAsEnterpriseOwned(); 54 MarkAsEnterpriseOwned();
43 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); 55 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture();
44 } 56 }
45 57
46 void TearDownOnMainThread() override { 58 void TearDownOnMainThread() override {
47 // This shuts down the login UI. 59 // This shuts down the login UI.
48 base::ThreadTaskRunnerHandle::Get()->PostTask( 60 base::ThreadTaskRunnerHandle::Get()->PostTask(
49 FROM_HERE, base::Bind(&chrome::AttemptExit)); 61 FROM_HERE, base::Bind(&chrome::AttemptExit));
50 base::RunLoop().RunUntilIdle(); 62 base::RunLoop().RunUntilIdle();
51 } 63 }
64
65 void RegisterUser(const std::string& user_id) {
66 ListPrefUpdate users_pref(g_browser_process->local_state(),
67 "LoggedInUsers");
68 users_pref->AppendIfNotPresent(base::MakeUnique<base::Value>(user_id));
69 }
52 }; 70 };
53 71
54 void LoginScreenPolicyTest::RefreshDevicePolicyAndWaitForSettingChange( 72 void LoginScreenPolicyTest::RefreshDevicePolicyAndWaitForSettingChange(
55 const char* cros_setting_name) { 73 const char* cros_setting_name) {
56 scoped_refptr<content::MessageLoopRunner> runner( 74 scoped_refptr<content::MessageLoopRunner> runner(
57 new content::MessageLoopRunner); 75 new content::MessageLoopRunner);
58 std::unique_ptr<CrosSettings::ObserverSubscription> subscription( 76 std::unique_ptr<CrosSettings::ObserverSubscription> subscription(
59 chromeos::CrosSettings::Get()->AddSettingsObserver( 77 chromeos::CrosSettings::Get()->AddSettingsObserver(
60 cros_setting_name, runner->QuitClosure())); 78 cros_setting_name, runner->QuitClosure()));
61 79
62 RefreshDevicePolicy(); 80 RefreshDevicePolicy();
63 runner->Run(); 81 runner->Run();
64 } 82 }
65 83
66 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, DisableSupervisedUsers) { 84 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, DisableSupervisedUsers) {
67 EXPECT_FALSE(user_manager::UserManager::Get()->AreSupervisedUsersAllowed()); 85 EXPECT_FALSE(user_manager::UserManager::Get()->AreSupervisedUsersAllowed());
68 86
69 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 87 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
70 proto.mutable_supervised_users_settings()->set_supervised_users_enabled(true); 88 proto.mutable_supervised_users_settings()->set_supervised_users_enabled(true);
71 RefreshDevicePolicyAndWaitForSettingChange( 89 RefreshDevicePolicyAndWaitForSettingChange(
72 chromeos::kAccountsPrefSupervisedUsersEnabled); 90 chromeos::kAccountsPrefSupervisedUsersEnabled);
73 91
74 EXPECT_TRUE(user_manager::UserManager::Get()->AreSupervisedUsersAllowed()); 92 EXPECT_TRUE(user_manager::UserManager::Get()->AreSupervisedUsersAllowed());
75 } 93 }
76 94
95 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, PRE_RestrictInputMethods) {
96 RegisterUser(kTestUser);
97 StartupUtils::MarkOobeCompleted();
98 }
99
77 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, RestrictInputMethods) { 100 IN_PROC_BROWSER_TEST_F(LoginScreenPolicyTest, RestrictInputMethods) {
101 ShowLoginWizard(OobeScreen::SCREEN_SPECIAL_LOGIN);
102 OobeScreenWaiter(OobeScreen::SCREEN_ACCOUNT_PICKER).Wait();
103
78 input_method::InputMethodManager* imm = 104 input_method::InputMethodManager* imm =
79 input_method::InputMethodManager::Get(); 105 input_method::InputMethodManager::Get();
80 ASSERT_TRUE(imm); 106 ASSERT_TRUE(imm);
81 107
82 ASSERT_EQ(0U, imm->GetActiveIMEState()->GetAllowedInputMethods().size()); 108 ASSERT_EQ(0U, imm->GetActiveIMEState()->GetAllowedInputMethods().size());
83 109
84 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 110 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
85 proto.mutable_login_screen_input_methods()->add_login_screen_input_methods( 111 proto.mutable_login_screen_input_methods()->add_login_screen_input_methods(
86 "xkb:de::ger"); 112 "xkb:de::ger");
87 RefreshDevicePolicyAndWaitForSettingChange( 113 RefreshDevicePolicyAndWaitForSettingChange(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Make sure this is really French and differs from the English title. 152 // Make sure this is really French and differs from the English title.
127 std::string loaded = 153 std::string loaded =
128 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("en-US"); 154 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("en-US");
129 EXPECT_EQ("en-US", loaded); 155 EXPECT_EQ("en-US", loaded);
130 base::string16 english_title = 156 base::string16 english_title =
131 l10n_util::GetStringUTF16(IDS_LOGIN_POD_SIGNING_IN); 157 l10n_util::GetStringUTF16(IDS_LOGIN_POD_SIGNING_IN);
132 EXPECT_NE(french_title, english_title); 158 EXPECT_NE(french_title, english_title);
133 } 159 }
134 160
135 } // namespace chromeos 161 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698