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

Side by Side Diff: chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.js

Issue 791083005: Browser tests for DevToolsBridgeClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed for Chrome OS. Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 GEN('#include "chrome/browser/devtools/device/webrtc/' +
6 'devtools_bridge_client_browsertest.h"');
7
8 /**
9 * Test fixture for DevToolsBridgeClientBrowserTest.
10 * @constructor
11 * @extends {testing.Test}
12 */
13 function DevToolsBridgeClientBrowserTest() {}
14
15 var DEVICES_URL = "https://www.googleapis.com/clouddevices/v1/devices";
16
17 DevToolsBridgeClientBrowserTest.prototype = {
18 __proto__: testing.Test.prototype,
19
20 /** @override */
21 typedefCppFixture: 'DevToolsBridgeClientBrowserTest',
22
23 /** @override */
24 isAsync: true,
25
26 /** @override */
27 browsePreload: DUMMY_URL,
28
29 setUp: function() {
30 this.callbacksMock = mock(DevToolsBridgeClientBrowserTest.NativeCallbacks);
31 window.callbacks = this.callbacksMock.proxy();
32 },
33
34 signIn: function() {
35 return new Promise(function(resolve) {
36 this.callbacksMock.expects(once()).workerLoaded().will(
37 callFunction(resolve));
38 }.bind(this));
39 },
40
41 createInstanceDef: function(id, displayName) {
dgozman 2014/12/22 16:38:21 JSDoc?
SeRya 2014/12/22 17:00:14 Done.
42 return {
43 'kind': 'clouddevices#device',
44 'deviceKind': 'vendor',
45 'id': id,
46 'displayName': displayName,
47 'commandDefs': {
48 'base': {
49 '_iceExchange': {'kind': 'clouddevices#commandDef'},
50 '_renegotiate': {'kind': 'clouddevices#commandDef'},
51 '_startSession': {'kind': 'clouddevices#commandDef'},
52 }
53 },
54 };
55 }
56 };
57
58 /**
59 * Callbacks from native DevToolsBridgeClientBrowserTest.
60 * @constructor
61 */
62 DevToolsBridgeClientBrowserTest.NativeCallbacks = function() {}
63
64 DevToolsBridgeClientBrowserTest.NativeCallbacks.prototype = {
65 workerLoaded: function() {},
66 request: function(id, body) {},
dgozman 2014/12/22 16:38:21 gcdApiRequest
SeRya 2014/12/22 17:00:15 Done.
67 browserListUpdated: function(count) {},
68 };
69
70 TEST_F('DevToolsBridgeClientBrowserTest', 'testSetUpOnMainThread', function() {
71 testDone();
72 });
73
74 TEST_F('DevToolsBridgeClientBrowserTest', 'testSignIn', function() {
75 chrome.send('signIn', []);
76 this.signIn().then(testDone);
77 });
78
79 TEST_F('DevToolsBridgeClientBrowserTest', 'testQueryBrowsers', function() {
80 chrome.send('signIn', []);
dgozman 2014/12/22 16:38:21 Move this to signIn method.
SeRya 2014/12/22 17:00:15 Done.
81 this.signIn().then(function() {
82 chrome.send('queryDevices');
83 });
84 var savedArgs = new SaveMockArguments();
85 this.callbacksMock.expects(once()).request(
86 savedArgs.match(ANYTHING), DEVICES_URL, '').will(
87 callFunctionWithSavedArgs(savedArgs, function(id) {
88 var response = {
89 'kind': 'clouddevices#devicesListResponse',
90 'devices': [
91 this.createInstanceDef(
92 'ab911465-83c7-e335-ea64-cb656868cbe0', 'Test 1'),
93 this.createInstanceDef(
94 'ab911465-83c7-e335-ea64-cb656868cbe1', 'Test 2'),
95 this.createInstanceDef(
96 'ab911465-83c7-e335-ea64-cb656868cbe2', 'Test 3'),
97 ],
98 };
99 chrome.send('response', [id, response]);
dgozman 2014/12/22 16:38:21 gcdApiResponse
SeRya 2014/12/22 17:00:15 Done.
100 }.bind(this)));
101
102 this.callbacksMock.expects(once()).browserListUpdated(3).will(
103 callFunction(testDone));
104 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698