base/threading: remove ScopedTracker placed for experiments
[chromium-blink-merge.git] / remoting / webapp / browser_test / me2me_browser_test.js
blobd4f0353b32e85c3e0dcbb59761da982117f53d78
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.
5 (function() {
7 'use strict';
9 /** @constructor */
10 browserTest.ConnectToLocalHost = function() {};
12 /**
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);
19 }).then(function() {
20 return browserTest.disconnect();
21 }).then(function() {
22 browserTest.pass();
23 }).catch(function(/** Error */ reason) {
24 browserTest.fail(reason);
25 });
29 /** @constructor */
30 browserTest.AliveOnLostFocus = function() {};
32 /**
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);
39 }).then(function() {
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);
44 }).then(function() {
45 chrome.app.window.current().restore();
46 }).then(function() {
47 // Validate that the session is still active.
48 if (remoting.currentMode !== remoting.AppMode.IN_SESSION) {
49 throw new Error(
50 'Unexpected session disconnect when the app is minimized.');
52 }).then(function() {
53 return browserTest.disconnect();
54 }).then(function() {
55 browserTest.pass();
56 }).catch(function(/** Error */ reason) {
57 browserTest.fail(reason);
58 });
62 /** @constructor */
63 browserTest.RetryOnHostOffline = function() {
64 /** @private */
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;
71 var that = this;
73 plugin.mock$onConnect().then(function() {
74 plugin.mock$setConnectionStatus(State.CONNECTING);
75 }).then(function() {
76 plugin.mock$setConnectionStatus(State.FAILED, Error.HOST_IS_OFFLINE);
77 }).then(function() {
78 that.cleanup_();
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);
83 });
86 /** @private */
87 browserTest.RetryOnHostOffline.prototype.cleanup_ = function() {
88 this.mockConnection_.restore();
89 this.mockConnection_ = null;
92 browserTest.RetryOnHostOffline.prototype.run = function() {
93 var that = this;
94 browserTest.connectMe2Me().then(function() {
95 return browserTest.enterPIN('123456');
96 }).then(function() {
97 return browserTest.disconnect();
98 }).then(function() {
99 that.cleanup_();
100 browserTest.pass();
101 }).catch(function(/** Error */ reason) {
102 that.cleanup_();
103 browserTest.fail(reason);
107 })();