Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * @suppress {checkTypes} By default, JSCompile is not run on test files. | 7 * @suppress {checkTypes} By default, JSCompile is not run on test files. |
| 8 * However, you can modify |remoting_webapp_files.gypi| locally to include | 8 * However, you can modify |remoting_webapp_files.gypi| locally to include |
| 9 * the test in the package to expedite local development. This suppress | 9 * the test in the package to expedite local development. This suppress |
| 10 * is here so that JSCompile won't complain. | 10 * is here so that JSCompile won't complain. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 return browserTest.onUIMode(AppMode.CLIENT_HOST_NEEDS_UPGRADE).then( | 162 return browserTest.onUIMode(AppMode.CLIENT_HOST_NEEDS_UPGRADE).then( |
| 163 function() { | 163 function() { |
| 164 // On fulfilled. | 164 // On fulfilled. |
| 165 browserTest.clickOnControl('host-needs-update-connect-button'); | 165 browserTest.clickOnControl('host-needs-update-connect-button'); |
| 166 }, function() { | 166 }, function() { |
| 167 // On time out. | 167 // On time out. |
| 168 return Promise.resolve(); | 168 return Promise.resolve(); |
| 169 }).then(function() { | 169 }).then(function() { |
| 170 return browserTest.onUIMode(AppMode.CLIENT_PIN_PROMPT); | 170 return browserTest.onUIMode(AppMode.CLIENT_PIN_PROMPT); |
| 171 }); | 171 }); |
| 172 } | 172 }; |
| 173 | 173 |
| 174 browserTest.expectMe2MeError = function(errorTag) { | 174 browserTest.expectMe2MeError = function(errorTag) { |
| 175 var AppMode = remoting.AppMode; | 175 var AppMode = remoting.AppMode; |
| 176 var Timeout = browserTest.Timeout; | 176 var Timeout = browserTest.Timeout; |
| 177 | 177 |
| 178 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.None); | 178 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.None); |
| 179 var onFailure = browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 179 var onFailure = browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_ME2ME); |
| 180 | 180 |
| 181 onConnected = onConnected.then(function() { | 181 onConnected = onConnected.then(function() { |
| 182 return Promise.reject( | 182 return Promise.reject( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 browserTest.runTest = function(testClass, data) { | 218 browserTest.runTest = function(testClass, data) { |
| 219 try { | 219 try { |
| 220 var test = new testClass(); | 220 var test = new testClass(); |
| 221 browserTest.expect(typeof test.run == 'function'); | 221 browserTest.expect(typeof test.run == 'function'); |
| 222 test.run(data); | 222 test.run(data); |
| 223 } catch (e) { | 223 } catch (e) { |
| 224 browserTest.fail(e); | 224 browserTest.fail(e); |
| 225 } | 225 } |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 browserTest.setupPIN = function(newPin) { | |
| 229 var AppMode = remoting.AppMode; | |
| 230 var HOST_SETUP_WAIT = 10000; | |
| 231 var Timeout = browserTest.Timeout; | |
| 232 | |
| 233 return browserTest.onUIMode(AppMode.HOST_SETUP_ASK_PIN).then(function() { | |
| 234 document.getElementById('daemon-pin-entry').value = newPin; | |
| 235 document.getElementById('daemon-pin-confirm').value = newPin; | |
| 236 browserTest.clickOnControl('daemon-pin-ok'); | |
| 237 | |
| 238 var success = browserTest.onUIMode(AppMode.HOST_SETUP_DONE, Timeout.NONE); | |
| 239 var failure = browserTest.onUIMode(AppMode.HOST_SETUP_ERROR, Timeout.NONE); | |
| 240 failure.then(function(){ | |
|
Jamie
2014/07/22 18:47:11
I think you need to update failure, ie:
failure =
kelvinp
2014/07/23 22:22:27
Done.
| |
| 241 return Promise.reject('Unexpected host setup failure'); | |
| 242 }); | |
| 243 return Promise.race([success, failure]); | |
| 244 }).then(function() { | |
| 245 console.log('browserTest: PIN Setup is done.') | |
| 246 browserTest.clickOnControl('host-config-done-dismiss'); | |
| 247 | |
| 248 // On Linux, we restart the host after changing the PIN, need to sleep | |
| 249 // for ten seconds before the host is ready for connection. | |
| 250 return base.Promise.sleep(HOST_SETUP_WAIT); | |
| 251 }); | |
| 252 }; | |
| 253 | |
| 254 browserTest.ensureHostStartedWithPIN = function(pin) { | |
| 255 var AppMode = remoting.AppMode; | |
| 256 var HOST_RESTART_WAIT = 10000; | |
| 257 var Timeout = browserTest.Timeout; | |
|
Jamie
2014/07/22 18:47:11
You don't seem to be using any of these definition
kelvinp
2014/07/23 22:22:27
Done.
| |
| 258 | |
| 259 // Return if host is already | |
| 260 var startDaemonButton = document.getElementById('start-daemon'); | |
| 261 if (startDaemonButton.offsetWidth != 0) { | |
|
weitao
2014/07/21 18:53:45
Could you please add a comment here? What does the
Jamie
2014/07/22 18:47:11
It's an indication that the element is visible, bu
kelvinp
2014/07/23 22:22:27
Done.
| |
| 262 console.log('browserTest: Enabling remote connection.'); | |
| 263 browserTest.clickOnControl('start-daemon'); | |
|
weitao
2014/07/21 18:53:45
Have you tested this on all platforms? I assume yo
Jamie
2014/07/22 18:47:11
This is a good point. If we can't implement this c
kelvinp
2014/07/23 22:22:27
The code will work on Windows and Linux, as we are
| |
| 264 } else { | |
| 265 console.log('browserTest: Changing the PIN of the host to <' + pin + '>.' ); | |
| 266 browserTest.clickOnControl('change-daemon-pin'); | |
| 267 } | |
| 268 return browserTest.setupPIN(pin); | |
| 269 }; | |
| 270 | |
| 271 // Called by Browser Test in C++ | |
| 272 browserTest.ensureRemoteConnectionEnabled = function(pin) { | |
| 273 browserTest.ensureHostStartedWithPIN(pin).then(function(){ | |
| 274 browserTest.automationController_.send(true); | |
| 275 }).catch(function(errorMessage){ | |
| 276 console.error(errorMessage); | |
| 277 browserTest.automationController_.send(false); | |
| 278 }); | |
| 279 }; | |
| 280 | |
| 228 browserTest.init(); | 281 browserTest.init(); |
| OLD | NEW |