| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 9 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| 11 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 namespace chromeos { | 15 namespace chromeos { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 static const char kActiveUserHash[] = "01234567890"; | 18 static const char kActiveUserHash[] = "01234567890"; |
| 17 } // namespace | 19 } // namespace |
| 18 | 20 |
| 19 class ProfileHelperTest : public InProcessBrowserTest { | 21 // The boolean parameter, retrieved by GetParam(), is true if testing with |
| 22 // multi-profiles enabled. |
| 23 class ProfileHelperTest : public InProcessBrowserTest, |
| 24 public testing::WithParamInterface<bool> { |
| 20 public: | 25 public: |
| 21 ProfileHelperTest() { | 26 ProfileHelperTest() { |
| 22 } | 27 } |
| 23 | 28 |
| 24 protected: | 29 protected: |
| 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 31 if (GetParam()) |
| 32 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 33 } |
| 34 |
| 25 void ActiveUserChanged(ProfileHelper* profile_helper, | 35 void ActiveUserChanged(ProfileHelper* profile_helper, |
| 26 const std::string& hash) { | 36 const std::string& hash) { |
| 27 profile_helper->ActiveUserHashChanged(hash); | 37 profile_helper->ActiveUserHashChanged(hash); |
| 28 } | 38 } |
| 29 }; | 39 }; |
| 30 | 40 |
| 31 IN_PROC_BROWSER_TEST_F(ProfileHelperTest, ActiveUserProfileDir) { | 41 IN_PROC_BROWSER_TEST_P(ProfileHelperTest, ActiveUserProfileDir) { |
| 32 ProfileHelper profile_helper; | 42 ProfileHelper profile_helper; |
| 33 ActiveUserChanged(&profile_helper, kActiveUserHash); | 43 ActiveUserChanged(&profile_helper, kActiveUserHash); |
| 34 base::FilePath profile_dir = profile_helper.GetActiveUserProfileDir(); | 44 base::FilePath profile_dir = profile_helper.GetActiveUserProfileDir(); |
| 35 std::string expected_dir; | 45 std::string expected_dir; |
| 36 expected_dir.append(chrome::kProfileDirPrefix); | 46 expected_dir.append(chrome::kProfileDirPrefix); |
| 37 expected_dir.append(kActiveUserHash); | 47 expected_dir.append(kActiveUserHash); |
| 38 EXPECT_EQ(expected_dir, profile_dir.BaseName().value()); | 48 EXPECT_EQ(expected_dir, profile_dir.BaseName().value()); |
| 39 } | 49 } |
| 40 | 50 |
| 51 INSTANTIATE_TEST_CASE_P(ProfileHelperTestInstantiation, |
| 52 ProfileHelperTest, |
| 53 testing::Bool()); |
| 54 |
| 41 } // namespace chromeos | 55 } // namespace chromeos |
| OLD | NEW |