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

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

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/chromeos/login/login_manager_test.h" 9 #include "chrome/browser/chromeos/login/login_manager_test.h"
10 #include "chrome/browser/chromeos/login/startup_utils.h" 10 #include "chrome/browser/chromeos/login/startup_utils.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 { kStatsReportingPref, true, true }, 79 { kStatsReportingPref, true, true },
80 { prefs::kSpellCheckUseSpellingService, false, false }, 80 { prefs::kSpellCheckUseSpellingService, false, false },
81 #endif 81 #endif
82 }; 82 };
83 83
84 } // namespace 84 } // namespace
85 85
86 class SharedOptionsTest : public LoginManagerTest { 86 class SharedOptionsTest : public LoginManagerTest {
87 public: 87 public:
88 SharedOptionsTest() 88 SharedOptionsTest()
89 : LoginManagerTest(false), 89 : LoginManagerTest(false),
90 device_settings_provider_(NULL) { 90 device_settings_provider_(NULL),
91 test_owner_account_id_(AccountId::FromUserEmail(kTestOwner)),
92 test_non_owner_account_id_(AccountId::FromUserEmail(kTestNonOwner)) {
91 stub_settings_provider_.Set(kDeviceOwner, base::StringValue(kTestOwner)); 93 stub_settings_provider_.Set(kDeviceOwner, base::StringValue(kTestOwner));
92 } 94 }
93 95
94 ~SharedOptionsTest() override {} 96 ~SharedOptionsTest() override {}
95 97
96 void SetUpOnMainThread() override { 98 void SetUpOnMainThread() override {
97 LoginManagerTest::SetUpOnMainThread(); 99 LoginManagerTest::SetUpOnMainThread();
98 100
99 CrosSettings* settings = CrosSettings::Get(); 101 CrosSettings* settings = CrosSettings::Get();
100 102
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 !is_owner); 261 !is_owner);
260 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 262 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
261 contents, js_expression, &success)); 263 contents, js_expression, &success));
262 EXPECT_TRUE(success) << "Accounts overlay incorrect for " << 264 EXPECT_TRUE(success) << "Accounts overlay incorrect for " <<
263 (is_owner ? "owner." : "non-owner."); 265 (is_owner ? "owner." : "non-owner.");
264 } 266 }
265 267
266 StubAccountSettingsProvider stub_settings_provider_; 268 StubAccountSettingsProvider stub_settings_provider_;
267 CrosSettingsProvider* device_settings_provider_; 269 CrosSettingsProvider* device_settings_provider_;
268 270
271 const AccountId test_owner_account_id_;
272 const AccountId test_non_owner_account_id_;
273
269 private: 274 private:
270 DISALLOW_COPY_AND_ASSIGN(SharedOptionsTest); 275 DISALLOW_COPY_AND_ASSIGN(SharedOptionsTest);
271 }; 276 };
272 277
273 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_SharedOptions) { 278 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_SharedOptions) {
274 RegisterUser(kTestOwner); 279 RegisterUser(test_owner_account_id_.GetUserEmail());
275 RegisterUser(kTestNonOwner); 280 RegisterUser(test_non_owner_account_id_.GetUserEmail());
276 StartupUtils::MarkOobeCompleted(); 281 StartupUtils::MarkOobeCompleted();
277 } 282 }
278 283
279 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, SharedOptions) { 284 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, SharedOptions) {
280 // Log in the owner first, then add a secondary user. 285 // Log in the owner first, then add a secondary user.
281 LoginUser(kTestOwner); 286 LoginUser(test_owner_account_id_.GetUserEmail());
282 UserAddingScreen::Get()->Start(); 287 UserAddingScreen::Get()->Start();
283 content::RunAllPendingInMessageLoop(); 288 content::RunAllPendingInMessageLoop();
284 AddUser(kTestNonOwner); 289 AddUser(test_non_owner_account_id_.GetUserEmail());
285 290
286 user_manager::UserManager* manager = user_manager::UserManager::Get(); 291 user_manager::UserManager* manager = user_manager::UserManager::Get();
287 ASSERT_EQ(2u, manager->GetLoggedInUsers().size()); 292 ASSERT_EQ(2u, manager->GetLoggedInUsers().size());
288 { 293 {
289 SCOPED_TRACE("Checking settings for owner, primary user."); 294 SCOPED_TRACE("Checking settings for owner, primary user.");
290 CheckOptionsUI(manager->FindUser(manager->GetOwnerEmail()), true, true); 295 CheckOptionsUI(manager->FindUser(manager->GetOwnerAccountId()), true, true);
291 } 296 }
292 { 297 {
293 SCOPED_TRACE("Checking settings for non-owner, secondary user."); 298 SCOPED_TRACE("Checking settings for non-owner, secondary user.");
294 CheckOptionsUI(manager->FindUser(kTestNonOwner), false, false); 299 CheckOptionsUI(manager->FindUser(test_non_owner_account_id_), false, false);
295 } 300 }
296 // TODO(michaelpg): Add tests for non-primary owner and primary non-owner 301 // TODO(michaelpg): Add tests for non-primary owner and primary non-owner
297 // when the owner-only multiprofile restriction is removed, probably M38. 302 // when the owner-only multiprofile restriction is removed, probably M38.
298 } 303 }
299 304
300 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_ScreenLockPreferencePrimary) { 305 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_ScreenLockPreferencePrimary) {
301 RegisterUser(kTestOwner); 306 RegisterUser(test_owner_account_id_.GetUserEmail());
302 RegisterUser(kTestNonOwner); 307 RegisterUser(test_non_owner_account_id_.GetUserEmail());
303 StartupUtils::MarkOobeCompleted(); 308 StartupUtils::MarkOobeCompleted();
304 } 309 }
305 310
306 // Tests the shared setting indicator for the primary user's auto-lock setting 311 // Tests the shared setting indicator for the primary user's auto-lock setting
307 // when the secondary user has enabled or disabled their preference. 312 // when the secondary user has enabled or disabled their preference.
308 // (The checkbox is unset if the current user's preference is false, but if any 313 // (The checkbox is unset if the current user's preference is false, but if any
309 // other signed-in user has enabled this preference, the shared setting 314 // other signed-in user has enabled this preference, the shared setting
310 // indicator explains this.) 315 // indicator explains this.)
311 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) { 316 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) {
312 LoginUser(kTestOwner); 317 LoginUser(test_owner_account_id_.GetUserEmail());
313 UserAddingScreen::Get()->Start(); 318 UserAddingScreen::Get()->Start();
314 content::RunAllPendingInMessageLoop(); 319 content::RunAllPendingInMessageLoop();
315 AddUser(kTestNonOwner); 320 AddUser(test_non_owner_account_id_.GetUserEmail());
316 321
317 user_manager::UserManager* manager = user_manager::UserManager::Get(); 322 user_manager::UserManager* manager = user_manager::UserManager::Get();
318 const user_manager::User* user1 = manager->FindUser(kTestOwner); 323 const user_manager::User* user1 = manager->FindUser(test_owner_account_id_);
319 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); 324 const user_manager::User* user2 =
325 manager->FindUser(test_non_owner_account_id_);
320 326
321 PrefService* prefs1 = 327 PrefService* prefs1 =
322 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); 328 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs();
323 PrefService* prefs2 = 329 PrefService* prefs2 =
324 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); 330 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs();
325 331
326 // Set both users' preference to false, then change the secondary user's to 332 // Set both users' preference to false, then change the secondary user's to
327 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage 333 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage
328 // but reloading the settings page is super slow on debug builds. 334 // but reloading the settings page is super slow on debug builds.
329 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false); 335 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true); 368 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true);
363 { 369 {
364 SCOPED_TRACE("Screen lock true for both users"); 370 SCOPED_TRACE("Screen lock true for both users");
365 expected_value = true; 371 expected_value = true;
366 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, 372 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled,
367 empty_controlled, expected_value); 373 empty_controlled, expected_value);
368 } 374 }
369 } 375 }
370 376
371 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_ScreenLockPreferenceSecondary) { 377 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_ScreenLockPreferenceSecondary) {
372 RegisterUser(kTestOwner); 378 RegisterUser(test_owner_account_id_.GetUserEmail());
373 RegisterUser(kTestNonOwner); 379 RegisterUser(test_non_owner_account_id_.GetUserEmail());
374 StartupUtils::MarkOobeCompleted(); 380 StartupUtils::MarkOobeCompleted();
375 } 381 }
376 382
377 // Tests the shared setting indicator for the secondary user's auto-lock setting 383 // Tests the shared setting indicator for the secondary user's auto-lock setting
378 // when the primary user has enabled or disabled their preference. 384 // when the primary user has enabled or disabled their preference.
379 // (The checkbox is unset if the current user's preference is false, but if any 385 // (The checkbox is unset if the current user's preference is false, but if any
380 // other signed-in user has enabled this preference, the shared setting 386 // other signed-in user has enabled this preference, the shared setting
381 // indicator explains this.) 387 // indicator explains this.)
382 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) { 388 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) {
383 LoginUser(kTestOwner); 389 LoginUser(test_owner_account_id_.GetUserEmail());
384 UserAddingScreen::Get()->Start(); 390 UserAddingScreen::Get()->Start();
385 content::RunAllPendingInMessageLoop(); 391 content::RunAllPendingInMessageLoop();
386 AddUser(kTestNonOwner); 392 AddUser(test_non_owner_account_id_.GetUserEmail());
387 393
388 user_manager::UserManager* manager = user_manager::UserManager::Get(); 394 user_manager::UserManager* manager = user_manager::UserManager::Get();
389 const user_manager::User* user1 = manager->FindUser(kTestOwner); 395 const user_manager::User* user1 = manager->FindUser(test_owner_account_id_);
390 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); 396 const user_manager::User* user2 =
397 manager->FindUser(test_non_owner_account_id_);
391 398
392 PrefService* prefs1 = 399 PrefService* prefs1 =
393 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); 400 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs();
394 PrefService* prefs2 = 401 PrefService* prefs2 =
395 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); 402 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs();
396 403
397 // Set both users' preference to true, then change the secondary user's to 404 // Set both users' preference to true, then change the secondary user's to
398 // false. 405 // false.
399 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true); 406 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true);
400 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true); 407 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 content::WaitForLoadStop(contents); 439 content::WaitForLoadStop(contents);
433 { 440 {
434 SCOPED_TRACE("Screen lock false for both users"); 441 SCOPED_TRACE("Screen lock false for both users");
435 expected_value = false; 442 expected_value = false;
436 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, 443 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled,
437 empty_controlled, expected_value); 444 empty_controlled, expected_value);
438 } 445 }
439 } 446 }
440 447
441 } // namespace chromeos 448 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698