Index: remoting/webapp/browser_test/it2me_browser_test.js |
diff --git a/remoting/webapp/browser_test/it2me_browser_test.js b/remoting/webapp/browser_test/it2me_browser_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..274ea5b37a94a0afb5bad3ae6615a64e8889d0cb |
--- /dev/null |
+++ b/remoting/webapp/browser_test/it2me_browser_test.js |
@@ -0,0 +1,74 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @fileoverview |
+ * @suppress {checkTypes} |
+ * Browser test for the scenario below: |
+ * 1. Generates an access code. |
+ * 2. Launches another chromoting app instance. |
+ * 3. Connects with the generated access code. |
+ * 4. Verifies that the session is connected. |
+ */ |
+ |
+'use strict'; |
+ |
+/** @constructor */ |
+browserTest.CONNECT_IT2ME = function() {}; |
+ |
+browserTest.CONNECT_IT2ME.prototype.run = function(data) { |
+ browserTest.expect(typeof data.accessCode == 'string', |
+ 'The access code should be an non-empty string'); |
+ browserTest.clickOnControl('get-started-it2me'); |
+ var that = this; |
+ this.clickOnAccessButton().then(function() { |
+ return that.enterAccessCode(data.accessCode); |
+ }).then(function() { |
+ return browserTest.disconnect(); |
+ }).then(function() { |
+ browserTest.pass(); |
+ }, function(reason) { |
+ browserTest.fail(reason); |
+ }); |
+}; |
+ |
+browserTest.CONNECT_IT2ME.prototype.clickOnAccessButton = function() { |
Jamie
2015/01/06 22:18:52
These two methods (and onUserInfoReady) should be
kelvinp
2015/01/09 22:21:30
Done.
Jamie
2015/01/10 00:14:23
No you haven't ;)
|
+ browserTest.clickOnControl('access-mode-button'); |
+ return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED); |
+}; |
+ |
+browserTest.CONNECT_IT2ME.prototype.enterAccessCode = function(code) { |
+ document.getElementById('access-code-entry').value = code; |
+ browserTest.clickOnControl('connect-button'); |
+ return browserTest.expectConnected(); |
+}; |
+ |
+/** @constructor */ |
+browserTest.GET_ACCESS_CODE = function() {}; |
+ |
+browserTest.GET_ACCESS_CODE.prototype.run = function() { |
+ browserTest.clickOnControl('get-started-it2me'); |
+ this.onUserInfoReady().then(function() { |
+ browserTest.clickOnControl('share-button'); |
+ }).then(function(){ |
+ return browserTest.onUIMode(remoting.AppMode.HOST_WAITING_FOR_CONNECTION); |
+ }).then(function() { |
+ var accessCode = document.getElementById('access-code-display').innerText; |
+ browserTest.expect(accessCode.length === 12, |
+ "The access code should be 12 digits long."); |
+ browserTest.expect(!isNaN(accessCode), |
+ "The access code should be numeric."); |
Jamie
2015/01/06 22:18:52
It has to be a positive integer, so this test coul
kelvinp
2015/01/09 22:21:30
Done.
|
+ browserTest.pass(accessCode); |
+ },function(reason) { |
+ browserTest.fail(reason); |
+ }); |
+}; |
+ |
+// Wait for the email address of the local user to become available. The email |
+// address is required in an It2Me connection for domain policy enforcement. |
+browserTest.GET_ACCESS_CODE.prototype.onUserInfoReady = function() { |
+ return new Promise(function(resolve, reject){ |
+ remoting.identity.getUserInfo(resolve, reject); |
Jamie
2015/01/06 22:18:52
getUserInfo doesn't cache anything, so I'm not sur
kelvinp
2015/01/09 22:21:30
It2me currently calls getCachedEmail() to provide
|
+ }); |
+}; |