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 |
| 18 // Note: Make sure to restart the host before running this test. Connecting to |
| 19 // a previously connected host will output the time to reconnect versus the time |
| 20 // to connect. |
18 TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) { | 21 TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) { |
19 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); | 22 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); |
20 EXPECT_TRUE(connected); | 23 EXPECT_TRUE(connected); |
21 | 24 |
22 Disconnect(); | 25 Disconnect(); |
23 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( | 26 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( |
24 protocol::ConnectionToHost::State::INITIALIZING, | 27 protocol::ConnectionToHost::State::INITIALIZING, |
25 protocol::ConnectionToHost::State::CLOSED).is_max()); | 28 protocol::ConnectionToHost::State::CLOSED).is_max()); |
26 | 29 |
27 int authentication_time = connection_time_observer_->GetStateTransitionTime( | 30 int authentication_time = connection_time_observer_->GetStateTransitionTime( |
28 protocol::ConnectionToHost::State::INITIALIZING, | 31 protocol::ConnectionToHost::State::INITIALIZING, |
29 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); | 32 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); |
30 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); | 33 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); |
31 | 34 |
32 int authenticated_to_connected_time = | 35 int authenticated_to_connected_time = |
33 connection_time_observer_->GetStateTransitionTime( | 36 connection_time_observer_->GetStateTransitionTime( |
34 protocol::ConnectionToHost::State::AUTHENTICATED, | 37 protocol::ConnectionToHost::State::AUTHENTICATED, |
35 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); | 38 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); |
36 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); | 39 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); |
37 | 40 |
38 connection_time_observer_->DisplayConnectionStats(); | 41 connection_time_observer_->DisplayConnectionStats(); |
39 } | 42 } |
40 | 43 |
| 44 // Note: Make sure to restart the host before running this test. If the host |
| 45 // is not restarted after a previous connection, then the first connection will |
| 46 // be a reconnect and the second connection will be a second reconnect. |
41 TEST_F(ChromotingTestFixture, TestMeasureReconnectPerformance) { | 47 TEST_F(ChromotingTestFixture, TestMeasureReconnectPerformance) { |
42 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); | 48 bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); |
43 EXPECT_TRUE(connected); | 49 EXPECT_TRUE(connected); |
44 | 50 |
45 Disconnect(); | 51 Disconnect(); |
46 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( | 52 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( |
47 protocol::ConnectionToHost::State::INITIALIZING, | 53 protocol::ConnectionToHost::State::INITIALIZING, |
48 protocol::ConnectionToHost::State::CLOSED).is_max()); | 54 protocol::ConnectionToHost::State::CLOSED).is_max()); |
49 | 55 |
50 int authentication_time = connection_time_observer_->GetStateTransitionTime( | 56 int authentication_time = connection_time_observer_->GetStateTransitionTime( |
51 protocol::ConnectionToHost::State::INITIALIZING, | 57 protocol::ConnectionToHost::State::INITIALIZING, |
52 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); | 58 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); |
53 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); | 59 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); |
54 | 60 |
55 int authenticated_to_connected_time = | 61 int authenticated_to_connected_time = |
56 connection_time_observer_->GetStateTransitionTime( | 62 connection_time_observer_->GetStateTransitionTime( |
57 protocol::ConnectionToHost::State::AUTHENTICATED, | 63 protocol::ConnectionToHost::State::AUTHENTICATED, |
58 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); | 64 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); |
59 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); | 65 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); |
60 | 66 |
61 connection_time_observer_->DisplayConnectionStats(); | |
62 | |
63 // Begin reconnection to same host. | 67 // Begin reconnection to same host. |
64 connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); | 68 connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds); |
65 EXPECT_TRUE(connected); | 69 EXPECT_TRUE(connected); |
66 | 70 |
67 Disconnect(); | 71 Disconnect(); |
68 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( | 72 EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime( |
69 protocol::ConnectionToHost::State::INITIALIZING, | 73 protocol::ConnectionToHost::State::INITIALIZING, |
70 protocol::ConnectionToHost::State::CLOSED).is_max()); | 74 protocol::ConnectionToHost::State::CLOSED).is_max()); |
71 | 75 |
72 authentication_time = connection_time_observer_->GetStateTransitionTime( | 76 authentication_time = connection_time_observer_->GetStateTransitionTime( |
73 protocol::ConnectionToHost::State::INITIALIZING, | 77 protocol::ConnectionToHost::State::INITIALIZING, |
74 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); | 78 protocol::ConnectionToHost::State::AUTHENTICATED).InMilliseconds(); |
75 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); | 79 EXPECT_LE(authentication_time, kPinBasedMaxAuthenticationTimeMs); |
76 | 80 |
77 authenticated_to_connected_time = | 81 authenticated_to_connected_time = |
78 connection_time_observer_->GetStateTransitionTime( | 82 connection_time_observer_->GetStateTransitionTime( |
79 protocol::ConnectionToHost::State::AUTHENTICATED, | 83 protocol::ConnectionToHost::State::AUTHENTICATED, |
80 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); | 84 protocol::ConnectionToHost::State::CONNECTED).InMilliseconds(); |
81 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); | 85 EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs); |
82 | 86 |
83 connection_time_observer_->DisplayConnectionStats(); | 87 connection_time_observer_->DisplayConnectionStats(); |
84 } | 88 } |
85 | 89 |
86 } // namespace test | 90 } // namespace test |
87 } // namespace remoting | 91 } // namespace remoting |
OLD | NEW |