| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/notifications/message_center_settings_controller.h" | 9 #include "chrome/browser/notifications/message_center_settings_controller.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 TestingProfileManager testing_profile_manager_; | 55 TestingProfileManager testing_profile_manager_; |
| 56 scoped_ptr<MessageCenterSettingsController> controller_; | 56 scoped_ptr<MessageCenterSettingsController> controller_; |
| 57 content::TestBrowserThreadBundle thread_bundle_; | 57 content::TestBrowserThreadBundle thread_bundle_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerTest); | 59 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerTest); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
| 63 // This value should be same as the one in fake_user_manager.cc | |
| 64 static const char kUserIdHashSuffix[] = "-hash"; | |
| 65 | 63 |
| 66 class MessageCenterSettingsControllerChromeOSTest | 64 class MessageCenterSettingsControllerChromeOSTest |
| 67 : public MessageCenterSettingsControllerTest { | 65 : public MessageCenterSettingsControllerTest { |
| 68 protected: | 66 protected: |
| 69 MessageCenterSettingsControllerChromeOSTest() {} | 67 MessageCenterSettingsControllerChromeOSTest() {} |
| 70 virtual ~MessageCenterSettingsControllerChromeOSTest() {} | 68 virtual ~MessageCenterSettingsControllerChromeOSTest() {} |
| 71 | 69 |
| 72 virtual void SetUp() OVERRIDE { | 70 virtual void SetUp() OVERRIDE { |
| 73 MessageCenterSettingsControllerTest::SetUp(); | 71 MessageCenterSettingsControllerTest::SetUp(); |
| 74 | 72 |
| 75 // Initialize the UserManager singleton to a fresh FakeUserManager instance. | 73 // Initialize the UserManager singleton to a fresh FakeUserManager instance. |
| 76 user_manager_enabler_.reset( | 74 user_manager_enabler_.reset( |
| 77 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager)); | 75 new chromeos::ScopedUserManagerEnabler(new chromeos::FakeUserManager)); |
| 78 } | 76 } |
| 79 | 77 |
| 80 virtual void TearDown() OVERRIDE { | 78 virtual void TearDown() OVERRIDE { |
| 81 ResetController(); | 79 ResetController(); |
| 82 MessageCenterSettingsControllerTest::TearDown(); | 80 MessageCenterSettingsControllerTest::TearDown(); |
| 83 } | 81 } |
| 84 | 82 |
| 85 virtual void CreateProfile(const std::string& name) OVERRIDE { | 83 virtual void CreateProfile(const std::string& name) OVERRIDE { |
| 86 MessageCenterSettingsControllerTest::CreateProfile(name); | 84 MessageCenterSettingsControllerTest::CreateProfile(name); |
| 87 | 85 |
| 88 GetFakeUserManager()->AddUser(name); | 86 GetFakeUserManager()->AddUser(name); |
| 89 GetFakeUserManager()->UserLoggedIn(name, name + kUserIdHashSuffix, false); | 87 GetFakeUserManager()->LoginUser(name); |
| 90 } | 88 } |
| 91 | 89 |
| 92 void SwitchActiveUser(const std::string& name) { | 90 void SwitchActiveUser(const std::string& name) { |
| 93 GetFakeUserManager()->SwitchActiveUser(name); | 91 GetFakeUserManager()->SwitchActiveUser(name); |
| 94 controller()->ActiveUserChanged(GetFakeUserManager()->GetActiveUser()); | 92 controller()->ActiveUserChanged(GetFakeUserManager()->GetActiveUser()); |
| 95 } | 93 } |
| 96 | 94 |
| 97 private: | 95 private: |
| 98 chromeos::FakeUserManager* GetFakeUserManager() { | 96 chromeos::FakeUserManager* GetFakeUserManager() { |
| 99 return static_cast<chromeos::FakeUserManager*>( | 97 return static_cast<chromeos::FakeUserManager*>( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 SwitchActiveUser("Profile-1"); | 154 SwitchActiveUser("Profile-1"); |
| 157 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); | 155 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); |
| 158 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, | 156 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, |
| 159 base::UTF8ToUTF16("Profile-1")); | 157 base::UTF8ToUTF16("Profile-1")); |
| 160 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 0u); | 158 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 0u); |
| 161 } | 159 } |
| 162 #endif | 160 #endif |
| 163 | 161 |
| 164 // TODO(mukai): write a test case to reproduce the actual guest session scenario | 162 // TODO(mukai): write a test case to reproduce the actual guest session scenario |
| 165 // in ChromeOS -- no profiles in the profile_info_cache. | 163 // in ChromeOS -- no profiles in the profile_info_cache. |
| OLD | NEW |