summaryrefslogtreecommitdiffstats
path: root/remoting/test/fake_app_remoting_report_issue_request.h
blob: 11ecdccdd7647fc55e93add0f5bd30b58e5c4efd (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
// Copyright 2015 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 REMOTING_TEST_FAKE_APP_REMOTING_REPORT_ISSUE_REQUEST_H_
#define REMOTING_TEST_FAKE_APP_REMOTING_REPORT_ISSUE_REQUEST_H_

#include <string>
#include <vector>

#include "base/macros.h"
#include "remoting/test/app_remoting_report_issue_request.h"

namespace remoting {
namespace test {

// Generates a string used to track the 'released' host id by the
// FakeAppRemotingReportIssueRequest class.
std::string MakeFormattedStringForReleasedHost(
    const std::string& application_id,
    const std::string& host_id);

// Used for testing classes which rely on the AccessTokenFetcher and want to
// simulate success and failure scenarios without using the actual class and
// network connection.
class FakeAppRemotingReportIssueRequest : public AppRemotingReportIssueRequest {
 public:
  FakeAppRemotingReportIssueRequest();
  ~FakeAppRemotingReportIssueRequest() override;

  // AppRemotingReportIssueRequest interface.
  bool Start(const std::string& application_id,
             const std::string& host_id,
             const std::string& access_token,
             ServiceEnvironment service_environment,
             bool abandon_host,
             base::Closure done_callback) override;

  void set_fail_start_request(bool fail) { fail_start_request_ = fail; }

  const std::vector<std::string>& get_host_ids_released() {
    return host_ids_released_;
  }

 private:
  // True if Start() should fail.
  bool fail_start_request_;

  // Contains the set of host ids which have been released, the string contained
  // will be in the form "<application_id>::<host_id>";
  std::vector<std::string> host_ids_released_;

  DISALLOW_COPY_AND_ASSIGN(FakeAppRemotingReportIssueRequest);
};

}  // namespace test
}  // namespace remoting

#endif  // REMOTING_TEST_FAKE_APP_REMOTING_REPORT_ISSUE_REQUEST_H_