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 #include "remoting/test/chromoting_test_fixture.h" | 5 #include "remoting/test/chromoting_test_fixture.h" |
| 6 #include "remoting/test/connection_time_observer.h" | 6 #include "remoting/test/connection_time_observer.h" |
| 7 | 7 |
| 8 namespace { | 8 namespace { |
| 9 const base::TimeDelta kPinBasedMaxConnectionTimeInSeconds = | 9 const base::TimeDelta kPinBasedMaxConnectionTimeInSeconds = |
| 10 base::TimeDelta::FromSeconds(4); | 10 base::TimeDelta::FromSeconds(4); |
| 11 const int kPinBasedMaxAuthenticationTimeMs = 2000; | 11 const int kPinBasedMaxAuthenticationTimeMs = 2000; |
| 12 const int kMaxTimeToConnectMs = 2000; | 12 const int kMaxTimeToConnectMs = 2000; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
|
joedow
2015/08/13 20:04:39
To add on to Anand's comments a bit, can you add a
tonychun
2015/08/13 21:23:00
Done.
| |
| 18 TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) { | 18 TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) { |
| 19 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); | 19 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); |
| 20 EXPECT_TRUE(connected); | 20 EXPECT_TRUE(connected); |
| 21 | 21 |
| 22 Disconnect(); | 22 Disconnect(); |
| 23 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( | 23 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( |
| 24 protocol::ConnectionToHost::State::INITIALIZING, | 24 protocol::ConnectionToHost::State::INITIALIZING, |
| 25 protocol::ConnectionToHost::State::CLOSED).is_max()); | 25 protocol::ConnectionToHost::State::CLOSED).is_max()); |
| 26 | 26 |
| 27 int authentication_time = connection_time_observer_->GetStateTransitionTime( | 27 int authentication_time = connection_time_observer_->GetStateTransitionTime( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 51 protocol::ConnectionToHost::State::INITIALIZING, | 51 protocol::ConnectionToHost::State::INITIALIZING, |
| 52 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); | 52 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); |
| 53 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); | 53 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); |
| 54 | 54 |
| 55 int authenticated_to_connected_time = | 55 int authenticated_to_connected_time = |
| 56 connection_time_observer_->GetStateTransitionTime( | 56 connection_time_observer_->GetStateTransitionTime( |
| 57 protocol::ConnectionToHost::State::AUTHENTICATED, | 57 protocol::ConnectionToHost::State::AUTHENTICATED, |
| 58 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); | 58 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); |
| 59 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); | 59 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); |
| 60 | 60 |
| 61 connection_time_observer_->DisplayConnectionStats(); | |
| 62 | |
| 63 // Begin reconnection to same host. | 61 // Begin reconnection to same host. |
| 64 connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); | 62 connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); |
| 65 EXPECT_TRUE(connected); | 63 EXPECT_TRUE(connected); |
| 66 | 64 |
| 67 Disconnect(); | 65 Disconnect(); |
| 68 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( | 66 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( |
| 69 protocol::ConnectionToHost::State::INITIALIZING, | 67 protocol::ConnectionToHost::State::INITIALIZING, |
| 70 protocol::ConnectionToHost::State::CLOSED).is_max()); | 68 protocol::ConnectionToHost::State::CLOSED).is_max()); |
| 71 | 69 |
| 72 authentication_time = connection_time_observer_->GetStateTransitionTime( | 70 authentication_time = connection_time_observer_->GetStateTransitionTime( |
| 73 protocol::ConnectionToHost::State::INITIALIZING, | 71 protocol::ConnectionToHost::State::INITIALIZING, |
| 74 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); | 72 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); |
| 75 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); | 73 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); |
| 76 | 74 |
| 77 authenticated_to_connected_time = | 75 authenticated_to_connected_time = |
| 78 connection_time_observer_->GetStateTransitionTime( | 76 connection_time_observer_->GetStateTransitionTime( |
| 79 protocol::ConnectionToHost::State::AUTHENTICATED, | 77 protocol::ConnectionToHost::State::AUTHENTICATED, |
| 80 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); | 78 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); |
| 81 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); | 79 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); |
| 82 | 80 |
| 83 connection_time_observer_->DisplayConnectionStats(); | 81 connection_time_observer_->DisplayConnectionStats(); |
| 84 } | 82 } |
| 85 | 83 |
| 86 } // namespace test | 84 } // namespace test |
| 87 } // namespace remoting | 85 } // namespace remoting |
| OLD | NEW |