| 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 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 11 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
| 15 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/dbus/fake_session_manager_client.h" | 16 #include "chromeos/dbus/fake_session_manager_client.h" |
| 17 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
| 18 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 19 #include "components/user_manager/user_manager.h" | 19 #include "components/user_manager/user_manager.h" |
| 20 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 | 25 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 41 command_line->AppendSwitchASCII(switches::kLoginUser, kUserId1); | 41 command_line->AppendSwitchASCII(switches::kLoginUser, kUserId1); |
| 42 command_line->AppendSwitchASCII( | 42 command_line->AppendSwitchASCII( |
| 43 switches::kLoginProfile, | 43 switches::kLoginProfile, |
| 44 CryptohomeClient::GetStubSanitizedUsername(kUserId1)); | 44 CryptohomeClient::GetStubSanitizedUsername(kUserId1)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 47 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 48 // Redirect session_manager DBus calls to FakeSessionManagerClient. | 48 // Redirect session_manager DBus calls to FakeSessionManagerClient. |
| 49 FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager; | |
| 50 dbus_thread_manager->SetFakeClients(); | |
| 51 session_manager_client_ = new FakeSessionManagerClient; | 49 session_manager_client_ = new FakeSessionManagerClient; |
| 52 dbus_thread_manager->SetSessionManagerClient( | 50 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 53 scoped_ptr<SessionManagerClient>(session_manager_client_)); | 51 scoped_ptr<SessionManagerClient>(session_manager_client_)); |
| 54 DBusThreadManager::SetInstanceForTesting(dbus_thread_manager); | |
| 55 session_manager_client_->StartSession(kUserId1); | 52 session_manager_client_->StartSession(kUserId1); |
| 56 } | 53 } |
| 57 | 54 |
| 58 FakeSessionManagerClient* session_manager_client_; | 55 FakeSessionManagerClient* session_manager_client_; |
| 59 }; | 56 }; |
| 60 | 57 |
| 61 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { | 58 IN_PROC_BROWSER_TEST_F(CrashRestoreSimpleTest, RestoreSessionForOneUser) { |
| 62 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 59 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 63 user_manager::User* user = user_manager->GetActiveUser(); | 60 user_manager::User* user = user_manager->GetActiveUser(); |
| 64 ASSERT_TRUE(user); | 61 ASSERT_TRUE(user); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 users[0]->username_hash()); | 144 users[0]->username_hash()); |
| 148 EXPECT_EQ(kUserId2, users[1]->email()); | 145 EXPECT_EQ(kUserId2, users[1]->email()); |
| 149 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId2), | 146 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId2), |
| 150 users[1]->username_hash()); | 147 users[1]->username_hash()); |
| 151 EXPECT_EQ(kUserId1, users[2]->email()); | 148 EXPECT_EQ(kUserId1, users[2]->email()); |
| 152 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), | 149 EXPECT_EQ(CryptohomeClient::GetStubSanitizedUsername(kUserId1), |
| 153 users[2]->username_hash()); | 150 users[2]->username_hash()); |
| 154 } | 151 } |
| 155 | 152 |
| 156 } // namespace chromeos | 153 } // namespace chromeos |
| OLD | NEW |