OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_TEST_APP_REMOTING_CONNECTED_CLIENT_TESTS_H_ | |
6 #define REMOTING_TEST_APP_REMOTING_CONNECTED_CLIENT_TESTS_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "remoting/test/remote_connection_observer.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 namespace base { | |
16 class MessageLoopForIO; | |
17 } | |
18 | |
19 namespace remoting { | |
20 namespace test { | |
21 | |
22 struct ApplicationInfo; | |
23 class TestChromotingClient; | |
24 | |
25 // Supplied by the test code to the fixture to allow for custom handling of | |
26 // specific messages. | |
27 typedef base::Callback<void(const protocol::ExtensionMessage& message)> | |
28 HostMessageReceivedCallback; | |
29 | |
30 // Creates a connection to a remote host when the static SetUpTestCase() method | |
Wez
2015/03/16 22:19:10
This comment should describe the overall intended
joedow
2015/03/18 20:13:09
Done.
| |
31 // is called. This connection is persisted until TearDownTestCase() is called. | |
32 // This means that tests which use this fixture can rely on having a connection | |
Wez
2015/03/16 22:19:10
"This means that" is superfluous.
joedow
2015/03/18 20:13:09
Done.
| |
33 // available to them and do not need to create/manage it themselves. | |
34 // The parameter that is used to instantiate a test using this fixture is the | |
35 // name of the application we want to test. | |
Wez
2015/03/16 22:19:10
This sentence is pretty confusingly worded!
joedow
2015/03/18 20:13:09
My mastery of the English language changes dependi
| |
36 class AppRemotingConnectedClientTests | |
Wez
2015/03/16 22:19:09
Why is this class "*Tests" rather than "*Test"? Ea
joedow
2015/03/18 20:13:09
I've seen 'Tests' used for fixtures but it looks l
| |
37 : public testing::TestWithParam<const char*>, | |
38 public RemoteConnectionObserver { | |
39 public: | |
40 AppRemotingConnectedClientTests(); | |
41 ~AppRemotingConnectedClientTests() override; | |
42 | |
43 // static testing::Test overrides. | |
Wez
2015/03/16 22:19:09
Since these are static, they are presumably overri
joedow
2015/03/18 20:13:09
Acknowledged.
| |
44 static void SetUpTestCase(); | |
45 static void TearDownTestCase(); | |
46 | |
47 protected: | |
48 bool connection_is_ready_for_tests() { | |
49 return connection_is_ready_for_tests_; | |
50 } | |
51 | |
52 // Sends the request to the host and waits for a reply up to |max_wait_time|. | |
53 // Returns true if we received a response within the maximum time limit. | |
54 bool VerifyResponseForSimpleHostMessage( | |
55 const std::string& message_request_title, | |
56 const std::string& message_response_title, | |
57 const std::string& message_payload, | |
58 const base::TimeDelta& max_wait_time); | |
59 | |
60 private: | |
61 // testing::Test interface. | |
62 void SetUp() override; | |
63 void TearDown() override; | |
64 | |
65 // RemoteConnectionObserver interface. | |
66 void ConnectionStateChanged(protocol::ConnectionToHost::State state, | |
67 protocol::ErrorCode error_code) override; | |
68 void ConnectionReady(bool ready) override; | |
69 void HostMessageReceived(const protocol::ExtensionMessage& message) override; | |
70 | |
71 // Starts a connection with the remote host defined by the parameter.. | |
Wez
2015/03/16 22:19:09
typo: spurious .
joedow
2015/03/18 20:13:09
Done.
| |
72 void StartConnection(); | |
73 | |
74 // Sends the final client details to the host in order to complete the | |
75 // connection. | |
76 void SendClientConnectionDetailsToHost(); | |
77 | |
78 // Runs |done_closure_| when an onWindowAdded message with |main_window_name| | |
79 // for the title is passed in. | |
Wez
2015/03/16 22:19:09
This comment is confusing since it doesn't relate
joedow
2015/03/18 20:13:09
Done.
| |
80 void AddWindowMessageHandler( | |
81 const std::string& main_window_name, | |
82 const remoting::protocol::ExtensionMessage& message); | |
83 | |
84 // Tracks the details for the application the tests are targeting. | |
85 const ApplicationInfo& application_info_; | |
86 | |
87 // Used to signal when an action has been completed. | |
88 base::Closure done_closure_; | |
89 | |
90 // Used to customize the message handling behavior between tests. Called when | |
91 // a host message is received. | |
92 HostMessageReceivedCallback host_message_received_callback_; | |
Wez
2015/03/16 22:19:09
It's not clear how tests can customize this, since
joedow
2015/03/18 20:13:09
Done.
| |
93 | |
94 // Tracks the state of the connection between tests. True when we have a | |
95 // chromoting connection to the remote host established and the main | |
96 // application window is visible. | |
97 static bool connection_is_ready_for_tests_; | |
98 | |
99 // Used to post tasks by |client_| and tests. | |
100 static scoped_ptr<base::MessageLoopForIO> message_loop_; | |
101 | |
102 // Creates and manages the connection to the remote host. | |
103 static scoped_ptr<TestChromotingClient> client_; | |
Wez
2015/03/16 22:19:09
Do we really want to re-use a connection across te
joedow
2015/03/18 20:13:09
I think I started out with a more complicated 'fir
| |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(AppRemotingConnectedClientTests); | |
106 }; | |
107 | |
108 } // namespace test | |
109 } // namespace remoting | |
110 | |
111 #endif // REMOTING_TEST_APP_REMOTING_CONNECTED_CLIENT_TESTS_H_ | |
OLD | NEW |