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

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

Issue 1010443003: Make the lifetime of wallpaper manager more clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failed unittests. Created 5 years, 9 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 <string> 5 #include <string>
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/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 29 matching lines...) Expand all
40 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
41 #include "content/public/test/test_browser_thread_bundle.h" 41 #include "content/public/test/test_browser_thread_bundle.h"
42 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
43 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
45 45
46 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
47 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 47 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
48 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 48 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
49 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 49 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
50 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
50 #include "chrome/browser/chromeos/profiles/profile_helper.h" 51 #include "chrome/browser/chromeos/profiles/profile_helper.h"
51 #include "chrome/browser/chromeos/settings/cros_settings.h" 52 #include "chrome/browser/chromeos/settings/cros_settings.h"
52 #include "chrome/browser/chromeos/settings/device_settings_service.h" 53 #include "chrome/browser/chromeos/settings/device_settings_service.h"
53 #include "chromeos/chromeos_switches.h" 54 #include "chromeos/chromeos_switches.h"
54 #include "chromeos/login/user_names.h" 55 #include "chromeos/login/user_names.h"
55 #include "components/user_manager/user_manager.h" 56 #include "components/user_manager/user_manager.h"
56 #endif // defined(OS_CHROMEOS) 57 #endif // defined(OS_CHROMEOS)
57 58
58 using base::ASCIIToUTF16; 59 using base::ASCIIToUTF16;
59 using content::BrowserThread; 60 using content::BrowserThread;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 void SetUp() override { 107 void SetUp() override {
107 // Create a new temporary directory, and store the path 108 // Create a new temporary directory, and store the path
108 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 109 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
109 TestingBrowserProcess::GetGlobal()->SetProfileManager( 110 TestingBrowserProcess::GetGlobal()->SetProfileManager(
110 new UnittestProfileManager(temp_dir_.path())); 111 new UnittestProfileManager(temp_dir_.path()));
111 112
112 #if defined(OS_CHROMEOS) 113 #if defined(OS_CHROMEOS)
113 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 114 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
114 cl->AppendSwitch(switches::kTestType); 115 cl->AppendSwitch(switches::kTestType);
116 chromeos::WallpaperManager::Initialize();
115 #endif 117 #endif
116 } 118 }
117 119
118 void TearDown() override { 120 void TearDown() override {
119 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); 121 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
120 base::RunLoop().RunUntilIdle(); 122 base::RunLoop().RunUntilIdle();
123 #if defined(OS_CHROMEOS)
124 chromeos::WallpaperManager::Shutdown();
125 #endif
121 } 126 }
122 127
123 // Helper function to create a profile with |name| for a profile |manager|. 128 // Helper function to create a profile with |name| for a profile |manager|.
124 void CreateProfileAsync(ProfileManager* manager, 129 void CreateProfileAsync(ProfileManager* manager,
125 const std::string& name, 130 const std::string& name,
126 bool is_supervised, 131 bool is_supervised,
127 MockObserver* mock_observer) { 132 MockObserver* mock_observer) {
128 manager->CreateProfileAsync( 133 manager->CreateProfileAsync(
129 temp_dir_.path().AppendASCII(name), 134 temp_dir_.path().AppendASCII(name),
130 base::Bind(&MockObserver::OnProfileCreated, 135 base::Bind(&MockObserver::OnProfileCreated,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 422
418 #if defined(OS_CHROMEOS) 423 #if defined(OS_CHROMEOS)
419 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 424 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
420 // This switch is needed to skip non-test specific behavior in 425 // This switch is needed to skip non-test specific behavior in
421 // ProfileManager (accessing DBusThreadManager). 426 // ProfileManager (accessing DBusThreadManager).
422 cl->AppendSwitch(switches::kTestType); 427 cl->AppendSwitch(switches::kTestType);
423 428
424 cl->AppendSwitch(chromeos::switches::kGuestSession); 429 cl->AppendSwitch(chromeos::switches::kGuestSession);
425 cl->AppendSwitch(::switches::kIncognito); 430 cl->AppendSwitch(::switches::kIncognito);
426 431
432 chromeos::WallpaperManager::Initialize();
427 RegisterUser(chromeos::login::kGuestUserName); 433 RegisterUser(chromeos::login::kGuestUserName);
428 #endif 434 #endif
429 } 435 }
430 }; 436 };
431 437
432 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) { 438 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) {
433 ProfileManager* profile_manager = g_browser_process->profile_manager(); 439 ProfileManager* profile_manager = g_browser_process->profile_manager();
434 ASSERT_TRUE(profile_manager); 440 ASSERT_TRUE(profile_manager);
435 441
436 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); 442 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy();
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 dest_path2.BaseName().MaybeAsASCII()); 1305 dest_path2.BaseName().MaybeAsASCII());
1300 profile_manager->ScheduleProfileForDeletion(dest_path2, 1306 profile_manager->ScheduleProfileForDeletion(dest_path2,
1301 ProfileManager::CreateCallback()); 1307 ProfileManager::CreateCallback());
1302 // Spin the message loop so that all the callbacks can finish running. 1308 // Spin the message loop so that all the callbacks can finish running.
1303 base::RunLoop().RunUntilIdle(); 1309 base::RunLoop().RunUntilIdle();
1304 1310
1305 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1311 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1306 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1312 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1307 } 1313 }
1308 #endif // !defined(OS_MACOSX) 1314 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698