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

Side by Side Diff: chrome/browser/profiles/profile_browsertest.cc

Issue 933503004: Always load signin profile on Chrome OS startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes. Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/profiles/profile.h" 5 #include "chrome/browser/profiles/profile.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "base/version.h" 15 #include "base/version.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/profiles/chrome_version_service.h" 19 #include "chrome/browser/profiles/chrome_version_service.h"
19 #include "chrome/browser/profiles/profile_impl.h" 20 #include "chrome/browser/profiles/profile_impl.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/profiles/startup_task_runner_service.h" 22 #include "chrome/browser/profiles/startup_task_runner_service.h"
22 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" 23 #include "chrome/browser/profiles/startup_task_runner_service_factory.h"
23 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_version_info.h" 25 #include "chrome/common/chrome_version_info.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
27 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 base::ScopedTempDir temp_dir; 353 base::ScopedTempDir temp_dir;
353 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 354 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
354 355
355 ProfileManager* profile_manager = g_browser_process->profile_manager(); 356 ProfileManager* profile_manager = g_browser_process->profile_manager();
356 ASSERT_TRUE(profile_manager); 357 ASSERT_TRUE(profile_manager);
357 std::vector<Profile*> loaded_profiles = profile_manager->GetLoadedProfiles(); 358 std::vector<Profile*> loaded_profiles = profile_manager->GetLoadedProfiles();
358 359
359 ASSERT_NE(loaded_profiles.size(), 0UL); 360 ASSERT_NE(loaded_profiles.size(), 0UL);
360 Profile* profile = loaded_profiles[0]; 361 Profile* profile = loaded_profiles[0];
361 362
363 #if defined(OS_CHROMEOS)
364 for (const auto& loaded_profile : loaded_profiles) {
365 if (!chromeos::ProfileHelper::IsSigninProfile(loaded_profile)) {
366 profile = loaded_profile;
367 }
368 }
369 #endif
370
362 // This retry loop reduces flakiness due to the fact that this ultimately 371 // This retry loop reduces flakiness due to the fact that this ultimately
363 // tests whether or not a code path hits a timed wait. 372 // tests whether or not a code path hits a timed wait.
364 bool succeeded = false; 373 bool succeeded = false;
365 for (size_t retries = 0; !succeeded && retries < 3; ++retries) { 374 for (size_t retries = 0; !succeeded && retries < 3; ++retries) {
366 // Flush the profile data to disk for all loaded profiles. 375 // Flush the profile data to disk for all loaded profiles.
367 profile->SetExitType(Profile::EXIT_CRASHED); 376 profile->SetExitType(Profile::EXIT_CRASHED);
368 FlushTaskRunner(profile->GetIOTaskRunner().get()); 377 FlushTaskRunner(profile->GetIOTaskRunner().get());
369 378
370 // Make sure that the prefs file was written with the expected key/value. 379 // Make sure that the prefs file was written with the expected key/value.
371 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); 380 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed");
(...skipping 19 matching lines...) Expand all
391 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "SessionEnded"); 400 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "SessionEnded");
392 401
393 // Mark the success. 402 // Mark the success.
394 succeeded = true; 403 succeeded = true;
395 } 404 }
396 405
397 ASSERT_TRUE(succeeded) << "profile->EndSession() timed out too often."; 406 ASSERT_TRUE(succeeded) << "profile->EndSession() timed out too often.";
398 } 407 }
399 408
400 #endif // defined(USE_X11) || defined(OS_WIN) 409 #endif // defined(USE_X11) || defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698