summaryrefslogtreecommitdiffstats
path: root/remoting/test/chromoting_test_driver_tests.cc
blob: 8ab77654b06f8dc0f6b1af0bc3d3540a790ffb71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/test/chromoting_test_fixture.h"
#include "remoting/test/connection_time_observer.h"

namespace {
const base::TimeDelta kPinBasedMaxConnectionTimeInSeconds =
    base::TimeDelta::FromSeconds(5);
}

namespace remoting {
namespace test {

// Note: Make sure to restart the host before running this test. Connecting to
// a previously connected host will output the time to reconnect versus the time
// to connect.
TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) {
  bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
  EXPECT_TRUE(connected);

  Disconnect();
  EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime(
      protocol::ConnectionToHost::State::INITIALIZING,
      protocol::ConnectionToHost::State::CLOSED).is_max());

  connection_time_observer_->DisplayConnectionStats();
}

// Note: Make sure to restart the host before running this test. If the host
// is not restarted after a previous connection, then the first connection will
// be a reconnect and the second connection will be a second reconnect.
TEST_F(ChromotingTestFixture, TestMeasureReconnectPerformance) {
  bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
  EXPECT_TRUE(connected);

  Disconnect();
  EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime(
      protocol::ConnectionToHost::State::INITIALIZING,
      protocol::ConnectionToHost::State::CLOSED).is_max());

  // Begin reconnection to same host.
  connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
  EXPECT_TRUE(connected);

  Disconnect();
  EXPECT_FALSE(connection_time_observer_->GetStateTransitionTime(
      protocol::ConnectionToHost::State::INITIALIZING,
      protocol::ConnectionToHost::State::CLOSED).is_max());

  connection_time_observer_->DisplayConnectionStats();
}

}  // namespace test
}  // namespace remoting