Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: remoting/test/chromoting_test_driver_environment_unittest.cc

Issue 2734543002: Adding 'Show Host List' option to CTD (Closed)
Patch Set: Addressing comments and fixing unit tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/test/chromoting_test_driver_environment.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "remoting/test/chromoting_test_driver_environment.h" 5 #include "remoting/test/chromoting_test_driver_environment.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 fake_host_list_fetcher_.set_retrieved_host_list(fake_host_list); 75 fake_host_list_fetcher_.set_retrieved_host_list(fake_host_list);
76 76
77 environment_object_->SetAccessTokenFetcherForTest( 77 environment_object_->SetAccessTokenFetcherForTest(
78 &fake_access_token_fetcher_); 78 &fake_access_token_fetcher_);
79 environment_object_->SetRefreshTokenStoreForTest(&fake_token_store_); 79 environment_object_->SetRefreshTokenStoreForTest(&fake_token_store_);
80 environment_object_->SetHostListFetcherForTest(&fake_host_list_fetcher_); 80 environment_object_->SetHostListFetcherForTest(&fake_host_list_fetcher_);
81 } 81 }
82 82
83 bool ChromotingTestDriverEnvironmentTest::RefreshHostList() { 83 bool ChromotingTestDriverEnvironmentTest::RefreshHostList() {
84 return environment_object_->RefreshHostList(); 84 return environment_object_->RefreshHostList() &&
85 environment_object_->FindHostInHostList();
85 } 86 }
86 87
87 HostInfo ChromotingTestDriverEnvironmentTest::CreateFakeHostInfo() { 88 HostInfo ChromotingTestDriverEnvironmentTest::CreateFakeHostInfo() {
88 HostInfo host_info; 89 HostInfo host_info;
89 host_info.host_id = kFakeHostIdValue; 90 host_info.host_id = kFakeHostIdValue;
90 host_info.host_jid = kFakeHostJidValue; 91 host_info.host_jid = kFakeHostJidValue;
91 host_info.host_name = kFakeHostNameValue; 92 host_info.host_name = kFakeHostNameValue;
92 host_info.offline_reason = kFakeHostOfflineReasonValue; 93 host_info.offline_reason = kFakeHostOfflineReasonValue;
93 host_info.public_key = kFakeHostPublicKeyValue; 94 host_info.public_key = kFakeHostPublicKeyValue;
94 host_info.status = kHostStatusOnline; 95 host_info.status = kHostStatusOnline;
(...skipping 11 matching lines...) Expand all
106 EXPECT_TRUE(fake_token_store_.refresh_token_write_attempted()); 107 EXPECT_TRUE(fake_token_store_.refresh_token_write_attempted());
107 EXPECT_EQ(fake_token_store_.stored_refresh_token_value(), 108 EXPECT_EQ(fake_token_store_.stored_refresh_token_value(),
108 kFakeAccessTokenFetcherRefreshTokenValue); 109 kFakeAccessTokenFetcherRefreshTokenValue);
109 110
110 EXPECT_EQ(environment_object_->user_name(), kUserNameValue); 111 EXPECT_EQ(environment_object_->user_name(), kUserNameValue);
111 EXPECT_EQ(environment_object_->host_name(), kHostNameValue); 112 EXPECT_EQ(environment_object_->host_name(), kHostNameValue);
112 EXPECT_EQ(environment_object_->access_token(), 113 EXPECT_EQ(environment_object_->access_token(),
113 kFakeAccessTokenFetcherAccessTokenValue); 114 kFakeAccessTokenFetcherAccessTokenValue);
114 EXPECT_EQ(environment_object_->host_list().size(), 0u); 115 EXPECT_EQ(environment_object_->host_list().size(), 0u);
115 116
116 // Now Retrieve the host list. 117 // Now retrieve the host list.
117 EXPECT_TRUE(environment_object_->WaitForHostOnline(kFakeHostJidValue, 118 EXPECT_TRUE(environment_object_->WaitForHostOnline());
118 kFakeHostNameValue));
119 119
120 // Should only have one host in the list. 120 // Should only have one host in the list.
121 EXPECT_EQ(environment_object_->host_list().size(), kExpectedHostListSize); 121 EXPECT_EQ(environment_object_->host_list().size(), kExpectedHostListSize);
122 HostInfo fake_host = environment_object_->host_list().at(0); 122 HostInfo fake_host = environment_object_->host_list().at(0);
123 EXPECT_EQ(fake_host.host_id, kFakeHostIdValue); 123 EXPECT_EQ(fake_host.host_id, kFakeHostIdValue);
124 EXPECT_EQ(fake_host.host_jid, kFakeHostJidValue); 124 EXPECT_EQ(fake_host.host_jid, kFakeHostJidValue);
125 EXPECT_EQ(fake_host.host_name, kFakeHostNameValue); 125 EXPECT_EQ(fake_host.host_name, kFakeHostNameValue);
126 EXPECT_EQ(fake_host.public_key, kFakeHostPublicKeyValue); 126 EXPECT_EQ(fake_host.public_key, kFakeHostPublicKeyValue);
127 EXPECT_EQ(fake_host.token_url_patterns.at(0), kFakeHostFirstTokenUrlValue); 127 EXPECT_EQ(fake_host.token_url_patterns.at(0), kFakeHostFirstTokenUrlValue);
128 EXPECT_EQ(fake_host.token_url_patterns.at(1), kFakeHostSecondTokenUrlValue); 128 EXPECT_EQ(fake_host.token_url_patterns.at(1), kFakeHostSecondTokenUrlValue);
(...skipping 16 matching lines...) Expand all
145 // disk originally. 145 // disk originally.
146 EXPECT_FALSE(fake_token_store_.refresh_token_write_attempted()); 146 EXPECT_FALSE(fake_token_store_.refresh_token_write_attempted());
147 147
148 // Verify the object was initialized correctly. 148 // Verify the object was initialized correctly.
149 EXPECT_EQ(environment_object_->user_name(), kUserNameValue); 149 EXPECT_EQ(environment_object_->user_name(), kUserNameValue);
150 EXPECT_EQ(environment_object_->host_name(), kHostNameValue); 150 EXPECT_EQ(environment_object_->host_name(), kHostNameValue);
151 EXPECT_EQ(environment_object_->access_token(), 151 EXPECT_EQ(environment_object_->access_token(),
152 kFakeAccessTokenFetcherAccessTokenValue); 152 kFakeAccessTokenFetcherAccessTokenValue);
153 EXPECT_EQ(environment_object_->host_list().size(), 0u); 153 EXPECT_EQ(environment_object_->host_list().size(), 0u);
154 154
155 // Now Retrieve the host list. 155 // Now retrieve the host list.
156 EXPECT_TRUE(environment_object_->WaitForHostOnline(kFakeHostJidValue, 156 EXPECT_TRUE(environment_object_->WaitForHostOnline());
157 kFakeHostNameValue));
158 157
159 // Should only have one host in the list. 158 // Should only have one host in the list.
160 EXPECT_EQ(environment_object_->host_list().size(), kExpectedHostListSize); 159 EXPECT_EQ(environment_object_->host_list().size(), kExpectedHostListSize);
161 160
162 HostInfo fake_host = environment_object_->host_list().at(0); 161 HostInfo fake_host = environment_object_->host_list().at(0);
163 EXPECT_EQ(fake_host.host_id, kFakeHostIdValue); 162 EXPECT_EQ(fake_host.host_id, kFakeHostIdValue);
164 EXPECT_EQ(fake_host.host_jid, kFakeHostJidValue); 163 EXPECT_EQ(fake_host.host_jid, kFakeHostJidValue);
165 EXPECT_EQ(fake_host.host_name, kFakeHostNameValue); 164 EXPECT_EQ(fake_host.host_name, kFakeHostNameValue);
166 EXPECT_EQ(fake_host.public_key, kFakeHostPublicKeyValue); 165 EXPECT_EQ(fake_host.public_key, kFakeHostPublicKeyValue);
167 EXPECT_EQ(fake_host.token_url_patterns.at(0), kFakeHostFirstTokenUrlValue); 166 EXPECT_EQ(fake_host.token_url_patterns.at(0), kFakeHostFirstTokenUrlValue);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_TRUE(environment_object_->Initialize(std::string())); 254 EXPECT_TRUE(environment_object_->Initialize(std::string()));
256 255
257 HostInfo fake_host(CreateFakeHostInfo()); 256 HostInfo fake_host(CreateFakeHostInfo());
258 fake_host.status = kHostStatusOffline; 257 fake_host.status = kHostStatusOffline;
259 258
260 std::vector<HostInfo> fake_host_list(1, fake_host); 259 std::vector<HostInfo> fake_host_list(1, fake_host);
261 fake_host_list_fetcher_.set_retrieved_host_list(fake_host_list); 260 fake_host_list_fetcher_.set_retrieved_host_list(fake_host_list);
262 261
263 environment_object_->SetHostNameForTest(kFakeHostNameValue); 262 environment_object_->SetHostNameForTest(kFakeHostNameValue);
264 environment_object_->SetHostJidForTest(kFakeHostJidValue); 263 environment_object_->SetHostJidForTest(kFakeHostJidValue);
265 EXPECT_FALSE(RefreshHostList()); 264 EXPECT_TRUE(RefreshHostList());
266 EXPECT_FALSE(environment_object_->host_info().IsReadyForConnection()); 265 EXPECT_FALSE(environment_object_->host_info().IsReadyForConnection());
267 } 266 }
268 267
269 TEST_F(ChromotingTestDriverEnvironmentTest, RefreshHostList_HostListEmpty) { 268 TEST_F(ChromotingTestDriverEnvironmentTest, RefreshHostList_HostListEmpty) {
270 EXPECT_TRUE(environment_object_->Initialize(std::string())); 269 EXPECT_TRUE(environment_object_->Initialize(std::string()));
271 270
272 // Set the host list fetcher to return an empty list. 271 // Set the host list fetcher to return an empty list.
273 fake_host_list_fetcher_.set_retrieved_host_list(std::vector<HostInfo>()); 272 fake_host_list_fetcher_.set_retrieved_host_list(std::vector<HostInfo>());
274 environment_object_->SetHostNameForTest(kFakeHostNameValue); 273 environment_object_->SetHostNameForTest(kFakeHostNameValue);
275 environment_object_->SetHostJidForTest(kFakeHostJidValue); 274 environment_object_->SetHostJidForTest(kFakeHostJidValue);
276 EXPECT_FALSE(RefreshHostList()); 275 EXPECT_FALSE(RefreshHostList());
277 EXPECT_FALSE(environment_object_->host_info().IsReadyForConnection()); 276 EXPECT_FALSE(environment_object_->host_info().IsReadyForConnection());
278 } 277 }
279 278
280 } // namespace test 279 } // namespace test
281 } // namespace remoting 280 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/chromoting_test_driver_environment.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698