1//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#ifndef SHILL_MOCK_PROCESS_MANAGER_H_
18#define SHILL_MOCK_PROCESS_MANAGER_H_
19
20#include "shill/process_manager.h"
21
22#include <map>
23#include <string>
24#include <vector>
25
26#include <base/macros.h>
27#include <gmock/gmock.h>
28
29namespace shill {
30
31class MockProcessManager : public ProcessManager {
32 public:
33  MockProcessManager();
34  ~MockProcessManager() override;
35
36  MOCK_METHOD1(Init, void(EventDispatcher* dispatcher));
37  MOCK_METHOD0(Stop, void());
38  MOCK_METHOD6(StartProcess,
39               pid_t(const tracked_objects::Location& spawn_source,
40                     const base::FilePath& program,
41                     const std::vector<std::string>& arguments,
42                     const std::map<std::string, std::string>& env,
43                     bool terminate_with_parent,
44                     const base::Callback<void(int)>& exit_callback));
45  MOCK_METHOD7(StartProcessInMinijail,
46               pid_t(const tracked_objects::Location& spawn_source,
47                     const base::FilePath& program,
48                     const std::vector<std::string>& arguments,
49                     const std::string& user,
50                     const std::string& group,
51                     uint64_t capmask,
52                     const base::Callback<void(int)>& exit_callback));
53  MOCK_METHOD10(StartProcessInMinijailWithPipes,
54                pid_t(const tracked_objects::Location& spawn_source,
55                      const base::FilePath& program,
56                      const std::vector<std::string>& arguments,
57                      const std::string& user,
58                      const std::string& group,
59                      uint64_t capmask,
60                      const base::Callback<void(int)>& exit_callback,
61                      int* stdin_fd,
62                      int* stdout_fd,
63                      int* stderr_fd));
64  MOCK_METHOD1(StopProcess, bool(pid_t pid));
65  MOCK_METHOD1(StopProcessAndBlock, bool(pid_t pid));
66  MOCK_METHOD2(UpdateExitCallback,
67               bool(pid_t pid, const base::Callback<void(int)>& new_callback));
68
69 private:
70  DISALLOW_COPY_AND_ASSIGN(MockProcessManager);
71};
72
73}  // namespace shill
74
75#endif  // SHILL_MOCK_PROCESS_MANAGER_H_
76