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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc

Issue 144983002: Fixed chrome://settings/accounts availability for MP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed proxy_settings_ui. Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
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/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chromeos/login/login_manager_test.h"
9 #include "chrome/browser/chromeos/login/startup_utils.h"
10 #include "chrome/browser/chromeos/login/user_adding_screen.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/ui_test_utils.h"
19 #include "chromeos/chromeos_switches.h"
20 #include "chromeos/settings/cros_settings_names.h"
21 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h"
23 #include "content/public/test/test_utils.h"
24
25 namespace chromeos {
26
27 namespace {
28
29 const char* kTestUsers[] = { "test-user1@gmail.com", "test-user2@gmail.com" };
30
31 } // namespace
32
33 class AccountsOptionsTest : public LoginManagerTest {
34 public:
35 AccountsOptionsTest()
36 : LoginManagerTest(false),
37 device_settings_provider_(NULL) {
38 stub_settings_provider_.Set(kDeviceOwner, base::StringValue(kTestUsers[0]));
39 }
40
41 virtual ~AccountsOptionsTest() {
42 }
43
44 virtual void SetUpOnMainThread() OVERRIDE {
45 LoginManagerTest::SetUpOnMainThread();
46 CrosSettings* settings = CrosSettings::Get();
47 device_settings_provider_ = settings->GetProvider(kDeviceOwner);
48 settings->RemoveSettingsProvider(device_settings_provider_);
49 settings->AddSettingsProvider(&stub_settings_provider_);
50 }
51
52 virtual void CleanUpOnMainThread() OVERRIDE {
53 CrosSettings* settings = CrosSettings::Get();
54 settings->RemoveSettingsProvider(&stub_settings_provider_);
55 settings->AddSettingsProvider(device_settings_provider_);
56 LoginManagerTest::CleanUpOnMainThread();
57 }
58
59 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
60 LoginManagerTest::SetUpCommandLine(command_line);
61 command_line->AppendSwitch(::switches::kMultiProfiles);
62 command_line->AppendSwitch(switches::kForceMultiProfileInTests);
63 }
64
65 protected:
66 void CheckAccountsUI(const User* user, bool is_owner) {
67 Profile* profile = UserManager::Get()->GetProfileByUser(user);
68 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
69 user->email());
70
71 ui_test_utils::BrowserAddedObserver observer;
72 Browser* browser = CreateBrowser(profile);
73 observer.WaitForSingleNewBrowser();
74
75 ui_test_utils::NavigateToURL(browser,
76 GURL("chrome://settings-frame/accounts"));
77 content::WebContents* contents =
78 browser->tab_strip_model()->GetActiveWebContents();
79
80 bool warning_visible;
81 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
82 contents,
83 "var e = document.getElementById('ownerOnlyWarning');"
84 "var visible = e.offsetWidth > 0 && e.offsetHeight > 0;"
85 "window.domAutomationController.send(visible);",
86 &warning_visible));
87 EXPECT_EQ(is_owner, !warning_visible);
88
89 bool guest_option_enabled;
90 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
91 contents,
92 "var e = document.getElementById('allowBwsiCheck');"
93 "window.domAutomationController.send(!e.disabled);",
94 &guest_option_enabled));
95 ASSERT_EQ(is_owner, guest_option_enabled);
96
97 bool user_pods_enabled;
98 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
99 contents,
100 "var e = document.getElementById('showUserNamesCheck');"
101 "window.domAutomationController.send(!e.disabled);",
102 &user_pods_enabled));
103 ASSERT_EQ(is_owner, user_pods_enabled);
104
105 bool whitelist_enabled;
106 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
107 contents,
108 "var e = document.getElementById('useWhitelistCheck');"
109 "window.domAutomationController.send(!e.disabled);",
110 &whitelist_enabled));
111 ASSERT_EQ(is_owner, whitelist_enabled);
112 }
113
114 StubCrosSettingsProvider stub_settings_provider_;
115 CrosSettingsProvider* device_settings_provider_;
116
117 private:
118 DISALLOW_COPY_AND_ASSIGN(AccountsOptionsTest);
119 };
120
121 IN_PROC_BROWSER_TEST_F(AccountsOptionsTest, PRE_MultiProfilesAccountsOptions) {
122 RegisterUser(kTestUsers[0]);
123 RegisterUser(kTestUsers[1]);
124 StartupUtils::MarkOobeCompleted();
125 }
126
127 IN_PROC_BROWSER_TEST_F(AccountsOptionsTest, MultiProfilesAccountsOptions) {
128 LoginUser(kTestUsers[0]);
129 UserAddingScreen::Get()->Start();
130 content::RunAllPendingInMessageLoop();
131 AddUser(kTestUsers[1]);
132
133 UserManager* manager = UserManager::Get();
134 ASSERT_EQ(2u, manager->GetLoggedInUsers().size());
135
136 CheckAccountsUI(manager->FindUser(kTestUsers[0]), true /* is_owner */);
137 CheckAccountsUI(manager->FindUser(kTestUsers[1]), false /* is_owner */);
138 }
139
140 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/components_ui.cc ('k') | chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698