1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "testing/gtest/include/gtest/gtest.h"
20 static const char kActiveUserHash
[] = "01234567890";
23 // The boolean parameter, retrieved by GetParam(), is true if testing with
24 // multi-profiles enabled.
25 class ProfileHelperTest
: public InProcessBrowserTest
{
31 void ActiveUserChanged(ProfileHelper
* profile_helper
,
32 const std::string
& hash
) {
33 profile_helper
->ActiveUserHashChanged(hash
);
37 IN_PROC_BROWSER_TEST_F(ProfileHelperTest
, ActiveUserProfileDir
) {
38 ProfileHelper profile_helper
;
39 ActiveUserChanged(&profile_helper
, kActiveUserHash
);
40 base::FilePath profile_dir
= profile_helper
.GetActiveUserProfileDir();
41 std::string expected_dir
;
42 expected_dir
.append(chrome::kProfileDirPrefix
);
43 expected_dir
.append(kActiveUserHash
);
44 EXPECT_EQ(expected_dir
, profile_dir
.BaseName().value());
47 IN_PROC_BROWSER_TEST_F(ProfileHelperTest
, GetProfilePathByUserIdHash
) {
48 ProfileHelper profile_helper
;
49 base::FilePath profile_path
=
50 profile_helper
.GetProfilePathByUserIdHash(kActiveUserHash
);
51 base::FilePath expected_path
= g_browser_process
->profile_manager()->
52 user_data_dir().Append(
53 std::string(chrome::kProfileDirPrefix
) + kActiveUserHash
);
54 EXPECT_EQ(expected_path
, profile_path
);
57 } // namespace chromeos