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

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

Issue 445353004: GetProfileByUser deprecated and renamed to GetProfileByUserUnsafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 4 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
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 !is_owner && kPrefTests[i].indicator ? "owner" : 124 !is_owner && kPrefTests[i].indicator ? "owner" :
125 std::string()); 125 std::string());
126 } 126 }
127 CheckBanner(contents, is_primary); 127 CheckBanner(contents, is_primary);
128 CheckSharedSections(contents, is_primary); 128 CheckSharedSections(contents, is_primary);
129 CheckAccountsOverlay(contents, is_owner); 129 CheckAccountsOverlay(contents, is_owner);
130 } 130 }
131 131
132 // Creates a browser and navigates to the Settings page. 132 // Creates a browser and navigates to the Settings page.
133 Browser* CreateBrowserForUser(const user_manager::User* user) { 133 Browser* CreateBrowserForUser(const user_manager::User* user) {
134 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); 134 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user);
135 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 135 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
136 user->email()); 136 user->email());
137 137
138 ui_test_utils::BrowserAddedObserver observer; 138 ui_test_utils::BrowserAddedObserver observer;
139 Browser* browser = CreateBrowser(profile); 139 Browser* browser = CreateBrowser(profile);
140 observer.WaitForSingleNewBrowser(); 140 observer.WaitForSingleNewBrowser();
141 141
142 ui_test_utils::NavigateToURL(browser, 142 ui_test_utils::NavigateToURL(browser,
143 GURL("chrome://settings-frame")); 143 GURL("chrome://settings-frame"));
144 return browser; 144 return browser;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 LoginUser(kTestOwner); 302 LoginUser(kTestOwner);
303 UserAddingScreen::Get()->Start(); 303 UserAddingScreen::Get()->Start();
304 content::RunAllPendingInMessageLoop(); 304 content::RunAllPendingInMessageLoop();
305 AddUser(kTestNonOwner); 305 AddUser(kTestNonOwner);
306 306
307 UserManager* manager = UserManager::Get(); 307 UserManager* manager = UserManager::Get();
308 const user_manager::User* user1 = manager->FindUser(kTestOwner); 308 const user_manager::User* user1 = manager->FindUser(kTestOwner);
309 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); 309 const user_manager::User* user2 = manager->FindUser(kTestNonOwner);
310 310
311 PrefService* prefs1 = 311 PrefService* prefs1 =
312 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); 312 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs();
313 PrefService* prefs2 = 313 PrefService* prefs2 =
314 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); 314 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs();
315 315
316 // Set both users' preference to false, then change the secondary user's to 316 // Set both users' preference to false, then change the secondary user's to
317 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage 317 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage
318 // but reloading the settings page is super slow on debug builds. 318 // but reloading the settings page is super slow on debug builds.
319 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false); 319 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false);
320 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, false); 320 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, false);
321 321
322 Browser* browser = CreateBrowserForUser(user1); 322 Browser* browser = CreateBrowserForUser(user1);
323 content::WebContents* contents = 323 content::WebContents* contents =
324 browser->tab_strip_model()->GetActiveWebContents(); 324 browser->tab_strip_model()->GetActiveWebContents();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 LoginUser(kTestOwner); 373 LoginUser(kTestOwner);
374 UserAddingScreen::Get()->Start(); 374 UserAddingScreen::Get()->Start();
375 content::RunAllPendingInMessageLoop(); 375 content::RunAllPendingInMessageLoop();
376 AddUser(kTestNonOwner); 376 AddUser(kTestNonOwner);
377 377
378 UserManager* manager = UserManager::Get(); 378 UserManager* manager = UserManager::Get();
379 const user_manager::User* user1 = manager->FindUser(kTestOwner); 379 const user_manager::User* user1 = manager->FindUser(kTestOwner);
380 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); 380 const user_manager::User* user2 = manager->FindUser(kTestNonOwner);
381 381
382 PrefService* prefs1 = 382 PrefService* prefs1 =
383 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); 383 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs();
384 PrefService* prefs2 = 384 PrefService* prefs2 =
385 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); 385 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs();
386 386
387 // Set both users' preference to true, then change the secondary user's to 387 // Set both users' preference to true, then change the secondary user's to
388 // false. 388 // false.
389 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true); 389 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true);
390 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true); 390 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true);
391 391
392 Browser* browser = CreateBrowserForUser(user2); 392 Browser* browser = CreateBrowserForUser(user2);
393 content::WebContents* contents = 393 content::WebContents* contents =
394 browser->tab_strip_model()->GetActiveWebContents(); 394 browser->tab_strip_model()->GetActiveWebContents();
395 395
(...skipping 26 matching lines...) Expand all
422 content::WaitForLoadStop(contents); 422 content::WaitForLoadStop(contents);
423 { 423 {
424 SCOPED_TRACE("Screen lock false for both users"); 424 SCOPED_TRACE("Screen lock false for both users");
425 expected_value = false; 425 expected_value = false;
426 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, 426 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled,
427 empty_controlled, expected_value); 427 empty_controlled, expected_value);
428 } 428 }
429 } 429 }
430 430
431 } // namespace chromeos 431 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698