OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ | 5 #ifndef REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ |
6 #define REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ | 6 #define REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 base::FilePath refresh_token_file_path; | 42 base::FilePath refresh_token_file_path; |
43 bool use_test_environment = false; | 43 bool use_test_environment = false; |
44 }; | 44 }; |
45 | 45 |
46 explicit ChromotingTestDriverEnvironment(const EnvironmentOptions& options); | 46 explicit ChromotingTestDriverEnvironment(const EnvironmentOptions& options); |
47 ~ChromotingTestDriverEnvironment() override; | 47 ~ChromotingTestDriverEnvironment() override; |
48 | 48 |
49 // Returns false if a valid access token cannot be retrieved. | 49 // Returns false if a valid access token cannot be retrieved. |
50 bool Initialize(const std::string& auth_code); | 50 bool Initialize(const std::string& auth_code); |
51 | 51 |
| 52 // Clears and then retrieves a new host list. |
| 53 bool RefreshHostList(); |
| 54 |
52 // Retrieves connection information for all known hosts and displays | 55 // Retrieves connection information for all known hosts and displays |
53 // their availability to STDOUT. | 56 // their availability to STDOUT. |
54 void DisplayHostList(); | 57 void DisplayHostList(); |
55 | 58 |
56 // Waits for either the host to come online or a maximum timeout. Returns true | 59 // Waits for either the host to come online or a maximum timeout. Returns true |
57 // if host is found online. | 60 // if host is found online and |host_info_| is valid. |
58 bool WaitForHostOnline(const std::string& host_jid, | 61 bool WaitForHostOnline(); |
59 const std::string& host_name); | |
60 | 62 |
61 // Used to set fake/mock objects for ChromotingTestDriverEnvironment tests. | 63 // Used to set fake/mock objects for ChromotingTestDriverEnvironment tests. |
62 // The caller retains ownership of the supplied objects, and must ensure that | 64 // The caller retains ownership of the supplied objects, and must ensure that |
63 // they remain valid until the ChromotingTestDriverEnvironment instance has | 65 // they remain valid until the ChromotingTestDriverEnvironment instance has |
64 // been destroyed. | 66 // been destroyed. |
65 void SetAccessTokenFetcherForTest(AccessTokenFetcher* access_token_fetcher); | 67 void SetAccessTokenFetcherForTest(AccessTokenFetcher* access_token_fetcher); |
66 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); | 68 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); |
67 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); | 69 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); |
68 void SetHostNameForTest(const std::string& host_name); | 70 void SetHostNameForTest(const std::string& host_name); |
69 void SetHostJidForTest(const std::string& host_jid); | 71 void SetHostJidForTest(const std::string& host_jid); |
(...skipping 18 matching lines...) Expand all Loading... |
88 // Returns true if a new, valid access token has been retrieved. | 90 // Returns true if a new, valid access token has been retrieved. |
89 bool RetrieveAccessToken(const std::string& auth_code); | 91 bool RetrieveAccessToken(const std::string& auth_code); |
90 | 92 |
91 // Called after the access token fetcher completes. | 93 // Called after the access token fetcher completes. |
92 // The tokens will be empty on failure. | 94 // The tokens will be empty on failure. |
93 void OnAccessTokenRetrieved(base::Closure done_closure, | 95 void OnAccessTokenRetrieved(base::Closure done_closure, |
94 const std::string& retrieved_access_token, | 96 const std::string& retrieved_access_token, |
95 const std::string& retrieved_refresh_token); | 97 const std::string& retrieved_refresh_token); |
96 | 98 |
97 // Used to retrieve a host list from the directory service. | 99 // Used to retrieve a host list from the directory service. |
98 // Returns true if the request was successful, |host_list_| is valid, and | 100 // Returns true if the request was successful and |host_list_| is valid. |
99 // |host_info_| has been set. | |
100 bool RetrieveHostList(); | 101 bool RetrieveHostList(); |
101 | 102 |
102 // Clears and then retrieves a new host list. | 103 // Sets |host_info_| if the requested host exists in the host list. |
103 bool RefreshHostList(); | 104 bool FindHostInHostList(); |
104 | 105 |
105 // Called after the host info fetcher completes. | 106 // Called after the host info fetcher completes. |
106 void OnHostListRetrieved(base::Closure done_closure, | 107 void OnHostListRetrieved(base::Closure done_closure, |
107 const std::vector<HostInfo>& retrieved_host_list); | 108 const std::vector<HostInfo>& retrieved_host_list); |
108 | 109 |
109 // Used for authenticating with the directory service. | 110 // Used for authenticating with the directory service. |
110 std::string access_token_; | 111 std::string access_token_; |
111 | 112 |
112 // Used to retrieve an access token. | 113 // Used to retrieve an access token. |
113 std::string refresh_token_; | 114 std::string refresh_token_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 154 |
154 // Unfortunately a global var is how the GTEST framework handles sharing data | 155 // Unfortunately a global var is how the GTEST framework handles sharing data |
155 // between tests and keeping long-lived objects around. Used to share access | 156 // between tests and keeping long-lived objects around. Used to share access |
156 // tokens and a host list across tests. | 157 // tokens and a host list across tests. |
157 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; | 158 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; |
158 | 159 |
159 } // namespace test | 160 } // namespace test |
160 } // namespace remoting | 161 } // namespace remoting |
161 | 162 |
162 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ | 163 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ |
OLD | NEW |