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