Chromium Code Reviews| Index: chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js |
| diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..64c2c3d2f43cfcce0ed3d91f21eb709e128cad41 |
| --- /dev/null |
| +++ b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js |
| @@ -0,0 +1,104 @@ |
| +// 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. |
| + |
| +GEN('#include "chrome/browser/devtools/device/webrtc/' + |
| + 'devtools_bridge_client_browsertest.h"'); |
| + |
| +/** |
| + * Test fixture for DevToolsBridgeClientBrowserTest. |
| + * @constructor |
| + * @extends {testing.Test} |
| + */ |
| +function DevToolsBridgeClientBrowserTest() {} |
| + |
| +var DEVICES_URL = "https://www.googleapis.com/clouddevices/v1/devices"; |
| + |
| +DevToolsBridgeClientBrowserTest.prototype = { |
| + __proto__: testing.Test.prototype, |
| + |
| + /** @override */ |
| + typedefCppFixture: 'DevToolsBridgeClientBrowserTest', |
| + |
| + /** @override */ |
| + isAsync: true, |
| + |
| + /** @override */ |
| + browsePreload: DUMMY_URL, |
| + |
| + setUp: function() { |
| + this.callbacksMock = mock(DevToolsBridgeClientBrowserTest.NativeCallbacks); |
| + window.callbacks = this.callbacksMock.proxy(); |
| + }, |
| + |
| + signIn: function() { |
| + return new Promise(function(resolve) { |
| + this.callbacksMock.expects(once()).workerLoaded().will( |
| + callFunction(resolve)); |
| + }.bind(this)); |
| + }, |
| + |
| + createInstanceDef: function(id, displayName) { |
|
dgozman
2014/12/22 16:38:21
JSDoc?
SeRya
2014/12/22 17:00:14
Done.
|
| + return { |
| + 'kind': 'clouddevices#device', |
| + 'deviceKind': 'vendor', |
| + 'id': id, |
| + 'displayName': displayName, |
| + 'commandDefs': { |
| + 'base': { |
| + '_iceExchange': {'kind': 'clouddevices#commandDef'}, |
| + '_renegotiate': {'kind': 'clouddevices#commandDef'}, |
| + '_startSession': {'kind': 'clouddevices#commandDef'}, |
| + } |
| + }, |
| + }; |
| + } |
| +}; |
| + |
| +/** |
| + * Callbacks from native DevToolsBridgeClientBrowserTest. |
| + * @constructor |
| + */ |
| +DevToolsBridgeClientBrowserTest.NativeCallbacks = function() {} |
| + |
| +DevToolsBridgeClientBrowserTest.NativeCallbacks.prototype = { |
| + workerLoaded: function() {}, |
| + request: function(id, body) {}, |
|
dgozman
2014/12/22 16:38:21
gcdApiRequest
SeRya
2014/12/22 17:00:15
Done.
|
| + browserListUpdated: function(count) {}, |
| +}; |
| + |
| +TEST_F('DevToolsBridgeClientBrowserTest', 'testSetUpOnMainThread', function() { |
| + testDone(); |
| +}); |
| + |
| +TEST_F('DevToolsBridgeClientBrowserTest', 'testSignIn', function() { |
| + chrome.send('signIn', []); |
| + this.signIn().then(testDone); |
| +}); |
| + |
| +TEST_F('DevToolsBridgeClientBrowserTest', 'testQueryBrowsers', function() { |
| + chrome.send('signIn', []); |
|
dgozman
2014/12/22 16:38:21
Move this to signIn method.
SeRya
2014/12/22 17:00:15
Done.
|
| + this.signIn().then(function() { |
| + chrome.send('queryDevices'); |
| + }); |
| + var savedArgs = new SaveMockArguments(); |
| + this.callbacksMock.expects(once()).request( |
| + savedArgs.match(ANYTHING), DEVICES_URL, '').will( |
| + callFunctionWithSavedArgs(savedArgs, function(id) { |
| + var response = { |
| + 'kind': 'clouddevices#devicesListResponse', |
| + 'devices': [ |
| + this.createInstanceDef( |
| + 'ab911465-83c7-e335-ea64-cb656868cbe0', 'Test 1'), |
| + this.createInstanceDef( |
| + 'ab911465-83c7-e335-ea64-cb656868cbe1', 'Test 2'), |
| + this.createInstanceDef( |
| + 'ab911465-83c7-e335-ea64-cb656868cbe2', 'Test 3'), |
| + ], |
| + }; |
| + chrome.send('response', [id, response]); |
|
dgozman
2014/12/22 16:38:21
gcdApiResponse
SeRya
2014/12/22 17:00:15
Done.
|
| + }.bind(this))); |
| + |
| + this.callbacksMock.expects(once()).browserListUpdated(3).will( |
| + callFunction(testDone)); |
| +}); |