blob: c8c5828775d3c5cdd87825711e8f4f106e3bf278 (
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
|
// Copyright (c) 2012 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 CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_
#define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "chrome/browser/policy/device_management_service.h"
#include "chrome/browser/policy/proto/device_management_backend.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace policy {
class MockDeviceManagementJob {
public:
virtual ~MockDeviceManagementJob();
virtual void SendResponse(
DeviceManagementStatus status,
const enterprise_management::DeviceManagementResponse& response) = 0;
};
class MockDeviceManagementService : public DeviceManagementService {
public:
MockDeviceManagementService();
virtual ~MockDeviceManagementService();
typedef DeviceManagementRequestJob* CreateJobFunction(
DeviceManagementRequestJob::JobType);
MOCK_METHOD1(CreateJob, CreateJobFunction);
MOCK_METHOD7(
StartJob,
void(const std::string& request_type,
const std::string& gaia_token,
const std::string& oauth_token,
const std::string& dm_token,
const std::string& user_affiliation,
const std::string& client_id,
const enterprise_management::DeviceManagementRequest& request));
// Creates a gmock action that will make the job succeed.
testing::Action<CreateJobFunction> SucceedJob(
const enterprise_management::DeviceManagementResponse& response);
// Creates a gmock action which will fail the job with the given error.
testing::Action<CreateJobFunction> FailJob(DeviceManagementStatus status);
// Creates a gmock action which will capture the job so the test code can
// delay job completion.
testing::Action<CreateJobFunction> CreateAsyncJob(
MockDeviceManagementJob** job);
private:
DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_
|