| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/cryptohome/mock_homedir_methods.h" | 5 #include "chromeos/cryptohome/mock_homedir_methods.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" |
| 8 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 7 #include "chromeos/cryptohome/mock_async_method_caller.h" | 9 #include "chromeos/cryptohome/mock_async_method_caller.h" |
| 8 | 10 |
| 9 using ::testing::Invoke; | 11 using ::testing::Invoke; |
| 10 using ::testing::WithArgs; | 12 using ::testing::WithArgs; |
| 11 using ::testing::_; | 13 using ::testing::_; |
| 12 | 14 |
| 13 namespace cryptohome { | 15 namespace cryptohome { |
| 14 | 16 |
| 15 MockHomedirMethods::MockHomedirMethods() | 17 MockHomedirMethods::MockHomedirMethods() |
| 16 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {} | 18 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {} |
| 17 | 19 |
| 18 MockHomedirMethods::~MockHomedirMethods() {} | 20 MockHomedirMethods::~MockHomedirMethods() {} |
| 19 | 21 |
| 20 void MockHomedirMethods::SetUp(bool success, MountError return_code) { | 22 void MockHomedirMethods::SetUp(bool success, MountError return_code) { |
| 21 success_ = success; | 23 success_ = success; |
| 22 return_code_ = return_code; | 24 return_code_ = return_code; |
| 25 ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault( |
| 26 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback))); |
| 23 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault( | 27 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault( |
| 24 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback))); | 28 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback))); |
| 25 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault( | 29 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault( |
| 26 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback))); | 30 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback))); |
| 27 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault( | 31 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault( |
| 28 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); | 32 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); |
| 29 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault( | 33 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault( |
| 30 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); | 34 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); |
| 31 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault( | 35 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault( |
| 32 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback))); | 36 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback))); |
| 33 } | 37 } |
| 34 | 38 |
| 35 void MockHomedirMethods::DoCallback(const Callback& callback) { | 39 void MockHomedirMethods::DoCallback(const Callback& callback) { |
| 36 callback.Run(success_, return_code_); | 40 callback.Run(success_, return_code_); |
| 37 } | 41 } |
| 38 | 42 |
| 43 void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) { |
| 44 callback.Run(success_, return_code_, ScopedVector<RetrievedKeyData>()); |
| 45 } |
| 46 |
| 39 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) { | 47 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) { |
| 40 callback.Run( | 48 callback.Run( |
| 41 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername); | 49 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername); |
| 42 } | 50 } |
| 43 | 51 |
| 44 } // namespace cryptohome | 52 } // namespace cryptohome |
| OLD | NEW |