| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 bool WaitForHostOnline(const std::string& host_jid, | 57 bool WaitForHostOnline(const std::string& host_jid, |
| 58 const std::string& host_name); | 58 const std::string& host_name); |
| 59 | 59 |
| 60 // Used to set fake/mock objects for ChromotingTestDriverEnvironment tests. | 60 // Used to set fake/mock objects for ChromotingTestDriverEnvironment tests. |
| 61 // The caller retains ownership of the supplied objects, and must ensure that | 61 // The caller retains ownership of the supplied objects, and must ensure that |
| 62 // they remain valid until the ChromotingTestDriverEnvironment instance has | 62 // they remain valid until the ChromotingTestDriverEnvironment instance has |
| 63 // been destroyed. | 63 // been destroyed. |
| 64 void SetAccessTokenFetcherForTest(AccessTokenFetcher* access_token_fetcher); | 64 void SetAccessTokenFetcherForTest(AccessTokenFetcher* access_token_fetcher); |
| 65 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); | 65 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); |
| 66 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); | 66 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); |
| 67 void SetHostNameForTest(const std::string& host_name); |
| 68 void SetHostJidForTest(const std::string& host_jid); |
| 67 | 69 |
| 68 // Accessors for fields used by tests. | 70 // Accessors for fields used by tests. |
| 69 const std::string& access_token() const { return access_token_; } | 71 const std::string& access_token() const { return access_token_; } |
| 70 const std::string& host_name() const { return host_name_; } | 72 const std::string& host_name() const { return host_name_; } |
| 71 const std::string& pin() const { return pin_; } | 73 const std::string& pin() const { return pin_; } |
| 72 const std::string& user_name() const { return user_name_; } | 74 const std::string& user_name() const { return user_name_; } |
| 73 const std::vector<HostInfo>& host_list() const { return host_list_; } | 75 const std::vector<HostInfo>& host_list() const { return host_list_; } |
| 74 const HostInfo& host_info() const { return host_info_; } | 76 const HostInfo& host_info() const { return host_info_; } |
| 75 | 77 |
| 76 private: | 78 private: |
| 79 friend class ChromotingTestDriverEnvironmentTest; |
| 80 |
| 77 // testing::Environment interface. | 81 // testing::Environment interface. |
| 78 void TearDown() override; | 82 void TearDown() override; |
| 79 | 83 |
| 80 // Used to retrieve an access token. If |auth_code| is empty, then the stored | 84 // Used to retrieve an access token. If |auth_code| is empty, then the stored |
| 81 // refresh_token will be used instead of |auth_code|. | 85 // refresh_token will be used instead of |auth_code|. |
| 82 // Returns true if a new, valid access token has been retrieved. | 86 // Returns true if a new, valid access token has been retrieved. |
| 83 bool RetrieveAccessToken(const std::string& auth_code); | 87 bool RetrieveAccessToken(const std::string& auth_code); |
| 84 | 88 |
| 85 // Called after the access token fetcher completes. | 89 // Called after the access token fetcher completes. |
| 86 // The tokens will be empty on failure. | 90 // The tokens will be empty on failure. |
| 87 void OnAccessTokenRetrieved(base::Closure done_closure, | 91 void OnAccessTokenRetrieved(base::Closure done_closure, |
| 88 const std::string& retrieved_access_token, | 92 const std::string& retrieved_access_token, |
| 89 const std::string& retrieved_refresh_token); | 93 const std::string& retrieved_refresh_token); |
| 90 | 94 |
| 91 // Used to retrieve a host list from the directory service. | 95 // Used to retrieve a host list from the directory service. |
| 92 // Returns true if the request was successful and |host_list_| is valid. | 96 // Returns true if the request was successful, |host_list_| is valid, and |
| 97 // |host_info_| has been set. |
| 93 bool RetrieveHostList(); | 98 bool RetrieveHostList(); |
| 94 | 99 |
| 95 // Clears and then retrieves a new host list. | 100 // Clears and then retrieves a new host list. |
| 96 bool RefreshHostList(); | 101 bool RefreshHostList(); |
| 97 | 102 |
| 98 // Called after the host info fetcher completes. | 103 // Called after the host info fetcher completes. |
| 99 void OnHostListRetrieved(base::Closure done_closure, | 104 void OnHostListRetrieved(base::Closure done_closure, |
| 100 const std::vector<HostInfo>& retrieved_host_list); | 105 const std::vector<HostInfo>& retrieved_host_list); |
| 101 | 106 |
| 102 // Checks the status of the host in |host_list_| that matches the given | |
| 103 // host_jid and host_name. Returns true if that host is online, false | |
| 104 // otherwise. | |
| 105 bool IsHostOnline(const std::string host_jid, | |
| 106 const std::string host_name) const; | |
| 107 | |
| 108 // Used for authenticating with the directory service. | 107 // Used for authenticating with the directory service. |
| 109 std::string access_token_; | 108 std::string access_token_; |
| 110 | 109 |
| 111 // Used to retrieve an access token. | 110 // Used to retrieve an access token. |
| 112 std::string refresh_token_; | 111 std::string refresh_token_; |
| 113 | 112 |
| 114 // Used to find remote host in host list. | 113 // Used to find remote host in host list. |
| 115 std::string host_name_; | 114 std::string host_name_; |
| 116 | 115 |
| 116 // Used to find remote host in host list. |
| 117 std::string host_jid_; |
| 118 |
| 117 // The test account for a test case. | 119 // The test account for a test case. |
| 118 std::string user_name_; | 120 std::string user_name_; |
| 119 | 121 |
| 120 // Used to authenticate a connection with |host_name_|. | 122 // Used to authenticate a connection with |host_name_|. |
| 121 std::string pin_; | 123 std::string pin_; |
| 122 | 124 |
| 123 // Path to a JSON file containing refresh tokens. | 125 // Path to a JSON file containing refresh tokens. |
| 124 base::FilePath refresh_token_file_path_; | 126 base::FilePath refresh_token_file_path_; |
| 125 | 127 |
| 126 // List of remote hosts for the specified user/test-account. | 128 // List of remote hosts for the specified user/test-account. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 146 | 148 |
| 147 // Unfortunately a global var is how the GTEST framework handles sharing data | 149 // Unfortunately a global var is how the GTEST framework handles sharing data |
| 148 // between tests and keeping long-lived objects around. Used to share access | 150 // between tests and keeping long-lived objects around. Used to share access |
| 149 // tokens and a host list across tests. | 151 // tokens and a host list across tests. |
| 150 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; | 152 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; |
| 151 | 153 |
| 152 } // namespace test | 154 } // namespace test |
| 153 } // namespace remoting | 155 } // namespace remoting |
| 154 | 156 |
| 155 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ | 157 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ |
| OLD | NEW |