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

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

Issue 204123002: cros: Don't prefix test user profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests and session log dir Created 6 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile_info_cache.h" 9 #include "chrome/browser/profiles/profile_info_cache.h"
10 #include "chrome/browser/profiles/profile_info_cache_observer.h" 10 #include "chrome/browser/profiles/profile_info_cache_observer.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profile_window.h" 12 #include "chrome/browser/profiles/profile_window.h"
13 #include "chrome/browser/profiles/profiles_state.h" 13 #include "chrome/browser/profiles/profiles_state.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/host_desktop.h" 17 #include "chrome/browser/ui/host_desktop.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/test_switches.h" 21 #include "chrome/test/base/test_switches.h"
22 #include "chrome/test/base/testing_browser_process.h" 22 #include "chrome/test/base/testing_browser_process.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "base/path_service.h" 26 #include "base/path_service.h"
27 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chromeos/chromeos_switches.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #endif 31 #endif
31 32
32 namespace { 33 namespace {
33 34
34 const profiles::ProfileSwitchingDoneCallback kOnProfileSwitchDoNothing; 35 const profiles::ProfileSwitchingDoneCallback kOnProfileSwitchDoNothing;
35 36
36 // An observer that returns back to test code after a new profile is 37 // An observer that returns back to test code after a new profile is
37 // initialized. 38 // initialized.
38 void OnUnblockOnProfileCreation(Profile* profile, 39 void OnUnblockOnProfileCreation(Profile* profile,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 EXPECT_EQ(new_profile_path, last_used->GetPath()); 176 EXPECT_EQ(new_profile_path, last_used->GetPath());
176 } 177 }
177 #endif // OS_MACOSX 178 #endif // OS_MACOSX
178 179
179 #if defined(OS_CHROMEOS) 180 #if defined(OS_CHROMEOS)
180 181
181 class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest, 182 class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest,
182 public testing::WithParamInterface<bool> { 183 public testing::WithParamInterface<bool> {
183 protected: 184 protected:
184 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 185 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
185 if (GetParam()) 186 if (GetParam()) {
186 command_line->AppendSwitch(::switches::kMultiProfiles); 187 command_line->AppendSwitch(::switches::kMultiProfiles);
188 // Use a user hash other than the default chrome::kTestUserProfileDir
189 // so that the prefix case is tested.
190 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
191 "test-user-hash");
192 }
187 } 193 }
188 }; 194 };
189 195
190 IN_PROC_BROWSER_TEST_P(ProfileManagerCrOSBrowserTest, GetLastUsedProfile) { 196 IN_PROC_BROWSER_TEST_P(ProfileManagerCrOSBrowserTest, GetLastUsedProfile) {
191 // Make sure that last used profile is correct. 197 // Make sure that last used profile is correct.
192 Profile* last_used_profile = ProfileManager::GetLastUsedProfile(); 198 Profile* last_used_profile = ProfileManager::GetLastUsedProfile();
193 EXPECT_TRUE(last_used_profile != NULL); 199 EXPECT_TRUE(last_used_profile != NULL);
194 200
195 base::FilePath profile_path; 201 base::FilePath profile_path;
196 PathService::Get(chrome::DIR_USER_DATA, &profile_path); 202 PathService::Get(chrome::DIR_USER_DATA, &profile_path);
197 203
198 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 204 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
199 if (command_line.HasSwitch(switches::kMultiProfiles)) { 205 if (command_line.HasSwitch(switches::kMultiProfiles)) {
200 profile_path = profile_path.Append(base::FilePath( 206 profile_path = profile_path.AppendASCII(
201 std::string(chrome::kProfileDirPrefix) + chrome::kTestUserProfileDir)); 207 std::string(chrome::kProfileDirPrefix) + "test-user-hash");
202 } else { 208 } else {
203 profile_path = profile_path.Append( 209 profile_path = profile_path.AppendASCII(chrome::kTestUserProfileDir);
204 base::FilePath(chrome::kTestUserProfileDir));
205 } 210 }
206 EXPECT_EQ(profile_path.value(), last_used_profile->GetPath().value()); 211 EXPECT_EQ(profile_path.value(), last_used_profile->GetPath().value());
207 } 212 }
208 213
209 INSTANTIATE_TEST_CASE_P(ProfileManagerCrOSBrowserTestInstantiation, 214 INSTANTIATE_TEST_CASE_P(ProfileManagerCrOSBrowserTestInstantiation,
210 ProfileManagerCrOSBrowserTest, 215 ProfileManagerCrOSBrowserTest,
211 testing::Bool()); 216 testing::Bool());
212 217
213 #endif // OS_CHROMEOS 218 #endif // OS_CHROMEOS
214 219
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 content::RunAllPendingInMessageLoop(); 368 content::RunAllPendingInMessageLoop();
364 EXPECT_EQ(2U, browser_list->size()); 369 EXPECT_EQ(2U, browser_list->size());
365 ASSERT_EQ(2U, cache.GetNumberOfProfiles()); 370 ASSERT_EQ(2U, cache.GetNumberOfProfiles());
366 371
367 // The second should though. 372 // The second should though.
368 browser_list->get(1)->window()->Close(); 373 browser_list->get(1)->window()->Close();
369 content::RunAllPendingInMessageLoop(); 374 content::RunAllPendingInMessageLoop();
370 EXPECT_EQ(1U, browser_list->size()); 375 EXPECT_EQ(1U, browser_list->size());
371 ASSERT_EQ(1U, cache.GetNumberOfProfiles()); 376 ASSERT_EQ(1U, cache.GetNumberOfProfiles());
372 } 377 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.cc ('k') | chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698