| 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 #include "remoting/test/chromoting_test_fixture.h" | 5 #include "remoting/test/chromoting_test_fixture.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "remoting/test/chromoting_test_driver_environment.h" | 10 #include "remoting/test/chromoting_test_driver_environment.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 CreateObserver(); | 62 CreateObserver(); |
| 63 | 63 |
| 64 base::Timer timer(true, false); | 64 base::Timer timer(true, false); |
| 65 timer.Start(FROM_HERE, max_time_to_connect, run_loop.QuitClosure()); | 65 timer.Start(FROM_HERE, max_time_to_connect, run_loop.QuitClosure()); |
| 66 | 66 |
| 67 connection_time_observer_->ConnectionStateChanged( | 67 connection_time_observer_->ConnectionStateChanged( |
| 68 protocol::ConnectionToHost::State::INITIALIZING, | 68 protocol::ConnectionToHost::State::INITIALIZING, |
| 69 protocol::ErrorCode::OK); | 69 protocol::ErrorCode::OK); |
| 70 test_chromoting_client_->StartConnection( | 70 test_chromoting_client_->StartConnection( |
| 71 g_chromoting_shared_data->use_test_environment(), |
| 71 g_chromoting_shared_data->host_info().GenerateConnectionSetupInfo( | 72 g_chromoting_shared_data->host_info().GenerateConnectionSetupInfo( |
| 72 g_chromoting_shared_data->access_token(), | 73 g_chromoting_shared_data->access_token(), |
| 73 g_chromoting_shared_data->user_name(), | 74 g_chromoting_shared_data->user_name(), |
| 74 g_chromoting_shared_data->pin())); | 75 g_chromoting_shared_data->pin())); |
| 75 run_loop.Run(); | 76 run_loop.Run(); |
| 76 | 77 |
| 77 // Note: Under different network conditions, connection time will have | 78 // Note: Under different network conditions, connection time will have |
| 78 // greater variance. |max_time_to_connect| may need to be larger in high | 79 // greater variance. |max_time_to_connect| may need to be larger in high |
| 79 // latency network environments. | 80 // latency network environments. |
| 80 if (connection_time_observer_->GetStateTransitionTime( | 81 if (connection_time_observer_->GetStateTransitionTime( |
| 81 protocol::ConnectionToHost::State::INITIALIZING, | 82 protocol::ConnectionToHost::State::INITIALIZING, |
| 82 protocol::ConnectionToHost::State::CONNECTED).is_max()) { | 83 protocol::ConnectionToHost::State::CONNECTED).is_max()) { |
| 83 LOG(ERROR) << "Chromoting client did not connect to requested host"; | 84 LOG(ERROR) << "Chromoting client did not connect to requested host"; |
| 84 return false; | 85 return false; |
| 85 } | 86 } |
| 86 | 87 |
| 87 return true; | 88 return true; |
| 88 } | 89 } |
| 89 | 90 |
| 90 void ChromotingTestFixture::TearDown() { | 91 void ChromotingTestFixture::TearDown() { |
| 91 // If a chromoting connection is still connected, we want to end the | 92 // If a chromoting connection is still connected, we want to end the |
| 92 // connection before starting the next test. | 93 // connection before starting the next test. |
| 93 Disconnect(); | 94 Disconnect(); |
| 94 DestroyObserver(); | 95 DestroyObserver(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace test | 98 } // namespace test |
| 98 } // namespace remoting | 99 } // namespace remoting |
| OLD | NEW |