Fix issue with browser action toolbar putting all extension icons in overflow once...
[chromium-blink-merge.git] / chrome / test / remoting / me2me_browsertest.cc
blob41286daa2818a4a7d63bcf2afe5403252c5c546d
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/file_util.h"
6 #include "base/files/file_path.h"
7 #include "chrome/test/remoting/remote_desktop_browsertest.h"
8 #include "chrome/test/remoting/waiter.h"
10 namespace remoting {
12 class Me2MeBrowserTest : public RemoteDesktopBrowserTest {
13 protected:
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) {
23 VerifyInternetAccess();
24 Install();
25 LaunchChromotingApp();
27 // Authorize, Authenticate, and Approve.
28 Auth();
29 ExpandMe2Me();
31 ConnectToLocalHost(false);
33 OpenClientBrowserPage();
35 TestKeyboardInput();
37 // TODO(chaitali): Change the mouse input test to also work in the
38 // HTTP server framework
39 // TestMouseInput();
41 DisconnectMe2Me();
42 Cleanup();
45 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest,
46 MANUAL_Me2Me_Connect_Remote_Host) {
47 VerifyInternetAccess();
48 Install();
49 LaunchChromotingApp();
51 // Authorize, Authenticate, and Approve.
52 Auth();
53 ExpandMe2Me();
55 ConnectToRemoteHost(remote_host_name(), false);
57 // TODO(weitaosu): Find a way to verify keyboard input injection.
58 // We cannot use TestKeyboardInput because it assumes
59 // that the client and the host are on the same machine.
61 DisconnectMe2Me();
62 Cleanup();
65 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest,
66 MANUAL_Me2Me_Connect_Pinless) {
67 VerifyInternetAccess();
68 Install();
69 LaunchChromotingApp();
71 // Authorize, Authenticate, and Approve.
72 Auth();
73 ExpandMe2Me();
75 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message"))
76 << "The host must have no pairings before running the pinless test.";
78 // Test that cleanup works with either the Delete or Delete all buttons.
79 ConnectPinlessAndCleanupPairings(false);
80 ConnectPinlessAndCleanupPairings(true);
82 Cleanup();
85 void Me2MeBrowserTest::TestKeyboardInput() {
86 // We will assume here that the browser window is already open on the host
87 // and in focus.
88 // Press tab to put focus on the textbox.
89 SimulateKeyPressWithCode(ui::VKEY_TAB, "Tab", false, false, false, false);
91 // Write some text in the box and press enter
92 std::string text = "Abigail";
93 SimulateStringInput(text);
94 SimulateKeyPressWithCode(
95 ui::VKEY_RETURN, "Enter", false, false, false, false);
97 // Wait until the client tab sets the right variables
98 ConditionalTimeoutWaiter waiter(
99 base::TimeDelta::FromSeconds(10),
100 base::TimeDelta::FromMilliseconds(500),
101 base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete,
102 client_web_content(),
103 "testResult.keypressSucceeded"));
104 EXPECT_TRUE(waiter.Wait());
106 // Check that the text we got is correct
107 EXPECT_TRUE(ExecuteScriptAndExtractBool(
108 client_web_content(),
109 "testResult.keypressText == '" + text + "'"));
112 void Me2MeBrowserTest::TestMouseInput() {
113 SimulateMouseLeftClickAt(10, 50);
114 // TODO: Verify programatically the mouse events are received by the host.
115 // This will be tricky as it depends on the host OS, window manager, desktop
116 // layout, and screen resolution. Until then we need to visually verify that
117 // "Dash Home" is clicked on a Unity window manager.
118 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait());
121 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all) {
122 // First connection: verify that a PIN is requested, and request pairing.
123 ConnectToLocalHost(true);
124 DisconnectMe2Me();
126 // TODO(jamiewalch): This reload is only needed because there's a bug in the
127 // web-app whereby it doesn't refresh its pairing state correctly.
128 // http://crbug.com/311290
129 LaunchChromotingApp();
130 ASSERT_TRUE(HtmlElementVisible("paired-client-manager-message"));
132 // Second connection: verify that no PIN is requested.
133 ClickOnControl("this-host-connect");
134 WaitForConnection();
135 DisconnectMe2Me();
137 // Clean up pairings.
138 ClickOnControl("open-paired-client-manager-dialog");
139 ASSERT_TRUE(HtmlElementVisible("paired-client-manager-dialog"));
141 if (cleanup_all) {
142 ClickOnControl("delete-all-paired-clients");
143 } else {
144 std::string host_id = ExecuteScriptAndExtractString(
145 "remoting.pairedClientManager.getFirstClientIdForTesting_()");
146 std::string node_id = "delete-client-" + host_id;
147 ClickOnControl(node_id);
150 // Wait for the "working" spinner to disappear. The spinner is shown by both
151 // methods of deleting a host and is removed when the operation completes.
152 ConditionalTimeoutWaiter waiter(
153 base::TimeDelta::FromSeconds(5),
154 base::TimeDelta::FromMilliseconds(200),
155 base::Bind(&Me2MeBrowserTest::IsPairingSpinnerHidden, this));
156 EXPECT_TRUE(waiter.Wait());
157 EXPECT_TRUE(ExecuteScriptAndExtractBool(
158 "document.getElementById('delete-all-paired-clients').disabled"));
160 ClickOnControl("close-paired-client-manager-dialog");
161 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-dialog"));
162 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message"));
165 bool Me2MeBrowserTest::IsPairingSpinnerHidden() {
166 return !HtmlElementVisible("paired-client-manager-dialog-working");
169 } // namespace remoting