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

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: Edited merge errors, comments, and optimized code. 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/test_chromoting_client.h" 9 #include "remoting/test/test_chromoting_client.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 } 106 }
107 107
108 void TestChromotingClientTest::ConnectionReady(bool ready) { 108 void TestChromotingClientTest::ConnectionReady(bool ready) {
109 if (ready) { 109 if (ready) {
110 is_connected_to_host_ = true; 110 is_connected_to_host_ = true;
111 } 111 }
112 } 112 }
113 113
114 TEST_F(TestChromotingClientTest, StartConnectionAndDisconnect) { 114 TEST_F(TestChromotingClientTest, StartConnectionAndDisconnect) {
115 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 115 test_chromoting_client_->StartConnection(
116 remote_host_info_); 116 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
117 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 117 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
118 EXPECT_EQ(protocol::OK, error_code_); 118 EXPECT_EQ(protocol::OK, error_code_);
119 EXPECT_FALSE(is_connected_to_host_); 119 EXPECT_FALSE(is_connected_to_host_);
120 120
121 // Simulate an AUTHENTICATED message being sent from the Jingle session. 121 // Simulate an AUTHENTICATED message being sent from the Jingle session.
122 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED, 122 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED,
123 protocol::OK); 123 protocol::OK);
124 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED, 124 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED,
125 connection_state_); 125 connection_state_);
126 EXPECT_EQ(protocol::OK, error_code_); 126 EXPECT_EQ(protocol::OK, error_code_);
(...skipping 12 matching lines...) Expand all
139 EXPECT_TRUE(is_connected_to_host_); 139 EXPECT_TRUE(is_connected_to_host_);
140 140
141 test_chromoting_client_->EndConnection(); 141 test_chromoting_client_->EndConnection();
142 EXPECT_EQ(protocol::ConnectionToHost::State::CLOSED, connection_state_); 142 EXPECT_EQ(protocol::ConnectionToHost::State::CLOSED, connection_state_);
143 EXPECT_EQ(protocol::OK, error_code_); 143 EXPECT_EQ(protocol::OK, error_code_);
144 EXPECT_FALSE(is_connected_to_host_); 144 EXPECT_FALSE(is_connected_to_host_);
145 } 145 }
146 146
147 TEST_F(TestChromotingClientTest, 147 TEST_F(TestChromotingClientTest,
148 StartConnectionThenFailWithAuthenticationError) { 148 StartConnectionThenFailWithAuthenticationError) {
149 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 149 test_chromoting_client_->StartConnection(
150 remote_host_info_); 150 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
151 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 151 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
152 EXPECT_EQ(protocol::OK, error_code_); 152 EXPECT_EQ(protocol::OK, error_code_);
153 EXPECT_FALSE(is_connected_to_host_); 153 EXPECT_FALSE(is_connected_to_host_);
154 154
155 fake_connection_to_host_->SignalStateChange(protocol::Session::FAILED, 155 fake_connection_to_host_->SignalStateChange(protocol::Session::FAILED,
156 protocol::AUTHENTICATION_FAILED); 156 protocol::AUTHENTICATION_FAILED);
157 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 157 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
158 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_); 158 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_);
159 EXPECT_FALSE(is_connected_to_host_); 159 EXPECT_FALSE(is_connected_to_host_);
160 160
161 // Close the connection via the TestChromotingClient and verify the error 161 // Close the connection via the TestChromotingClient and verify the error
162 // state is persisted. 162 // state is persisted.
163 test_chromoting_client_->EndConnection(); 163 test_chromoting_client_->EndConnection();
164 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 164 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
165 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_); 165 EXPECT_EQ(protocol::ErrorCode::AUTHENTICATION_FAILED, error_code_);
166 EXPECT_FALSE(is_connected_to_host_); 166 EXPECT_FALSE(is_connected_to_host_);
167 } 167 }
168 168
169 TEST_F(TestChromotingClientTest, StartConnectionThenFailWithUnknownError) { 169 TEST_F(TestChromotingClientTest, StartConnectionThenFailWithUnknownError) {
170 test_chromoting_client_->StartConnection(kTestUserName, kAccessToken, 170 test_chromoting_client_->StartConnection(
171 remote_host_info_); 171 remote_host_info_.GenerateConnectionSetupInfo(kAccessToken, kTestUserName));
172 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_); 172 EXPECT_EQ(protocol::ConnectionToHost::State::CONNECTING, connection_state_);
173 EXPECT_EQ(protocol::OK, error_code_); 173 EXPECT_EQ(protocol::OK, error_code_);
174 EXPECT_FALSE(is_connected_to_host_); 174 EXPECT_FALSE(is_connected_to_host_);
175 175
176 // Simulate an AUTHENTICATED message being sent from the Jingle session. 176 // Simulate an AUTHENTICATED message being sent from the Jingle session.
177 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED, 177 fake_connection_to_host_->SignalStateChange(protocol::Session::AUTHENTICATED,
178 protocol::OK); 178 protocol::OK);
179 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED, 179 EXPECT_EQ(protocol::ConnectionToHost::State::AUTHENTICATED,
180 connection_state_); 180 connection_state_);
181 EXPECT_EQ(protocol::OK, error_code_); 181 EXPECT_EQ(protocol::OK, error_code_);
(...skipping 20 matching lines...) Expand all
202 // Close the connection via the TestChromotingClient and verify the error 202 // Close the connection via the TestChromotingClient and verify the error
203 // state is persisted. 203 // state is persisted.
204 test_chromoting_client_->EndConnection(); 204 test_chromoting_client_->EndConnection();
205 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); 205 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_);
206 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_); 206 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_);
207 EXPECT_FALSE(is_connected_to_host_); 207 EXPECT_FALSE(is_connected_to_host_);
208 } 208 }
209 209
210 } // namespace test 210 } // namespace test
211 } // namespace remoting 211 } // 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