1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
10 browserTest.ConnectToLocalHost = function() {};
13 * @param {{pin:string}} data
15 browserTest.ConnectToLocalHost.prototype.run = function(data) {
16 browserTest.expect(typeof data.pin == 'string', 'The PIN must be a string');
17 browserTest.connectMe2Me().then(function() {
18 return browserTest.enterPIN(data.pin);
20 return browserTest.disconnect();
23 }).catch(function(/** Error */ reason) {
24 browserTest.fail(reason);
30 browserTest.AliveOnLostFocus = function() {};
33 * @param {{pin:string}} data
35 browserTest.AliveOnLostFocus.prototype.run = function(data) {
36 browserTest.expect(typeof data.pin == 'string', 'The PIN must be a string');
37 browserTest.connectMe2Me().then(function() {
38 return browserTest.enterPIN(data.pin);
40 chrome.app.window.current().minimize();
41 // Wait for a few seconds for app to process any notifications it
42 // would have got from minimizing.
43 return base.Promise.sleep(4000);
45 chrome.app.window.current().restore();
47 // Validate that the session is still active.
48 if (remoting.currentMode !== remoting.AppMode.IN_SESSION) {
50 'Unexpected session disconnect when the app is minimized.');
53 return browserTest.disconnect();
56 }).catch(function(/** Error */ reason) {
57 browserTest.fail(reason);
63 browserTest.RetryOnHostOffline = function() {
65 this.mockConnection_ = new remoting.MockConnection();
67 // Fake an host offline error on first connect.
68 var plugin = this.mockConnection_.plugin();
69 var State = remoting.ClientSession.State;
70 var Error = remoting.ClientSession.ConnectionError;
73 plugin.mock$onConnect().then(function() {
74 plugin.mock$setConnectionStatus(State.CONNECTING);
76 plugin.mock$setConnectionStatus(State.FAILED, Error.HOST_IS_OFFLINE);
79 that.mockConnection_ = new remoting.MockConnection();
80 var newPlugin = that.mockConnection_.plugin();
81 // Let the second connect succeed.
82 newPlugin.mock$useDefaultBehavior(remoting.MockClientPlugin.AuthMethod.PIN);
87 browserTest.RetryOnHostOffline.prototype.cleanup_ = function() {
88 this.mockConnection_.restore();
89 this.mockConnection_ = null;
92 browserTest.RetryOnHostOffline.prototype.run = function() {
94 browserTest.connectMe2Me().then(function() {
95 return browserTest.enterPIN('123456');
97 return browserTest.disconnect();
101 }).catch(function(/** Error */ reason) {
103 browserTest.fail(reason);