OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "chrome/browser/ui/browser_window.h" | 7 #include "chrome/browser/ui/browser_window.h" |
| 8 #include "chrome/test/remoting/key_code_test_map.h" |
8 #include "chrome/test/remoting/remote_desktop_browsertest.h" | 9 #include "chrome/test/remoting/remote_desktop_browsertest.h" |
| 10 #include "chrome/test/remoting/remote_test_helper.h" |
9 #include "chrome/test/remoting/waiter.h" | 11 #include "chrome/test/remoting/waiter.h" |
10 #include "extensions/browser/app_window/app_window.h" | 12 #include "extensions/browser/app_window/app_window.h" |
11 | 13 |
12 namespace remoting { | 14 namespace remoting { |
13 | 15 |
14 class Me2MeBrowserTest : public RemoteDesktopBrowserTest { | 16 class Me2MeBrowserTest : public RemoteDesktopBrowserTest { |
15 protected: | 17 protected: |
16 void TestKeyboardInput(); | 18 void TestKeypressInput(ui::KeyboardCode, const char*); |
17 void TestMouseInput(); | |
18 | 19 |
19 void ConnectPinlessAndCleanupPairings(bool cleanup_all); | 20 void ConnectPinlessAndCleanupPairings(bool cleanup_all); |
20 bool IsPairingSpinnerHidden(); | 21 bool IsPairingSpinnerHidden(); |
| 22 void SetupForRemoteHostTest(); |
21 | 23 |
22 void RestoreApp(); | 24 void RestoreApp(); |
23 void MinimizeApp(); | 25 void MinimizeApp(); |
24 }; | 26 }; |
25 | 27 |
26 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | 28 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
27 MANUAL_Me2Me_Connect_Local_Host) { | 29 MANUAL_Me2Me_Connect_Local_Host) { |
28 SetUpTestForMe2Me(); | 30 SetUpTestForMe2Me(); |
29 | 31 |
30 ConnectToLocalHost(false); | 32 ConnectToLocalHost(false); |
(...skipping 20 matching lines...) Expand all Loading... |
51 | 53 |
52 // TODO(weitaosu): Find a way to verify keyboard input injection. | 54 // TODO(weitaosu): Find a way to verify keyboard input injection. |
53 // We cannot use TestKeyboardInput because it assumes | 55 // We cannot use TestKeyboardInput because it assumes |
54 // that the client and the host are on the same machine. | 56 // that the client and the host are on the same machine. |
55 | 57 |
56 DisconnectMe2Me(); | 58 DisconnectMe2Me(); |
57 Cleanup(); | 59 Cleanup(); |
58 } | 60 } |
59 | 61 |
60 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | 62 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 63 MANUAL_Me2Me_Remote_Host_Keypress) { |
| 64 SetupForRemoteHostTest(); |
| 65 |
| 66 // Test all key characters |
| 67 int length = sizeof(test_alpha_map)/sizeof(KeyCodeTestMap); |
| 68 for (int i = 0; i < length; i++) { |
| 69 KeyCodeTestMap key = test_alpha_map[i]; |
| 70 TestKeypressInput(key.vkey_code, key.code); |
| 71 } |
| 72 DisconnectMe2Me(); |
| 73 Cleanup(); |
| 74 } |
| 75 |
| 76 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 77 MANUAL_Me2Me_Remote_Host_Digitpress) { |
| 78 SetupForRemoteHostTest(); |
| 79 |
| 80 // Test all digit characters |
| 81 int length = sizeof(test_digit_map)/sizeof(KeyCodeTestMap); |
| 82 for (int i = 0; i < length; i++) { |
| 83 KeyCodeTestMap key = test_digit_map[i]; |
| 84 TestKeypressInput(key.vkey_code, key.code); |
| 85 } |
| 86 DisconnectMe2Me(); |
| 87 Cleanup(); |
| 88 } |
| 89 |
| 90 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 91 MANUAL_Me2Me_Remote_Host_Specialpress) { |
| 92 SetupForRemoteHostTest(); |
| 93 |
| 94 // Test all special characters |
| 95 int length = sizeof(test_special_map)/sizeof(KeyCodeTestMap); |
| 96 for (int i = 0; i < length; i++) { |
| 97 KeyCodeTestMap key = test_special_map[i]; |
| 98 TestKeypressInput(key.vkey_code, key.code); |
| 99 } |
| 100 DisconnectMe2Me(); |
| 101 Cleanup(); |
| 102 } |
| 103 |
| 104 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 105 MANUAL_Me2Me_Remote_Host_Numpadpress) { |
| 106 SetupForRemoteHostTest(); |
| 107 |
| 108 // Test all numpad characters |
| 109 int length = sizeof(test_numpad_map)/sizeof(KeyCodeTestMap); |
| 110 for (int i = 0; i < length; i++) { |
| 111 KeyCodeTestMap key = test_numpad_map[i]; |
| 112 TestKeypressInput(key.vkey_code, key.code); |
| 113 } |
| 114 DisconnectMe2Me(); |
| 115 Cleanup(); |
| 116 } |
| 117 |
| 118 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
61 MANUAL_Me2Me_Connect_Pinless) { | 119 MANUAL_Me2Me_Connect_Pinless) { |
62 SetUpTestForMe2Me(); | 120 SetUpTestForMe2Me(); |
63 | 121 |
64 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")) | 122 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")) |
65 << "The host must have no pairings before running the pinless test."; | 123 << "The host must have no pairings before running the pinless test."; |
66 | 124 |
67 // Test that cleanup works with either the Delete or Delete all buttons. | 125 // Test that cleanup works with either the Delete or Delete all buttons. |
68 ConnectPinlessAndCleanupPairings(false); | 126 ConnectPinlessAndCleanupPairings(false); |
69 ConnectPinlessAndCleanupPairings(true); | 127 ConnectPinlessAndCleanupPairings(true); |
70 | 128 |
(...skipping 18 matching lines...) Expand all Loading... |
89 EXPECT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected()); | 147 EXPECT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected()); |
90 | 148 |
91 // Maximize so we can disconnect and teardown. | 149 // Maximize so we can disconnect and teardown. |
92 RestoreApp(); | 150 RestoreApp(); |
93 | 151 |
94 // Cleanup | 152 // Cleanup |
95 DisconnectMe2Me(); | 153 DisconnectMe2Me(); |
96 Cleanup(); | 154 Cleanup(); |
97 } | 155 } |
98 | 156 |
| 157 void Me2MeBrowserTest::SetupForRemoteHostTest() { |
| 158 VerifyInternetAccess(); |
| 159 OpenClientBrowserPage(); |
| 160 Install(); |
| 161 LaunchChromotingApp(false); |
99 | 162 |
100 void Me2MeBrowserTest::TestKeyboardInput() { | 163 // Authorize, Authenticate, and Approve. |
101 // We will assume here that the browser window is already open on the host | 164 Auth(); |
102 // and in focus. | 165 ExpandMe2Me(); |
103 // Press tab to put focus on the textbox. | 166 ConnectToRemoteHost(remote_host_name(), false); |
104 SimulateKeyPressWithCode(ui::VKEY_TAB, "Tab", false, false, false, false); | |
105 | 167 |
106 // Write some text in the box and press enter | 168 // Wake up the machine if it's sleeping. |
107 std::string text = "Abigail"; | 169 // This is only needed when testing manually as the host machine |
108 SimulateStringInput(text); | 170 // may be sleeping. |
109 SimulateKeyPressWithCode( | 171 SimulateKeyPressWithCode(ui::VKEY_RETURN, "Enter"); |
110 ui::VKEY_RETURN, "Enter", false, false, false, false); | |
111 | |
112 // Wait until the client tab sets the right variables | |
113 ConditionalTimeoutWaiter waiter( | |
114 base::TimeDelta::FromSeconds(10), | |
115 base::TimeDelta::FromMilliseconds(500), | |
116 base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete, | |
117 client_web_content(), | |
118 "testResult.keypressSucceeded")); | |
119 EXPECT_TRUE(waiter.Wait()); | |
120 | |
121 // Check that the text we got is correct | |
122 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
123 client_web_content(), | |
124 "testResult.keypressText == '" + text + "'")); | |
125 } | 172 } |
126 | 173 |
127 void Me2MeBrowserTest::TestMouseInput() { | 174 void Me2MeBrowserTest::TestKeypressInput( |
128 SimulateMouseLeftClickAt(10, 50); | 175 ui::KeyboardCode keyCode, |
129 // TODO: Verify programatically the mouse events are received by the host. | 176 const char* code) { |
130 // This will be tricky as it depends on the host OS, window manager, desktop | 177 remote_test_helper()->ClearLastEvent(); |
131 // layout, and screen resolution. Until then we need to visually verify that | 178 VLOG(1) << "Pressing " << code; |
132 // "Dash Home" is clicked on a Unity window manager. | 179 SimulateKeyPressWithCode(keyCode, code); |
133 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); | 180 Event event; |
| 181 remote_test_helper()->GetLastEvent(&event); |
| 182 ASSERT_EQ(Action::Keydown, event.action); |
| 183 ASSERT_EQ(keyCode, event.value); |
134 } | 184 } |
135 | 185 |
136 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all) { | 186 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all) { |
137 // First connection: verify that a PIN is requested, and request pairing. | 187 // First connection: verify that a PIN is requested, and request pairing. |
138 ConnectToLocalHost(true); | 188 ConnectToLocalHost(true); |
139 DisconnectMe2Me(); | 189 DisconnectMe2Me(); |
140 | 190 |
141 // TODO(jamiewalch): This reload is only needed because there's a bug in the | 191 // TODO(jamiewalch): This reload is only needed because there's a bug in the |
142 // web-app whereby it doesn't refresh its pairing state correctly. | 192 // web-app whereby it doesn't refresh its pairing state correctly. |
143 // http://crbug.com/311290 | 193 // http://crbug.com/311290 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void Me2MeBrowserTest::RestoreApp() { | 243 void Me2MeBrowserTest::RestoreApp() { |
194 extensions::AppWindow* appWindow = GetFirstAppWindow(); | 244 extensions::AppWindow* appWindow = GetFirstAppWindow(); |
195 if (appWindow) { | 245 if (appWindow) { |
196 appWindow->Restore(); | 246 appWindow->Restore(); |
197 } else { | 247 } else { |
198 browser()->window()->Restore(); | 248 browser()->window()->Restore(); |
199 } | 249 } |
200 } | 250 } |
201 | 251 |
202 } // namespace remoting | 252 } // namespace remoting |
OLD | NEW |