summaryrefslogtreecommitdiffstats
path: root/chromeos/cryptohome/mock_homedir_methods.h
blob: 8647744d2c5107d64725f011d436a798178f8c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_CRYPTOHOME_MOCK_HOMEDIR_METHODS_H_
#define CHROMEOS_CRYPTOHOME_MOCK_HOMEDIR_METHODS_H_

#include <string>

#include "base/basictypes.h"
#include "base/callback.h"
#include "chromeos/cryptohome/homedir_methods.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace cryptohome {

class CHROMEOS_EXPORT MockHomedirMethods : public HomedirMethods {
 public:
  MockHomedirMethods();
  virtual ~MockHomedirMethods();

  void SetUp(bool success, MountError return_code);

  MOCK_METHOD3(GetKeyDataEx,
               void(const Identification& id,
                    const std::string& label,
                    const GetKeyDataCallback& callback));
  MOCK_METHOD3(CheckKeyEx,
               void(const Identification& id,
                    const Authorization& key,
                    const Callback& callback));
  MOCK_METHOD4(MountEx,
               void(const Identification& id,
                    const Authorization& key,
                    const MountParameters& request,
                    const MountCallback& callback));
  MOCK_METHOD5(AddKeyEx,
               void(const Identification& id,
                    const Authorization& auth,
                    const KeyDefinition& key,
                    bool clobber_if_exist,
                    const Callback& callback));
  MOCK_METHOD4(RemoveKeyEx,
               void(const Identification& id,
                    const Authorization& auth,
                    const std::string& label,
                    const Callback& callback));
  MOCK_METHOD5(UpdateKeyEx,
               void(const Identification& id,
                    const Authorization& auth,
                    const KeyDefinition& key,
                    const std::string& signature,
                    const Callback& callback));

 private:
  bool success_;
  MountError return_code_;

  void DoCallback(const Callback& callback);
  void DoGetDataCallback(const GetKeyDataCallback& callback);
  void DoMountCallback(const MountCallback& callback);

  DISALLOW_COPY_AND_ASSIGN(MockHomedirMethods);
};

}  // namespace cryptohome

#endif  // CHROMEOS_CRYPTOHOME_MOCK_HOMEDIR_METHODS_H_