1 // Copyright 2013 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.
5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h"
7 #include "chrome/test/remoting/remote_desktop_browsertest.h"
8 #include "chrome/test/remoting/waiter.h"
12 class Me2MeBrowserTest
: public RemoteDesktopBrowserTest
{
14 void TestKeyboardInput();
15 void TestMouseInput();
17 void ConnectPinlessAndCleanupPairings(bool cleanup_all
);
18 bool IsPairingSpinnerHidden();
21 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest
,
22 MANUAL_Me2Me_Connect_Local_Host
) {
25 ConnectToLocalHost(false);
27 // TODO(chaitali): Change the mouse input test to also work in the
28 // HTTP server framework
35 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest
,
36 MANUAL_Me2Me_Connect_Remote_Host
) {
37 VerifyInternetAccess();
39 LaunchChromotingApp();
41 // Authorize, Authenticate, and Approve.
45 ConnectToRemoteHost(remote_host_name(), false);
47 // TODO(weitaosu): Find a way to verify keyboard input injection.
48 // We cannot use TestKeyboardInput because it assumes
49 // that the client and the host are on the same machine.
55 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest
,
56 MANUAL_Me2Me_Connect_Pinless
) {
59 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message"))
60 << "The host must have no pairings before running the pinless test.";
62 // Test that cleanup works with either the Delete or Delete all buttons.
63 ConnectPinlessAndCleanupPairings(false);
64 ConnectPinlessAndCleanupPairings(true);
69 void Me2MeBrowserTest::TestKeyboardInput() {
70 // We will assume here that the browser window is already open on the host
72 // Press tab to put focus on the textbox.
73 SimulateKeyPressWithCode(ui::VKEY_TAB
, "Tab", false, false, false, false);
75 // Write some text in the box and press enter
76 std::string text
= "Abigail";
77 SimulateStringInput(text
);
78 SimulateKeyPressWithCode(
79 ui::VKEY_RETURN
, "Enter", false, false, false, false);
81 // Wait until the client tab sets the right variables
82 ConditionalTimeoutWaiter
waiter(
83 base::TimeDelta::FromSeconds(10),
84 base::TimeDelta::FromMilliseconds(500),
85 base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete
,
87 "testResult.keypressSucceeded"));
88 EXPECT_TRUE(waiter
.Wait());
90 // Check that the text we got is correct
91 EXPECT_TRUE(ExecuteScriptAndExtractBool(
93 "testResult.keypressText == '" + text
+ "'"));
96 void Me2MeBrowserTest::TestMouseInput() {
97 SimulateMouseLeftClickAt(10, 50);
98 // TODO: Verify programatically the mouse events are received by the host.
99 // This will be tricky as it depends on the host OS, window manager, desktop
100 // layout, and screen resolution. Until then we need to visually verify that
101 // "Dash Home" is clicked on a Unity window manager.
102 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait());
105 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all
) {
106 // First connection: verify that a PIN is requested, and request pairing.
107 ConnectToLocalHost(true);
110 // TODO(jamiewalch): This reload is only needed because there's a bug in the
111 // web-app whereby it doesn't refresh its pairing state correctly.
112 // http://crbug.com/311290
113 LaunchChromotingApp();
114 ASSERT_TRUE(HtmlElementVisible("paired-client-manager-message"));
116 // Second connection: verify that no PIN is requested.
117 ClickOnControl("this-host-connect");
121 // Clean up pairings.
122 ClickOnControl("open-paired-client-manager-dialog");
123 ASSERT_TRUE(HtmlElementVisible("paired-client-manager-dialog"));
126 ClickOnControl("delete-all-paired-clients");
128 std::string host_id
= ExecuteScriptAndExtractString(
129 "remoting.pairedClientManager.getFirstClientIdForTesting_()");
130 std::string node_id
= "delete-client-" + host_id
;
131 ClickOnControl(node_id
);
134 // Wait for the "working" spinner to disappear. The spinner is shown by both
135 // methods of deleting a host and is removed when the operation completes.
136 ConditionalTimeoutWaiter
waiter(
137 base::TimeDelta::FromSeconds(5),
138 base::TimeDelta::FromMilliseconds(200),
139 base::Bind(&Me2MeBrowserTest::IsPairingSpinnerHidden
, this));
140 EXPECT_TRUE(waiter
.Wait());
141 EXPECT_TRUE(ExecuteScriptAndExtractBool(
142 "document.getElementById('delete-all-paired-clients').disabled"));
144 ClickOnControl("close-paired-client-manager-dialog");
145 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-dialog"));
146 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message"));
149 bool Me2MeBrowserTest::IsPairingSpinnerHidden() {
150 return !HtmlElementVisible("paired-client-manager-dialog-working");
153 } // namespace remoting