PermissionRequestCreatorApiary: switch from deprecated "namespace" to "eventType"
[chromium-blink-merge.git] / chromeos / cryptohome / mock_homedir_methods.cc
blobdfc506f99028a86ba36022ae09f4ab51536dabb3
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
3 // found in the LICENSE file.
5 #include "chromeos/cryptohome/mock_homedir_methods.h"
7 #include <vector>
9 #include "chromeos/cryptohome/cryptohome_parameters.h"
10 #include "chromeos/cryptohome/mock_async_method_caller.h"
12 using ::testing::Invoke;
13 using ::testing::WithArgs;
14 using ::testing::_;
16 namespace cryptohome {
18 MockHomedirMethods::MockHomedirMethods()
19 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {}
21 MockHomedirMethods::~MockHomedirMethods() {}
23 void MockHomedirMethods::SetUp(bool success, MountError return_code) {
24 success_ = success;
25 return_code_ = return_code;
26 ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault(
27 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback)));
28 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault(
29 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback)));
30 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault(
31 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback)));
32 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault(
33 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback)));
34 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault(
35 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback)));
36 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault(
37 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback)));
40 void MockHomedirMethods::DoCallback(const Callback& callback) {
41 callback.Run(success_, return_code_);
44 void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) {
45 callback.Run(success_, return_code_, std::vector<KeyDefinition>());
48 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) {
49 callback.Run(
50 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername);
53 } // namespace cryptohome