Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import os | 5 import os |
| 6 | 6 import subprocess |
| 7 import sys | |
| 8 import time | |
| 7 | 9 |
| 8 class ChromotingMixIn(object): | 10 class ChromotingMixIn(object): |
| 9 """MixIn for PyUITest that adds Chromoting-specific methods. | 11 """MixIn for PyUITest that adds Chromoting-specific methods. |
| 10 | 12 |
| 11 Prepend it as a base class of a test to enable Chromoting functionality. | 13 Prepend it as a base class of a test to enable Chromoting functionality. |
| 12 This is a separate class from PyUITest to avoid namespace collisions. | 14 This is a separate class from PyUITest to avoid namespace collisions. |
| 13 | 15 |
| 14 Example usage: | 16 Example usage: |
| 15 class ChromotingExample(chromoting.ChromotingMixIn, pyauto.PyUITest): | 17 class ChromotingExample(chromoting.ChromotingMixIn, pyauto.PyUITest): |
| 16 def testShare(self): | 18 def testShare(self): |
| 17 app = self.InstallApp(self.GetWebappPath()) | 19 app = self.InstallApp(self.GetWebappPath()) |
| 18 self.LaunchApp(app) | 20 self.LaunchApp(app) |
| 19 self.Authenticate() | 21 self.Authenticate() |
| 20 self.assertTrue(self.Share()) | 22 self.assertTrue(self.Share()) |
| 21 """ | 23 """ |
| 22 | 24 |
| 23 def _ExecuteJavascript(self, command, tab_index, windex): | 25 def _ExecuteJavascript(self, command, tab_index, windex): |
| 24 """Helper that returns immediately after running a Javascript command.""" | 26 """Helper that returns immediately after running a Javascript command. |
| 25 return self.ExecuteJavascript( | 27 """ |
| 28 self.ExecuteJavascript( | |
| 26 '%s; window.domAutomationController.send("done");' % command, | 29 '%s; window.domAutomationController.send("done");' % command, |
| 27 tab_index, windex) | 30 tab_index, windex) |
| 28 | 31 |
| 29 def _WaitForJavascriptCondition(self, condition, tab_index, windex): | 32 def _WaitForJavascriptCondition(self, condition, tab_index, windex): |
| 30 """Waits until the Javascript condition is true. | 33 """Waits until the Javascript condition is true. |
| 31 | 34 |
| 32 This is different from a naive self.WaitUntil(lambda: self.GetDOMValue()) | 35 This is different from a naive self.WaitUntil(lambda: self.GetDOMValue()) |
| 33 because it uses Javascript to check the condition instead of Python. | 36 because it uses Javascript to check the condition instead of Python. |
| 37 | |
| 38 Returns: True or False if condition not satisfied. | |
|
simonmorris
2012/07/30 22:44:24
It's not clear whether True means that the conditi
yihongg1
2012/08/03 00:40:06
Done.
| |
| 34 """ | 39 """ |
| 35 return self.WaitUntil(lambda: self.GetDOMValue( | 40 return self.WaitUntil(lambda: self.GetDOMValue( |
| 36 '(%s) ? "1" : ""' % condition, tab_index, windex)) | 41 '(%s) ? "1" : ""' % condition, tab_index, windex)) |
| 37 | 42 |
| 38 def _ExecuteAndWaitForMode(self, command, mode, tab_index, windex): | 43 def _ExecuteAndWaitForMode(self, command, mode, tab_index, windex): |
| 39 self.assertTrue(self._ExecuteJavascript(command, tab_index, windex), | 44 """ Executes JavaScript and wait for remoting app mode equal to the given mo de. |
|
Nirnimesh
2012/07/31 20:15:10
80 chars
yihongg1
2012/08/03 00:40:06
Done.
| |
| 40 'Javascript command did not return anything.') | 45 |
| 46 Returns: True or False if app mode is not satisfied. | |
| 47 """ | |
| 48 self._ExecuteJavascript(command, tab_index, windex) | |
| 41 return self._WaitForJavascriptCondition( | 49 return self._WaitForJavascriptCondition( |
| 42 'remoting.currentMode == remoting.AppMode.%s' % mode, | 50 'remoting.currentMode == remoting.AppMode.%s' % mode, |
| 43 tab_index, windex) | 51 tab_index, windex) |
| 44 | 52 |
| 45 def _ExecuteAndWaitForMajorMode(self, command, mode, tab_index, windex): | 53 def _ExecuteAndWaitForMajorMode(self, command, mode, tab_index, windex): |
| 46 self.assertTrue(self._ExecuteJavascript(command, tab_index, windex), | 54 """ Executes JavaScript and wait for remoting app major mode equal to the gi ven mode. |
|
Nirnimesh
2012/07/31 20:15:10
80 chars
yihongg1
2012/08/03 00:40:06
Done.
| |
| 47 'Javascript command did not return anything.') | 55 |
| 56 Returns: True or False if app mode is not satisfied. | |
| 57 """ | |
| 58 self._ExecuteJavascript(command, tab_index, windex) | |
| 48 return self._WaitForJavascriptCondition( | 59 return self._WaitForJavascriptCondition( |
| 49 'remoting.getMajorMode() == remoting.AppMode.%s' % mode, | 60 'remoting.getMajorMode() == remoting.AppMode.%s' % mode, |
| 50 tab_index, windex) | 61 tab_index, windex) |
| 51 | 62 |
| 52 def GetWebappPath(self): | 63 def GetWebappPath(self): |
| 53 """Returns the path to the webapp. | 64 """Returns the path to the webapp. |
| 54 | 65 |
| 55 Expects the webapp to be in the same place as the pyautolib binaries. | 66 Expects the webapp to be in the same place as the pyautolib binaries. |
| 56 """ | 67 """ |
| 57 return os.path.join(self.BrowserPath(), 'remoting', 'remoting.webapp') | 68 return os.path.join(self.BrowserPath(), 'remoting', 'remoting.webapp') |
| 58 | 69 |
| 59 def Authenticate(self, email=None, password=None, otp=None, | 70 def GetHelperRunner(self): |
| 60 tab_index=1, windex=0): | 71 """Returns the python binary name that runs chromoting_helper.py.""" |
| 61 """Logs a user in for Chromoting and accepts permissions for the app. | 72 if sys.platform.startswith('win'): |
| 73 return "python" | |
| 74 else: | |
| 75 return "suid-python" | |
| 62 | 76 |
| 63 PyAuto tests start with a clean profile, so Chromoting tests should call | 77 def InstallHostDaemon(self): |
| 64 this for every run after launching the app. If email or password is omitted, | 78 """Installs the host daemon.""" |
| 65 the user can type it into the browser window manually. | 79 subprocess.call([self.GetHelperRunner(), "chrome/test/pyautolib/chromoting_h elper.py", |
| 80 "install", self.BrowserPath()]) | |
| 66 | 81 |
| 67 Raises: | 82 def UninstallHostDaemon(self): |
| 68 AssertionError if the authentication flow changes or | 83 """Uninstalls the host daemon.""" |
| 69 the credentials are incorrect. | 84 subprocess.call([self.GetHelperRunner(), "chrome/test/pyautolib/chromoting_h elper.py", |
| 70 """ | 85 "uninstall", self.BrowserPath()]) |
| 86 | |
| 87 def ContinueAuth(self, tab_index=1, windex=0): | |
| 88 """Starts authentication.""" | |
| 71 self.assertTrue( | 89 self.assertTrue( |
| 72 self._WaitForJavascriptCondition('window.remoting && remoting.oauth2', | 90 self._WaitForJavascriptCondition('window.remoting && remoting.oauth2', |
| 73 tab_index, windex), | 91 tab_index, windex), |
| 74 msg='Timed out while waiting for remoting app to finish loading.') | 92 msg='Timed out while waiting for remoting app to finish loading.') |
| 75 self._ExecuteJavascript('remoting.oauth2.doAuthRedirect();', | 93 self._ExecuteJavascript('remoting.oauth2.doAuthRedirect();', |
| 76 tab_index, windex) | 94 tab_index, windex) |
| 95 | |
| 96 def LogIn(self, email=None, password=None, otp=None, | |
| 97 tab_index=1, windex=0): | |
| 98 """Logs a user in. | |
| 99 | |
| 100 PyAuto tests start with a clean profile, so Chromoting tests should call | |
| 101 this for every run after launching the app. If email or password is omitted, | |
| 102 the user can type it into the browser window manually. | |
| 103 """ | |
| 77 self.assertTrue( | 104 self.assertTrue( |
| 78 self._WaitForJavascriptCondition('document.getElementById("signIn")', | 105 self._WaitForJavascriptCondition('document.getElementById("signIn")', |
| 79 tab_index, windex), | 106 tab_index, windex), |
| 80 msg='Unable to redirect for authentication.') | 107 msg='Unable to redirect for authentication.') |
| 81 | 108 |
| 82 if email: | 109 if email: |
| 83 self._ExecuteJavascript('document.getElementById("Email").value = "%s";' | 110 self._ExecuteJavascript('document.getElementById("Email").value = "%s";' |
| 84 'document.getElementById("Passwd").focus();' | 111 'document.getElementById("Passwd").focus();' |
| 85 % email, tab_index, windex) | 112 % email, tab_index, windex) |
| 86 | 113 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 105 self._WaitForJavascriptCondition( | 132 self._WaitForJavascriptCondition( |
| 106 'document.getElementById("skip") || ' | 133 'document.getElementById("skip") || ' |
| 107 'document.getElementById("submit_approve_access")', | 134 'document.getElementById("submit_approve_access")', |
| 108 tab_index, windex), | 135 tab_index, windex), |
| 109 msg='No "skip adding account" or "approve access" link.') | 136 msg='No "skip adding account" or "approve access" link.') |
| 110 self._ExecuteJavascript( | 137 self._ExecuteJavascript( |
| 111 'if (document.getElementById("skip")) ' | 138 'if (document.getElementById("skip")) ' |
| 112 '{ document.getElementById("skip").click(); }', | 139 '{ document.getElementById("skip").click(); }', |
| 113 tab_index, windex) | 140 tab_index, windex) |
| 114 | 141 |
| 142 def AllowAccess(self, tab_index=1, windex=0): | |
| 143 """Allows access to chromoting webapp.""" | |
| 115 # Approve access. | 144 # Approve access. |
| 116 self.assertTrue( | 145 self.assertTrue( |
| 117 self._WaitForJavascriptCondition( | 146 self._WaitForJavascriptCondition( |
| 118 'document.getElementById("submit_approve_access")', | 147 'document.getElementById("submit_approve_access")', |
| 119 tab_index, windex), | 148 tab_index, windex), |
| 120 msg='Authentication failed. The username, password, or otp is invalid.') | 149 msg='Did not go to permission page.') |
| 121 self._ExecuteJavascript( | 150 self._ExecuteJavascript( |
| 122 'document.getElementById("submit_approve_access").click();', | 151 'document.getElementById("submit_approve_access").click();', |
| 123 tab_index, windex) | 152 tab_index, windex) |
| 124 | 153 |
| 125 # Wait for some things to be ready. | 154 # Wait for some things to be ready. |
| 126 self.assertTrue( | 155 self.assertTrue( |
| 127 self._WaitForJavascriptCondition( | 156 self._WaitForJavascriptCondition( |
| 128 'window.remoting && remoting.oauth2 && ' | 157 'window.remoting && remoting.oauth2 && ' |
| 129 'remoting.oauth2.isAuthenticated()', | 158 'remoting.oauth2.isAuthenticated()', |
| 130 tab_index, windex), | 159 tab_index, windex), |
| 131 msg='OAuth2 authentication failed.') | 160 msg='OAuth2 authentication failed.') |
| 132 self.assertTrue( | 161 self.assertTrue( |
| 133 self._WaitForJavascriptCondition( | 162 self._WaitForJavascriptCondition( |
| 134 'window.localStorage.getItem("remoting-email")', | 163 'window.localStorage.getItem("remoting-email")', |
| 135 tab_index, windex), | 164 tab_index, windex), |
| 136 msg='Chromoting app did not reload after authentication.') | 165 msg='Chromoting app did not reload after authentication.') |
| 137 | 166 |
| 167 def DenyAccess(self, tab_index=1, windex=0): | |
| 168 """Deny and then allow access to chromoting webapp.""" | |
| 169 self.assertTrue( | |
| 170 self._WaitForJavascriptCondition( | |
| 171 'document.getElementById("submit_deny_access")', | |
| 172 tab_index, windex), | |
| 173 msg='Did not go to permission page.') | |
| 174 self._ExecuteJavascript( | |
| 175 'document.getElementById("submit_deny_access").click();', | |
| 176 tab_index, windex) | |
| 177 | |
| 178 def SignOut(self, tab_index=1, windex=0): | |
| 179 """Signs out from chromoting and signs back in.""" | |
| 180 self._ExecuteAndWaitForMode( | |
| 181 'document.getElementById("sign-out").click();', | |
| 182 'UNAUTHENTICATED', tab_index, windex) | |
| 183 | |
| 184 def Authenticate(self, tab_index=1, windex=0): | |
| 185 """Finishes authentication flow for user.""" | |
| 186 self.ContinueAuth(tab_index, windex) | |
| 187 account = self.GetPrivateInfo()['test_chromoting_account'] | |
| 188 self.host.LogIn(account['username'], account['password'], None, tab_index, w index) | |
| 189 self.host.AllowAccess(tab_index, windex) | |
| 190 | |
| 191 def GetMe2MeStarted(self, tab_index=1, windex=0): | |
| 192 """Starts Me2Me. """ | |
| 193 self._ExecuteJavascript( | |
| 194 'document.getElementById("get-started-me2me").click();', | |
| 195 tab_index, windex) | |
| 196 | |
| 138 def Share(self, tab_index=1, windex=0): | 197 def Share(self, tab_index=1, windex=0): |
| 139 """Generates an access code and waits for incoming connections. | 198 """Generates an access code and waits for incoming connections. |
| 140 | 199 |
| 141 Returns: | 200 Returns: |
| 142 The access code on success; None otherwise. | 201 The access code on success; None otherwise. |
| 143 """ | 202 """ |
| 144 self._ExecuteAndWaitForMode( | 203 self._ExecuteAndWaitForMode( |
| 145 'remoting.tryShare();', | 204 'remoting.tryShare();', |
| 146 'HOST_WAITING_FOR_CONNECTION', tab_index, windex) | 205 'HOST_WAITING_FOR_CONNECTION', tab_index, windex) |
| 147 return self.GetDOMValue( | 206 return self.GetDOMValue( |
| 148 'document.getElementById("access-code-display").innerText', | 207 'document.getElementById("access-code-display").innerText', |
| 149 tab_index, windex) | 208 tab_index, windex) |
| 150 | 209 |
| 210 def CancelShare(self, tab_index=1, windex=0): | |
| 211 """Stops sharing the desktop on the host side.""" | |
| 212 self.assertTrue( | |
| 213 self._ExecuteAndWaitForMode( | |
| 214 'remoting.cancelShare();', | |
| 215 'HOST_SHARE_FINISHED', tab_index, windex), | |
| 216 msg='Stopping sharing from the host side failed') | |
| 217 | |
| 218 def EnableConnectionsInstalled(self, pin_exercise=False, tab_index=1, windex=0 ): | |
| 219 """Enables the remote connections on the host side.""" | |
| 220 subprocess.call([self.GetHelperRunner(), "chrome/test/pyautolib/chromoting_h elper.py", "enable"]) | |
| 221 | |
| 222 self.assertTrue( | |
| 223 self._ExecuteAndWaitForMode( | |
| 224 'document.getElementById("start-daemon").click();', | |
| 225 'HOST_SETUP_ASK_PIN', tab_index, windex), | |
| 226 msg='Cannot start host setup') | |
| 227 self.assertTrue( | |
| 228 self._WaitForJavascriptCondition( | |
| 229 'document.getElementById("ask-pin-form").hidden == false', | |
| 230 tab_index, windex), | |
| 231 msg='No ask pin dialog') | |
| 232 | |
| 233 if pin_exercise: | |
| 234 # Cancels the pin prompt | |
| 235 self._ExecuteJavascript( | |
| 236 'document.getElementById("daemon-pin-cancel").click();', | |
| 237 tab_index, windex) | |
| 238 | |
| 239 # Enables again | |
| 240 self.assertTrue( | |
| 241 self._ExecuteAndWaitForMode( | |
| 242 'document.getElementById("start-daemon").click();', | |
| 243 'HOST_SETUP_ASK_PIN', tab_index, windex), | |
| 244 msg='Cannot start host setup') | |
| 245 | |
| 246 # Click ok without typing in pins | |
| 247 self._ExecuteJavascript( | |
| 248 'document.getElementById("daemon-pin-ok").click();', | |
| 249 tab_index, windex) | |
| 250 self.assertTrue( | |
| 251 self._WaitForJavascriptCondition( | |
| 252 'document.getElementById("daemon-pin-error-message")', | |
| 253 tab_index, windex), | |
| 254 msg='No pin error message') | |
| 255 | |
| 256 # Mis-mtaching pins | |
|
simonmorris
2012/07/30 22:44:24
mtaching -> matching
yihongg1
2012/08/03 00:40:06
Done.
| |
| 257 self._ExecuteJavascript( | |
| 258 'document.getElementById("daemon-pin-entry").value = "111111";', | |
| 259 tab_index, windex) | |
| 260 self._ExecuteJavascript( | |
| 261 'document.getElementById("daemon-pin-confirm").value = "123456";', | |
| 262 tab_index, windex) | |
| 263 self.assertTrue( | |
| 264 self._WaitForJavascriptCondition( | |
| 265 'document.getElementById("daemon-pin-error-message")', | |
| 266 tab_index, windex), | |
| 267 msg='No pin error message') | |
| 268 | |
| 269 # Types in correct pins | |
| 270 self._ExecuteJavascript( | |
| 271 'document.getElementById("daemon-pin-entry").value = "111111";', | |
| 272 tab_index, windex) | |
| 273 self._ExecuteJavascript( | |
| 274 'document.getElementById("daemon-pin-confirm").value = "111111";', | |
| 275 tab_index, windex) | |
| 276 self.assertTrue( | |
| 277 self._ExecuteAndWaitForMode( | |
| 278 'document.getElementById("daemon-pin-ok").click();', | |
| 279 'HOST_SETUP_PROCESSING', tab_index, windex), | |
| 280 msg='Host setup was not started') | |
| 281 | |
| 282 # Handles preference panes | |
| 283 self.assertTrue( | |
| 284 self._WaitForJavascriptCondition( | |
| 285 'remoting.currentMode == remoting.AppMode.HOST_SETUP_DONE', | |
| 286 tab_index, windex), | |
| 287 msg='Host setup was not done') | |
| 288 | |
| 289 # Dismisses the host config done dialog | |
| 290 self.assertTrue( | |
| 291 self._WaitForJavascriptCondition( | |
| 292 'document.getElementById("host-setup-dialog").childNodes[5].hidden = = false', | |
| 293 tab_index, windex), | |
| 294 msg='No host setup done dialog') | |
| 295 self.assertTrue( | |
| 296 self._ExecuteAndWaitForMode( | |
| 297 'document.getElementById("host-config-done-dismiss").click();', | |
| 298 'HOME', tab_index, windex), | |
| 299 msg='Failed to dismiss host setup confirmation dialog') | |
| 300 | |
| 301 def EnableConnectionsUninstalledAndCancel(self, tab_index=1, windex=0): | |
| 302 """Enables remote connections while host is not installed yet.""" | |
| 303 self.assertTrue( | |
| 304 self._ExecuteAndWaitForMode( | |
| 305 'document.getElementById("start-daemon").click();', | |
| 306 'HOST_SETUP_INSTALL', tab_index, windex), | |
| 307 msg='Cannot start host install') | |
| 308 self.assertTrue( | |
| 309 self._ExecuteAndWaitForMode( | |
| 310 'document.getElementById("host-config-install-dismiss").click();', | |
| 311 'HOME', tab_index, windex), | |
| 312 msg='Failed to dismiss host install dialog') | |
| 313 | |
| 314 def DisableConnections(self, tab_index=1, windex=0): | |
| 315 """Disables the remote connections on the host side.""" | |
| 316 time.sleep(2) | |
| 317 subprocess.call([self.GetHelperRunner(), "chrome/test/pyautolib/chromoting_h elper.py", "disable"]) | |
| 318 | |
| 319 self._ExecuteJavascript( | |
| 320 'window.location.reload();', | |
| 321 tab_index, windex) | |
| 322 time.sleep(2) | |
| 323 | |
| 324 self._ExecuteJavascript( | |
| 325 'document.getElementById("stop-daemon").click();', | |
| 326 tab_index, windex) | |
| 327 self.assertTrue( | |
| 328 self._ExecuteAndWaitForMode( | |
| 329 'document.getElementById("host-config-done-dismiss").click();', | |
| 330 'HOME', tab_index, windex), | |
| 331 msg='Failed to dismiss host setup confirmation dialog') | |
| 332 | |
| 151 def Connect(self, access_code, tab_index=1, windex=0): | 333 def Connect(self, access_code, tab_index=1, windex=0): |
| 152 """Connects to a Chromoting host and starts the session. | 334 """Connects to a Chromoting host and starts the session.""" |
| 153 | 335 self.assertTrue( |
| 154 Returns: | 336 self._ExecuteAndWaitForMode( |
| 155 True on success; False otherwise. | 337 'document.getElementById("access-code-entry").value = "%s";' |
| 156 """ | 338 'remoting.connectIt2Me();' % access_code, |
| 157 return self._ExecuteAndWaitForMode( | 339 'IN_SESSION', tab_index, windex), |
| 158 'document.getElementById("access-code-entry").value = "%s";' | 340 msg='Cannot connect it2me session') |
| 159 'remoting.connectIt2Me();' % access_code, | 341 |
| 160 'IN_SESSION', tab_index, windex) | 342 def ChangePin(self, pin="222222", tab_index=1, windex=0): |
| 161 | 343 """Changes pin for enabled host.""" |
| 162 def CancelShare(self, tab_index=1, windex=0): | 344 subprocess.call([self.GetHelperRunner(), "chrome/test/pyautolib/chromoting_h elper.py", "changepin"]) |
| 163 """Stops sharing the desktop on the host side. | 345 |
| 164 | 346 self.assertTrue( |
| 165 Returns: | 347 self._ExecuteAndWaitForMode( |
| 166 True on success; False otherwise. | 348 'document.getElementById("change-daemon-pin").click();', |
| 167 """ | 349 'HOST_SETUP_ASK_PIN', tab_index, windex), |
| 168 return self._ExecuteAndWaitForMode( | 350 msg='Cannot change daemon pin') |
| 169 'remoting.cancelShare();', | 351 self.assertTrue( |
| 170 'HOST_SHARE_FINISHED', tab_index, windex) | 352 self._WaitForJavascriptCondition( |
| 353 'document.getElementById("ask-pin-form").hidden == false', | |
| 354 tab_index, windex), | |
| 355 msg='No ask pin dialog') | |
| 356 | |
| 357 self._ExecuteJavascript( | |
| 358 'document.getElementById("daemon-pin-entry").value = "' + pin + '";', | |
| 359 tab_index, windex) | |
| 360 self._ExecuteJavascript( | |
| 361 'document.getElementById("daemon-pin-confirm").value = "' + pin + '";', | |
| 362 tab_index, windex) | |
| 363 self.assertTrue( | |
| 364 self._ExecuteAndWaitForMode( | |
| 365 'document.getElementById("daemon-pin-ok").click();', | |
| 366 'HOST_SETUP_PROCESSING', tab_index, windex), | |
| 367 msg='Host setup was not started') | |
| 368 | |
| 369 # Handles preference panes | |
| 370 self.assertTrue( | |
| 371 self._WaitForJavascriptCondition( | |
| 372 'remoting.currentMode == remoting.AppMode.HOST_SETUP_DONE', | |
| 373 tab_index, windex), | |
| 374 msg='Host setup was not done') | |
| 375 | |
| 376 # Dismisses the host config done dialog | |
| 377 self.assertTrue( | |
| 378 self._WaitForJavascriptCondition( | |
| 379 'document.getElementById("host-setup-dialog").childNodes[5].hidden = = false', | |
| 380 tab_index, windex), | |
| 381 msg='No host setup done dialog') | |
| 382 self.assertTrue( | |
| 383 self._ExecuteAndWaitForMode( | |
| 384 'document.getElementById("host-config-done-dismiss").click();', | |
| 385 'HOME', tab_index, windex), | |
| 386 msg='Failed to dismiss host setup confirmation dialog') | |
| 387 | |
| 388 def ChangeName(self, new_name="Changed", tab_index=1, windex=0): | |
| 389 """Changes the host name.""" | |
| 390 self._ExecuteJavascript( | |
| 391 'document.getElementById("this-host-rename").click();', | |
| 392 tab_index, windex) | |
| 393 self._ExecuteJavascript( | |
| 394 'document.getElementById("this-host-name").childNodes[0].value = "' + ne w_name + '";', | |
| 395 tab_index, windex) | |
| 396 self._ExecuteJavascript( | |
| 397 'document.getElementById("this-host-rename").click();', | |
| 398 tab_index, windex) | |
| 399 | |
| 400 def ConnectMe2Me(self, pin="111111", mode="IN_SESSION", tab_index=1, windex=0) : | |
| 401 """Connects to a Chromoting host and starts the session.""" | |
| 402 if sys.platform.startswith('win'): | |
| 403 time.sleep(10) | |
| 404 else: | |
| 405 time.sleep(2) | |
| 406 self._ExecuteJavascript( | |
| 407 'window.location.reload();', | |
| 408 tab_index, windex) | |
| 409 time.sleep(2) | |
| 410 | |
| 411 self.assertTrue( | |
| 412 self._WaitForJavascriptCondition( | |
| 413 'document.getElementById("this-host-connect")', | |
| 414 tab_index, windex), | |
| 415 msg='This host did not appear') | |
| 416 self.assertTrue( | |
| 417 self._ExecuteAndWaitForMode( | |
| 418 'document.getElementById("this-host-name").click();', | |
| 419 'CLIENT_PIN_PROMPT', tab_index, windex), | |
| 420 msg='Client pin prompt did not show') | |
| 421 self._ExecuteJavascript( | |
| 422 'document.getElementById("pin-entry").value = "' + pin + '";', | |
| 423 tab_index, windex) | |
| 424 self.assertTrue( | |
| 425 self._ExecuteAndWaitForMode( | |
| 426 'document.getElementById("pin-form").childNodes[5].click();', | |
| 427 mode, tab_index, windex), | |
| 428 msg='Session was not started') | |
| 171 | 429 |
| 172 def Disconnect(self, tab_index=1, windex=0): | 430 def Disconnect(self, tab_index=1, windex=0): |
| 173 """Disconnects from the Chromoting session on the client side. | 431 """Disconnects from the Chromoting it2me session on the client side.""" |
| 174 | 432 self.assertTrue( |
| 175 Returns: | 433 self._ExecuteAndWaitForMode( |
| 176 True on success; False otherwise. | 434 'remoting.disconnect();', |
| 177 """ | 435 'CLIENT_SESSION_FINISHED_IT2ME', tab_index, windex), |
| 178 return self._ExecuteAndWaitForMode( | 436 msg='Disconnecting it2me session from the client side failed') |
| 179 'remoting.disconnect();', | 437 |
| 180 'CLIENT_SESSION_FINISHED_IT2ME', tab_index, windex) | 438 def DisconnectMe2Me(self, ok=True, tab_index=1, windex=0): |
| 439 """Disconnects from the Chromoting me2me session on the client side.""" | |
| 440 self.assertTrue( | |
| 441 self._ExecuteAndWaitForMode( | |
| 442 'remoting.disconnect();', | |
| 443 'CLIENT_SESSION_FINISHED_ME2ME', tab_index, windex), | |
| 444 msg='Disconnecting me2me session from the client side failed') | |
| 445 | |
| 446 if ok: | |
| 447 self.assertTrue( | |
| 448 self._ExecuteAndWaitForMode( | |
| 449 'document.getElementById("client-finished-me2me-button").click();' , | |
| 450 'HOME', tab_index, windex), | |
| 451 msg='Failed to dismiss session finished dialog') | |
| 452 | |
| 453 def ReconnectMe2Me(self, pin="111111", tab_index=1, windex=0): | |
| 454 """Reconnects the me2me session.""" | |
| 455 self._ExecuteJavascript( | |
| 456 'document.getElementById("client-reconnect-button").click();', | |
| 457 tab_index, windex) | |
| 458 time.sleep(2) | |
| 459 self._ExecuteJavascript( | |
| 460 'document.getElementById("pin-entry").value = "' + pin + '";', | |
| 461 tab_index, windex) | |
| 462 self.assertTrue( | |
| 463 self._ExecuteAndWaitForMode( | |
| 464 'document.getElementById("pin-form").childNodes[5].click();', | |
| 465 'IN_SESSION', tab_index, windex), | |
| 466 msg='Session was not started') | |
| OLD | NEW |