Chromium Code Reviews| 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/test/remoting/key_code_test_map.h" | |
| 7 #include "chrome/test/remoting/remote_desktop_browsertest.h" | 8 #include "chrome/test/remoting/remote_desktop_browsertest.h" |
| 9 #include "chrome/test/remoting/remote_test_helper.h" | |
| 8 #include "chrome/test/remoting/waiter.h" | 10 #include "chrome/test/remoting/waiter.h" |
| 9 | 11 |
| 10 namespace remoting { | 12 namespace remoting { |
| 11 | 13 |
| 12 class Me2MeBrowserTest : public RemoteDesktopBrowserTest { | 14 class Me2MeBrowserTest : public RemoteDesktopBrowserTest { |
| 13 protected: | 15 protected: |
| 14 void TestKeyboardInput(); | 16 void TestKeypressInput(ui::KeyboardCode, const char*); |
| 15 void TestMouseInput(); | 17 void TestMouseInput(blink::WebMouseEvent::Button); |
| 16 | 18 |
| 17 void ConnectPinlessAndCleanupPairings(bool cleanup_all); | 19 void ConnectPinlessAndCleanupPairings(bool cleanup_all); |
| 18 bool IsPairingSpinnerHidden(); | 20 bool IsPairingSpinnerHidden(); |
| 21 void SetupForRemoteHostTest(); | |
| 19 }; | 22 }; |
| 20 | 23 |
| 21 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | 24 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 22 MANUAL_Me2Me_Connect_Local_Host) { | 25 MANUAL_Me2Me_Connect_Local_Host) { |
| 23 SetUpTestForMe2Me(); | 26 SetUpTestForMe2Me(); |
| 24 | 27 |
| 25 ConnectToLocalHost(false); | 28 ConnectToLocalHost(false); |
| 26 | 29 |
| 27 // TODO(chaitali): Change the mouse input test to also work in the | 30 // TODO(chaitali): Change the mouse input test to also work in the |
| 28 // HTTP server framework | 31 // HTTP server framework |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 46 | 49 |
| 47 // TODO(weitaosu): Find a way to verify keyboard input injection. | 50 // TODO(weitaosu): Find a way to verify keyboard input injection. |
| 48 // We cannot use TestKeyboardInput because it assumes | 51 // We cannot use TestKeyboardInput because it assumes |
| 49 // that the client and the host are on the same machine. | 52 // that the client and the host are on the same machine. |
| 50 | 53 |
| 51 DisconnectMe2Me(); | 54 DisconnectMe2Me(); |
| 52 Cleanup(); | 55 Cleanup(); |
| 53 } | 56 } |
| 54 | 57 |
| 55 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | 58 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, |
| 59 MANUAL_Me2Me_Remote_Host_Keypress) { | |
| 60 SetupForRemoteHostTest(); | |
| 61 | |
| 62 // Test all key characters | |
| 63 int length = sizeof(test_key_map)/sizeof(KeyCodeTestMap); | |
| 64 for (int i = 0; i < length; i++) { | |
| 65 KeyCodeTestMap key = test_key_map[i]; | |
| 66 TestKeypressInput(key.vkey_code, key.code); | |
| 67 } | |
| 68 DisconnectMe2Me(); | |
| 69 Cleanup(); | |
| 70 } | |
| 71 | |
| 72 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | |
| 73 MANUAL_Me2Me_Remote_Host_Digitpress) { | |
| 74 SetupForRemoteHostTest(); | |
| 75 | |
| 76 // Test all digit characters | |
| 77 int length = sizeof(test_digit_map)/sizeof(KeyCodeTestMap); | |
| 78 for (int i = 0; i < length; i++) { | |
| 79 KeyCodeTestMap key = test_digit_map[i]; | |
| 80 TestKeypressInput(key.vkey_code, key.code); | |
| 81 } | |
| 82 DisconnectMe2Me(); | |
| 83 Cleanup(); | |
| 84 } | |
| 85 | |
| 86 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | |
| 87 MANUAL_Me2Me_Remote_Host_Specialpress) { | |
| 88 SetupForRemoteHostTest(); | |
| 89 | |
| 90 // Test all special characters | |
| 91 int length = sizeof(test_special_map)/sizeof(KeyCodeTestMap); | |
| 92 for (int i = 0; i < length; i++) { | |
| 93 KeyCodeTestMap key = test_special_map[i]; | |
| 94 TestKeypressInput(key.vkey_code, key.code); | |
| 95 } | |
| 96 DisconnectMe2Me(); | |
| 97 Cleanup(); | |
| 98 } | |
| 99 | |
| 100 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | |
| 101 MANUAL_Me2Me_Remote_Host_Numpadpress) { | |
| 102 SetupForRemoteHostTest(); | |
| 103 SimulateKeyPressWithCode(ui::VKEY_SPACE, "Space", false, false, true, false); | |
|
Jamie
2014/12/17 03:15:40
None of the other tests do this. Why is it needed
Mike Meade
2014/12/18 18:54:24
Its left over from when I had to wake the machine
| |
| 104 // Test all numpad characters | |
| 105 int length = sizeof(test_numpad_map)/sizeof(KeyCodeTestMap); | |
| 106 for (int i = 0; i < length; i++) { | |
| 107 KeyCodeTestMap key = test_numpad_map[i]; | |
| 108 TestKeypressInput(key.vkey_code, key.code); | |
| 109 } | |
| 110 DisconnectMe2Me(); | |
| 111 Cleanup(); | |
| 112 } | |
| 113 | |
| 114 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | |
| 115 MANUAL_Me2Me_Remote_Host_Mouseclick) { | |
| 116 SetupForRemoteHostTest(); | |
| 117 | |
| 118 TestMouseInput(blink::WebMouseEvent::ButtonLeft); | |
| 119 TestMouseInput(blink::WebMouseEvent::ButtonMiddle); | |
| 120 TestMouseInput(blink::WebMouseEvent::ButtonRight); | |
| 121 // Dismiss the context menu from the right button press. | |
| 122 // The button press that cancels the context menu is not captured by the | |
| 123 // javascript on the page. This ensures that the next run will be clean. | |
|
Jamie
2014/12/17 03:15:40
Is this needed? Cleanup uninstalls the app, which
Mike Meade
2014/12/18 18:54:24
This is here for when the tests are run manually,
Jamie
2014/12/18 21:31:44
I still don't understand; whether it's run manuall
Mike Meade
2015/01/05 23:18:58
The context menu is opened in Chrome on a remote h
| |
| 124 SimulateMouseLeftClickAt(100, 100); | |
| 125 DisconnectMe2Me(); | |
| 126 Cleanup(); | |
| 127 } | |
| 128 | |
| 129 IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, | |
| 56 MANUAL_Me2Me_Connect_Pinless) { | 130 MANUAL_Me2Me_Connect_Pinless) { |
| 57 SetUpTestForMe2Me(); | 131 SetUpTestForMe2Me(); |
| 58 | 132 |
| 59 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")) | 133 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")) |
| 60 << "The host must have no pairings before running the pinless test."; | 134 << "The host must have no pairings before running the pinless test."; |
| 61 | 135 |
| 62 // Test that cleanup works with either the Delete or Delete all buttons. | 136 // Test that cleanup works with either the Delete or Delete all buttons. |
| 63 ConnectPinlessAndCleanupPairings(false); | 137 ConnectPinlessAndCleanupPairings(false); |
| 64 ConnectPinlessAndCleanupPairings(true); | 138 ConnectPinlessAndCleanupPairings(true); |
| 65 | 139 |
| 66 Cleanup(); | 140 Cleanup(); |
| 67 } | 141 } |
| 68 | 142 |
| 69 void Me2MeBrowserTest::TestKeyboardInput() { | 143 void Me2MeBrowserTest::SetupForRemoteHostTest() { |
| 70 // We will assume here that the browser window is already open on the host | 144 VerifyInternetAccess(); |
| 71 // and in focus. | 145 OpenClientBrowserPage(); |
| 72 // Press tab to put focus on the textbox. | 146 Install(); |
| 73 SimulateKeyPressWithCode(ui::VKEY_TAB, "Tab", false, false, false, false); | 147 LaunchChromotingApp(); |
| 74 | 148 |
| 75 // Write some text in the box and press enter | 149 // Authorize, Authenticate, and Approve. |
| 76 std::string text = "Abigail"; | 150 Auth(); |
| 77 SimulateStringInput(text); | 151 ExpandMe2Me(); |
| 78 SimulateKeyPressWithCode( | 152 ConnectToRemoteHost(remote_host_name(), false); |
| 79 ui::VKEY_RETURN, "Enter", false, false, false, false); | |
| 80 | 153 |
| 81 // Wait until the client tab sets the right variables | 154 // Wake up the machine if its sleeping |
|
Jamie
2014/12/17 03:15:40
nit: s/its/it's/
I have concerns about this step.
Mike Meade
2014/12/18 18:54:24
Done.
Jamie
2014/12/18 21:31:44
Can you address my concerns about what this means
Mike Meade
2015/01/05 23:18:58
There are 3 things here
1) The server only tracks
Jamie
2015/01/06 19:31:38
Okay, in that case, please remove the reference to
| |
| 82 ConditionalTimeoutWaiter waiter( | 155 SimulateKeyPressWithCode(ui::VKEY_RETURN, "Enter"); |
| 83 base::TimeDelta::FromSeconds(10), | |
| 84 base::TimeDelta::FromMilliseconds(500), | |
| 85 base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete, | |
| 86 client_web_content(), | |
| 87 "testResult.keypressSucceeded")); | |
| 88 EXPECT_TRUE(waiter.Wait()); | |
| 89 | |
| 90 // Check that the text we got is correct | |
| 91 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 92 client_web_content(), | |
| 93 "testResult.keypressText == '" + text + "'")); | |
| 94 } | 156 } |
| 95 | 157 |
| 96 void Me2MeBrowserTest::TestMouseInput() { | 158 void Me2MeBrowserTest::TestKeypressInput( |
| 97 SimulateMouseLeftClickAt(10, 50); | 159 ui::KeyboardCode keyCode, |
| 98 // TODO: Verify programatically the mouse events are received by the host. | 160 const char* code) { |
| 99 // This will be tricky as it depends on the host OS, window manager, desktop | 161 remote_test_helper().ClearLastEvent(); |
| 100 // layout, and screen resolution. Until then we need to visually verify that | 162 LOG(INFO) << "Pressing " << code; |
|
Jamie
2014/12/17 03:15:40
Given that we test all keys, this log will be very
Mike Meade
2014/12/18 18:54:24
Done.
| |
| 101 // "Dash Home" is clicked on a Unity window manager. | 163 SimulateKeyPressWithCode(keyCode, code); |
| 102 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); | 164 Event event; |
| 165 remote_test_helper().GetLastEvent(event); | |
| 166 ASSERT_EQ(Action::KEYDOWN, event.action); | |
| 167 ASSERT_EQ(keyCode, event.value); | |
| 168 } | |
| 169 | |
| 170 void Me2MeBrowserTest::TestMouseInput( | |
| 171 blink::WebMouseEvent::Button button) { | |
| 172 remote_test_helper().ClearLastEvent(); | |
| 173 // Offset the clicks to account for the context menu that appears on a | |
| 174 // right click; | |
|
Jamie
2014/12/17 03:15:40
I don't understand why the context menu affects wh
Jamie
2014/12/18 21:31:44
You haven't addressed this comment.
Mike Meade
2015/01/05 23:18:58
I removed this code until we could make it a bit m
| |
| 175 int offset = 0; | |
| 176 switch (button) { | |
| 177 case blink::WebMouseEvent::ButtonLeft: | |
| 178 LOG(INFO) << "Clicking left mouse button"; | |
|
Jamie
2014/12/17 03:15:40
This should probably also be a VLOG, although it w
Mike Meade
2014/12/18 18:54:24
Done.
| |
| 179 break; | |
| 180 case blink::WebMouseEvent::ButtonMiddle: | |
| 181 LOG(INFO) << "Clicking middle mouse button"; | |
| 182 break; | |
| 183 case blink::WebMouseEvent::ButtonRight: | |
| 184 LOG(INFO) << "Clicking right mouse button"; | |
| 185 offset = 100; | |
| 186 break; | |
| 187 default: | |
| 188 LOG(ERROR) << "The indicated button " << button << "is not valid"; | |
| 189 } | |
| 190 SimulateMouseClickAt(0, button, 100 + offset, 100 + offset); | |
| 191 Event event; | |
| 192 remote_test_helper().GetLastEvent(event); | |
| 193 ASSERT_EQ(Action::BUTTONPRESS, event.action); | |
| 194 ASSERT_EQ(button, event.value); | |
|
Jamie
2014/12/17 03:15:40
Can we also verify the location somehow? If that m
Jamie
2014/12/18 21:31:44
You haven't addressed this comment.
Mike Meade
2015/01/05 23:18:58
I removed this test for now. It seems to deserve i
| |
| 103 } | 195 } |
| 104 | 196 |
| 105 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all) { | 197 void Me2MeBrowserTest::ConnectPinlessAndCleanupPairings(bool cleanup_all) { |
| 106 // First connection: verify that a PIN is requested, and request pairing. | 198 // First connection: verify that a PIN is requested, and request pairing. |
| 107 ConnectToLocalHost(true); | 199 ConnectToLocalHost(true); |
| 108 DisconnectMe2Me(); | 200 DisconnectMe2Me(); |
| 109 | 201 |
| 110 // TODO(jamiewalch): This reload is only needed because there's a bug in the | 202 // 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. | 203 // web-app whereby it doesn't refresh its pairing state correctly. |
| 112 // http://crbug.com/311290 | 204 // http://crbug.com/311290 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 ClickOnControl("close-paired-client-manager-dialog"); | 236 ClickOnControl("close-paired-client-manager-dialog"); |
| 145 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-dialog")); | 237 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-dialog")); |
| 146 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")); | 238 ASSERT_FALSE(HtmlElementVisible("paired-client-manager-message")); |
| 147 } | 239 } |
| 148 | 240 |
| 149 bool Me2MeBrowserTest::IsPairingSpinnerHidden() { | 241 bool Me2MeBrowserTest::IsPairingSpinnerHidden() { |
| 150 return !HtmlElementVisible("paired-client-manager-dialog-working"); | 242 return !HtmlElementVisible("paired-client-manager-dialog-working"); |
| 151 } | 243 } |
| 152 | 244 |
| 153 } // namespace remoting | 245 } // namespace remoting |
| OLD | NEW |