Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 public: | 33 public: |
| 34 struct EnvironmentOptions { | 34 struct EnvironmentOptions { |
| 35 EnvironmentOptions(); | 35 EnvironmentOptions(); |
| 36 ~EnvironmentOptions(); | 36 ~EnvironmentOptions(); |
| 37 | 37 |
| 38 std::string user_name; | 38 std::string user_name; |
| 39 std::string host_name; | 39 std::string host_name; |
| 40 std::string host_jid; | 40 std::string host_jid; |
| 41 std::string pin; | 41 std::string pin; |
| 42 base::FilePath refresh_token_file_path; | 42 base::FilePath refresh_token_file_path; |
| 43 bool use_test_environment; | |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 explicit ChromotingTestDriverEnvironment(const EnvironmentOptions& options); | 46 explicit ChromotingTestDriverEnvironment(const EnvironmentOptions& options); |
| 46 ~ChromotingTestDriverEnvironment() override; | 47 ~ChromotingTestDriverEnvironment() override; |
| 47 | 48 |
| 48 // Returns false if a valid access token cannot be retrieved. | 49 // Returns false if a valid access token cannot be retrieved. |
| 49 bool Initialize(const std::string& auth_code); | 50 bool Initialize(const std::string& auth_code); |
| 50 | 51 |
| 51 // Retrieves connection information for all known hosts and displays | 52 // Retrieves connection information for all known hosts and displays |
| 52 // their availability to STDOUT. | 53 // their availability to STDOUT. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 65 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); | 66 void SetRefreshTokenStoreForTest(RefreshTokenStore* refresh_token_store); |
| 66 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); | 67 void SetHostListFetcherForTest(HostListFetcher* host_list_fetcher); |
| 67 void SetHostNameForTest(const std::string& host_name); | 68 void SetHostNameForTest(const std::string& host_name); |
| 68 void SetHostJidForTest(const std::string& host_jid); | 69 void SetHostJidForTest(const std::string& host_jid); |
| 69 | 70 |
| 70 // Accessors for fields used by tests. | 71 // Accessors for fields used by tests. |
| 71 const std::string& access_token() const { return access_token_; } | 72 const std::string& access_token() const { return access_token_; } |
| 72 const std::string& host_name() const { return host_name_; } | 73 const std::string& host_name() const { return host_name_; } |
| 73 const std::string& pin() const { return pin_; } | 74 const std::string& pin() const { return pin_; } |
| 74 const std::string& user_name() const { return user_name_; } | 75 const std::string& user_name() const { return user_name_; } |
| 76 bool use_test_environment() const { return use_test_environment_; } | |
| 75 const std::vector<HostInfo>& host_list() const { return host_list_; } | 77 const std::vector<HostInfo>& host_list() const { return host_list_; } |
| 76 const HostInfo& host_info() const { return host_info_; } | 78 const HostInfo& host_info() const { return host_info_; } |
| 77 | 79 |
| 78 private: | 80 private: |
| 79 friend class ChromotingTestDriverEnvironmentTest; | 81 friend class ChromotingTestDriverEnvironmentTest; |
| 80 | 82 |
| 81 // testing::Environment interface. | 83 // testing::Environment interface. |
| 82 void TearDown() override; | 84 void TearDown() override; |
| 83 | 85 |
| 84 // Used to retrieve an access token. If |auth_code| is empty, then the stored | 86 // Used to retrieve an access token. If |auth_code| is empty, then the stored |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 120 |
| 119 // The test account for a test case. | 121 // The test account for a test case. |
| 120 std::string user_name_; | 122 std::string user_name_; |
| 121 | 123 |
| 122 // Used to authenticate a connection with |host_name_|. | 124 // Used to authenticate a connection with |host_name_|. |
| 123 std::string pin_; | 125 std::string pin_; |
| 124 | 126 |
| 125 // Path to a JSON file containing refresh tokens. | 127 // Path to a JSON file containing refresh tokens. |
| 126 base::FilePath refresh_token_file_path_; | 128 base::FilePath refresh_token_file_path_; |
| 127 | 129 |
| 130 // Indicates whether the test environment APIs should be used. | |
| 131 bool use_test_environment_; | |
|
Sergey Ulanov
2016/12/02 19:55:44
make it const, to ensure it's initialized in the c
| |
| 132 | |
| 128 // List of remote hosts for the specified user/test-account. | 133 // List of remote hosts for the specified user/test-account. |
| 129 std::vector<HostInfo> host_list_; | 134 std::vector<HostInfo> host_list_; |
| 130 | 135 |
| 131 // Used to generate connection setup information to connect to |host_name_|. | 136 // Used to generate connection setup information to connect to |host_name_|. |
| 132 HostInfo host_info_; | 137 HostInfo host_info_; |
| 133 | 138 |
| 134 // Access token fetcher used by TestDriverEnvironment tests. | 139 // Access token fetcher used by TestDriverEnvironment tests. |
| 135 remoting::test::AccessTokenFetcher* test_access_token_fetcher_; | 140 remoting::test::AccessTokenFetcher* test_access_token_fetcher_ = nullptr; |
| 136 | 141 |
| 137 // RefreshTokenStore used by TestDriverEnvironment tests. | 142 // RefreshTokenStore used by TestDriverEnvironment tests. |
| 138 remoting::test::RefreshTokenStore* test_refresh_token_store_; | 143 remoting::test::RefreshTokenStore* test_refresh_token_store_ = nullptr; |
| 139 | 144 |
| 140 // HostListFetcher used by TestDriverEnvironment tests. | 145 // HostListFetcher used by TestDriverEnvironment tests. |
| 141 remoting::test::HostListFetcher* test_host_list_fetcher_; | 146 remoting::test::HostListFetcher* test_host_list_fetcher_ = nullptr; |
| 142 | 147 |
| 143 // Used for running network request tasks. | 148 // Used for running network request tasks. |
| 144 std::unique_ptr<base::MessageLoopForIO> message_loop_; | 149 std::unique_ptr<base::MessageLoopForIO> message_loop_; |
| 145 | 150 |
| 146 DISALLOW_COPY_AND_ASSIGN(ChromotingTestDriverEnvironment); | 151 DISALLOW_COPY_AND_ASSIGN(ChromotingTestDriverEnvironment); |
| 147 }; | 152 }; |
| 148 | 153 |
| 149 // Unfortunately a global var is how the GTEST framework handles sharing data | 154 // Unfortunately a global var is how the GTEST framework handles sharing data |
| 150 // between tests and keeping long-lived objects around. Used to share access | 155 // between tests and keeping long-lived objects around. Used to share access |
| 151 // tokens and a host list across tests. | 156 // tokens and a host list across tests. |
| 152 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; | 157 extern ChromotingTestDriverEnvironment* g_chromoting_shared_data; |
| 153 | 158 |
| 154 } // namespace test | 159 } // namespace test |
| 155 } // namespace remoting | 160 } // namespace remoting |
| 156 | 161 |
| 157 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ | 162 #endif // REMOTING_TEST_CHROMOTING_TEST_DRIVER_ENVIRONMENT_H_ |
| OLD | NEW |