blob: 521db86e66f902dd8568f559ba436b18780499ab (
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
|
// 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_ACCESS_TOKEN_FETCHER_H_
#define REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_
#include <string>
#include "base/macros.h"
#include "remoting/test/access_token_fetcher.h"
namespace remoting {
namespace test {
const char kFakeAccessTokenFetcherRefreshTokenValue[] = "fake_refresh_token";
const char kFakeAccessTokenFetcherAccessTokenValue[] = "fake_access_token";
// 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 FakeAccessTokenFetcher : public AccessTokenFetcher {
public:
FakeAccessTokenFetcher();
~FakeAccessTokenFetcher() override;
// AccessTokenFetcher interface.
void GetAccessTokenFromAuthCode(const std::string& auth_code,
const AccessTokenCallback& callback) override;
void GetAccessTokenFromRefreshToken(
const std::string& refresh_token,
const AccessTokenCallback& callback) override;
void set_fail_access_token_from_auth_code(bool fail) {
fail_access_token_from_auth_code_ = fail;
}
void set_fail_access_token_from_refresh_token(bool fail) {
fail_access_token_from_refresh_token_ = fail;
}
private:
// True if GetAccessTokenFromAuthCode() should fail.
bool fail_access_token_from_auth_code_;
// True if GetAccessTokenFromRefreshToken() should fail.
bool fail_access_token_from_refresh_token_;
DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenFetcher);
};
} // namespace test
} // namespace remoting
#endif // REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_
|