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

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

Issue 1237093004: Support for connecting to localhost on the chromoting test driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made changes to comments and removed unused headers. Created 5 years, 5 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
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 <string> 5 #include <string>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "remoting/protocol/fake_connection_to_host.h" 8 #include "remoting/protocol/fake_connection_to_host.h"
9 #include "remoting/test/remote_host_info.h"
tonychun 2015/07/20 18:13:01 Tests use remote_host_info
joedow 2015/07/20 18:23:07 Sorry for the late comment on this file, but I'm w
9 #include "remoting/test/test_chromoting_client.h" 10 #include "remoting/test/test_chromoting_client.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace { 13 namespace {
13 const char kTestUserName[] = "test_user@faux_address.com"; 14 const char kTestUserName[] = "test_user@faux_address.com";
14 const char kAccessToken[] = "faux_access_token"; 15 const char kAccessToken[] = "faux_access_token";
15 } 16 }
16 17
17 namespace remoting { 18 namespace remoting {
18 namespace test { 19 namespace test {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 106 }
106 } 107 }
107 108
108 void TestChromotingClientTest::ConnectionReady(bool ready) { 109 void TestChromotingClientTest::ConnectionReady(bool ready) {
109 if (ready) { 110 if (ready) {
110 is_connected_to_host_ = true; 111 is_connected_to_host_ = true;
111 } 112 }
112 } 113 }
113 114
114 TEST_F(TestChromotingClientTest, StartConnectionAndDisconnect) { 115 TEST_F(TestChromotingClientTest, StartConnectionAndDisconnect) {
115 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 116 test_chromoting_client_->StartConnection(
116 remote_host_info_); 117 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
117 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 118 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
118 EXPECT_EQ(protocol::OK, error_code_); 119 EXPECT_EQ(protocol::OK, error_code_);
119 EXPECT_FALSE(is_connected_to_host_); 120 EXPECT_FALSE(is_connected_to_host_);
120 121
121 // Simulate an AUTHENTICATED message being sent from the Jingle session. 122 // Simulate an AUTHENTICATED message being sent from the Jingle session.
122 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED, 123 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED,
123 protocol::OK); 124 protocol::OK);
124 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED, 125 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED,
125 connection_state_); 126 connection_state_);
126 EXPECT_EQ(protocol::OK, error_code_); 127 EXPECT_EQ(protocol::OK, error_code_);
(...skipping 12 matching lines...) Expand all
139 EXPECT_TRUE(is_connected_to_host_); 140 EXPECT_TRUE(is_connected_to_host_);
140 141
141 test_chromoting_client_->EndConnection(); 142 test_chromoting_client_->EndConnection();
142 EXPECT_EQ(protocol::ConnectionToHost::State::CLOSED, connection_state_); 143 EXPECT_EQ(protocol::ConnectionToHost::State::CLOSED, connection_state_);
143 EXPECT_EQ(protocol::OK, error_code_); 144 EXPECT_EQ(protocol::OK, error_code_);
144 EXPECT_FALSE(is_connected_to_host_); 145 EXPECT_FALSE(is_connected_to_host_);
145 } 146 }
146 147
147 TEST_F(TestChromotingClientTest, 148 TEST_F(TestChromotingClientTest,
148 StartConnectionThenFailWithAuthenticationError) { 149 StartConnectionThenFailWithAuthenticationError) {
149 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 150 test_chromoting_client_->StartConnection(
150 remote_host_info_); 151 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
151 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 152 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
152 EXPECT_EQ(protocol::OK, error_code_); 153 EXPECT_EQ(protocol::OK, error_code_);
153 EXPECT_FALSE(is_connected_to_host_); 154 EXPECT_FALSE(is_connected_to_host_);
154 155
155 fake_connection_to_host_->SignalStateChange(protocol::Session::FAILED, 156 fake_connection_to_host_->SignalStateChange(protocol::Session::FAILED,
156 protocol::AUTHENTICATION_FAILED); 157 protocol::AUTHENTICATION_FAILED);
157 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 158 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
158 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_); 159 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_);
159 EXPECT_FALSE(is_connected_to_host_); 160 EXPECT_FALSE(is_connected_to_host_);
160 161
161 // Close the connection via the TestChromotingClient and verify the error 162 // Close the connection via the TestChromotingClient and verify the error
162 // state is persisted. 163 // state is persisted.
163 test_chromoting_client_->EndConnection(); 164 test_chromoting_client_->EndConnection();
164 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 165 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
165 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_); 166 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_);
166 EXPECT_FALSE(is_connected_to_host_); 167 EXPECT_FALSE(is_connected_to_host_);
167 } 168 }
168 169
169 TEST_F(TestChromotingClientTest, StartConnectionThenFailWithUnknownError) { 170 TEST_F(TestChromotingClientTest, StartConnectionThenFailWithUnknownError) {
170 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 171 test_chromoting_client_->StartConnection(
171 remote_host_info_); 172 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
172 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 173 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
173 EXPECT_EQ(protocol::OK, error_code_); 174 EXPECT_EQ(protocol::OK, error_code_);
174 EXPECT_FALSE(is_connected_to_host_); 175 EXPECT_FALSE(is_connected_to_host_);
175 176
176 // Simulate an AUTHENTICATED message being sent from the Jingle session. 177 // Simulate an AUTHENTICATED message being sent from the Jingle session.
177 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED, 178 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED,
178 protocol::OK); 179 protocol::OK);
179 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED, 180 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED,
180 connection_state_); 181 connection_state_);
181 EXPECT_EQ(protocol::OK, error_code_); 182 EXPECT_EQ(protocol::OK, error_code_);
(...skipping 20 matching lines...) Expand all
202 // Close the connection via the TestChromotingClient and verify the error 203 // Close the connection via the TestChromotingClient and verify the error
203 // state is persisted. 204 // state is persisted.
204 test_chromoting_client_->EndConnection(); 205 test_chromoting_client_->EndConnection();
205 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 206 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
206 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_); 207 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_);
207 EXPECT_FALSE(is_connected_to_host_); 208 EXPECT_FALSE(is_connected_to_host_);
208 } 209 }
209 210
210 } // namespace test 211 } // namespace test
211 } // namespace remoting 212 } // namespace remoting
OLDNEW
« remoting/test/test_chromoting_client.cc ('K') | « remoting/test/test_chromoting_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698