Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: remoting/webapp/browser_test/browser_test.js

Issue 398823005: Automate host start up in browser test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/browser_test/browser_test.js
diff --git a/remoting/webapp/browser_test/browser_test.js b/remoting/webapp/browser_test/browser_test.js
index 2c385bb986a59c9035cde3fea17674bd06313b0f..c2cc76112e33d505f10e94b2f80647ca11787242 100644
--- a/remoting/webapp/browser_test/browser_test.js
+++ b/remoting/webapp/browser_test/browser_test.js
@@ -169,7 +169,7 @@ browserTest.connectMe2Me = function() {
}).then(function() {
return browserTest.onUIMode(AppMode.CLIENT_PIN_PROMPT);
});
-}
+};
browserTest.expectMe2MeError = function(errorTag) {
var AppMode = remoting.AppMode;
@@ -225,4 +225,57 @@ browserTest.runTest = function(testClass, data) {
}
};
+browserTest.setupPIN = function(newPin) {
+ var AppMode = remoting.AppMode;
+ var HOST_SETUP_WAIT = 10000;
+ var Timeout = browserTest.Timeout;
+
+ return browserTest.onUIMode(AppMode.HOST_SETUP_ASK_PIN).then(function() {
+ document.getElementById('daemon-pin-entry').value = newPin;
+ document.getElementById('daemon-pin-confirm').value = newPin;
+ browserTest.clickOnControl('daemon-pin-ok');
+
+ var success = browserTest.onUIMode(AppMode.HOST_SETUP_DONE, Timeout.NONE);
+ var failure = browserTest.onUIMode(AppMode.HOST_SETUP_ERROR, Timeout.NONE);
+ 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.
+ return Promise.reject('Unexpected host setup failure');
+ });
+ return Promise.race([success, failure]);
+ }).then(function() {
+ console.log('browserTest: PIN Setup is done.')
+ browserTest.clickOnControl('host-config-done-dismiss');
+
+ // On Linux, we restart the host after changing the PIN, need to sleep
+ // for ten seconds before the host is ready for connection.
+ return base.Promise.sleep(HOST_SETUP_WAIT);
+ });
+};
+
+browserTest.ensureHostStartedWithPIN = function(pin) {
+ var AppMode = remoting.AppMode;
+ var HOST_RESTART_WAIT = 10000;
+ 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.
+
+ // Return if host is already
+ var startDaemonButton = document.getElementById('start-daemon');
+ 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.
+ console.log('browserTest: Enabling remote connection.');
+ 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
+ } else {
+ console.log('browserTest: Changing the PIN of the host to <' + pin + '>.' );
+ browserTest.clickOnControl('change-daemon-pin');
+ }
+ return browserTest.setupPIN(pin);
+};
+
+// Called by Browser Test in C++
+browserTest.ensureRemoteConnectionEnabled = function(pin) {
+ browserTest.ensureHostStartedWithPIN(pin).then(function(){
+ browserTest.automationController_.send(true);
+ }).catch(function(errorMessage){
+ console.error(errorMessage);
+ browserTest.automationController_.send(false);
+ });
+};
+
browserTest.init();

Powered by Google App Engine
This is Rietveld 408576698