blob: cf62ccd64234c3029a3ec7d26850c510306304c5 [file] [log] [blame]
tonychun29b70952015-08-06 04:03:121// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef REMOTING_TEST_CHROMOTING_TEST_FIXTURE_H_
6#define REMOTING_TEST_CHROMOTING_TEST_FIXTURE_H_
7
dcheng0765c492016-04-06 22:41:538#include <memory>
9
avi5a080f012015-12-22 23:15:4310#include "base/macros.h"
tonychun29b70952015-08-06 04:03:1211#include "base/threading/thread_checker.h"
12#include "testing/gtest/include/gtest/gtest.h"
13
tonychun29b70952015-08-06 04:03:1214namespace remoting {
15namespace test {
16
17class ConnectionTimeObserver;
18class TestChromotingClient;
tonychun29b70952015-08-06 04:03:1219
20// Provides chromoting connection capabilities for tests to use. Performance
21// metrics of the established connection are readily available to calculate
22// through the ConnectionTimeObserver.
23class ChromotingTestFixture
24 : public testing::Test {
25 public:
26 ChromotingTestFixture();
27 ~ChromotingTestFixture() override;
28
29 // Client initiates a session with a host to establish a chromoting
30 // connection. Only has |timeout| seconds to connect to host.
31 bool ConnectToHost(const base::TimeDelta& timeout);
32
33 // Ends a chromoting connection with the host.
34 void Disconnect();
35
36 protected:
37 // Observes and saves the times when a chromoting client changes its state.
dcheng0765c492016-04-06 22:41:5338 std::unique_ptr<ConnectionTimeObserver> connection_time_observer_;
tonychun29b70952015-08-06 04:03:1239
40 private:
41 // testing::Test overrides.
tonychun29b70952015-08-06 04:03:1242 void TearDown() override;
43
tonychun43fcaac2015-08-13 02:52:2244 // Creates |connection_time_observer_| to attach to |test_chromoting_client_|.
45 void CreateObserver();
46
47 // Detaches |connection_time_observer_| and destroys it.
48 void DestroyObserver();
49
tonychun29b70952015-08-06 04:03:1250 // Creates and manages the connection to the remote host.
dcheng0765c492016-04-06 22:41:5351 std::unique_ptr<TestChromotingClient> test_chromoting_client_;
tonychun29b70952015-08-06 04:03:1252
53 base::ThreadChecker thread_checker_;
54
55 DISALLOW_COPY_AND_ASSIGN(ChromotingTestFixture);
56};
57
58} // namespace test
59} // namespace remoting
60
61#endif // REMOTING_TEST_CHROMOTING_TEST_FIXTURE_H_