OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Tests for chrome://bluetooth-internals | 6 * @fileoverview Tests for chrome://bluetooth-internals |
7 */ | 7 */ |
8 | 8 |
9 /** @const {string} Path to source root. */ | 9 /** @const {string} Path to source root. */ |
10 var ROOT_PATH = '../../../../'; | 10 var ROOT_PATH = '../../../../'; |
(...skipping 20 matching lines...) Expand all Loading... | |
31 /** @override */ | 31 /** @override */ |
32 runAccessibilityChecks: false, | 32 runAccessibilityChecks: false, |
33 | 33 |
34 /** @override */ | 34 /** @override */ |
35 extraLibraries: [ | 35 extraLibraries: [ |
36 ROOT_PATH + 'third_party/mocha/mocha.js', | 36 ROOT_PATH + 'third_party/mocha/mocha.js', |
37 ROOT_PATH + 'chrome/test/data/webui/mocha_adapter.js', | 37 ROOT_PATH + 'chrome/test/data/webui/mocha_adapter.js', |
38 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', | 38 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', |
39 ROOT_PATH + 'ui/webui/resources/js/cr.js', | 39 ROOT_PATH + 'ui/webui/resources/js/cr.js', |
40 ROOT_PATH + 'ui/webui/resources/js/util.js', | 40 ROOT_PATH + 'ui/webui/resources/js/util.js', |
41 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js', | 41 ROOT_PATH + 'chrome/test/data/webui/test_browser_proxy.js', |
42 ], | 42 ], |
43 | 43 |
44 preLoad: function() { | 44 preLoad: function() { |
45 // A function that is called from chrome://bluetooth-internals to allow this | 45 // A function that is called from chrome://bluetooth-internals to allow this |
46 // test to replace the real Mojo browser proxy with a fake one, before any | 46 // test to replace the real Mojo browser proxy with a fake one, before any |
47 // other code runs. | 47 // other code runs. |
48 window.setupFn = function() { | 48 window.setupFn = function() { |
49 return importModules([ | 49 return importModules([ |
50 'content/public/renderer/frame_interfaces', | 50 'content/public/renderer/frame_interfaces', |
51 'device/bluetooth/public/interfaces/adapter.mojom', | 51 'device/bluetooth/public/interfaces/adapter.mojom', |
52 'device/bluetooth/public/interfaces/device.mojom', | 52 'device/bluetooth/public/interfaces/device.mojom', |
53 'mojo/public/js/bindings', | 53 'mojo/public/js/bindings', |
54 ]).then(function([frameInterfaces, adapter, device, bindings]) { | 54 ]).then(function([frameInterfaces, adapter, device, bindings]) { |
55 /** | 55 /** |
56 * A test adapter factory proxy for the chrome://bluetooth-internals | 56 * A test adapter factory proxy for the chrome://bluetooth-internals |
57 * page. | 57 * page. |
58 * | 58 * |
59 * @constructor | 59 * @constructor |
60 * @extends {TestBrowserProxyBase} | 60 * @extends {TestBrowserProxyBase} |
rbpotter
2017/06/07 00:32:01
Should probably be test.TestBrowserProxy. TestBrow
dpapad
2017/06/07 00:42:53
Done.
| |
61 */ | 61 */ |
62 var TestAdapterFactoryProxy = function() { | 62 var TestAdapterFactoryProxy = function() { |
63 settings.TestBrowserProxy.call(this, [ | 63 test.TestBrowserProxy.call(this, [ |
64 'getAdapter', | 64 'getAdapter', |
65 ]); | 65 ]); |
66 | 66 |
67 this.binding = new bindings.Binding(adapter.AdapterFactory, this); | 67 this.binding = new bindings.Binding(adapter.AdapterFactory, this); |
68 this.adapter = new TestAdapterProxy(); | 68 this.adapter = new TestAdapterProxy(); |
69 this.adapterBinding_ = new bindings.Binding(adapter.Adapter, | 69 this.adapterBinding_ = new bindings.Binding(adapter.Adapter, |
70 this.adapter); | 70 this.adapter); |
71 }; | 71 }; |
72 | 72 |
73 TestAdapterFactoryProxy.prototype = { | 73 TestAdapterFactoryProxy.prototype = { |
74 __proto__: settings.TestBrowserProxy.prototype, | 74 __proto__: test.TestBrowserProxy.prototype, |
75 getAdapter: function() { | 75 getAdapter: function() { |
76 this.methodCalled('getAdapter'); | 76 this.methodCalled('getAdapter'); |
77 | 77 |
78 // Create message pipe bound to TestAdapter. | 78 // Create message pipe bound to TestAdapter. |
79 return Promise.resolve({ | 79 return Promise.resolve({ |
80 adapter: this.adapterBinding_.createInterfacePtrAndBind(), | 80 adapter: this.adapterBinding_.createInterfacePtrAndBind(), |
81 }); | 81 }); |
82 } | 82 } |
83 }; | 83 }; |
84 | 84 |
85 /** | 85 /** |
86 * A test adapter proxy for the chrome://bluetooth-internals page. | 86 * A test adapter proxy for the chrome://bluetooth-internals page. |
87 * @constructor | 87 * @constructor |
88 * @extends {TestBrowserProxyBase} | 88 * @extends {TestBrowserProxyBase} |
89 */ | 89 */ |
90 var TestAdapterProxy = function() { | 90 var TestAdapterProxy = function() { |
91 settings.TestBrowserProxy.call(this, [ | 91 test.TestBrowserProxy.call(this, [ |
92 'getInfo', | 92 'getInfo', |
93 'getDevices', | 93 'getDevices', |
94 'setClient', | 94 'setClient', |
95 ]); | 95 ]); |
96 | 96 |
97 this.deviceProxyMap = new Map(); | 97 this.deviceProxyMap = new Map(); |
98 this.adapterInfo_ = null; | 98 this.adapterInfo_ = null; |
99 this.devices_ = []; | 99 this.devices_ = []; |
100 this.connectResult_ = adapter.AdapterInfo.SUCCESS; | 100 this.connectResult_ = adapter.AdapterInfo.SUCCESS; |
101 }; | 101 }; |
102 | 102 |
103 TestAdapterProxy.prototype = { | 103 TestAdapterProxy.prototype = { |
104 __proto__: settings.TestBrowserProxy.prototype, | 104 __proto__: test.TestBrowserProxy.prototype, |
105 | 105 |
106 connectToDevice: function(address) { | 106 connectToDevice: function(address) { |
107 assert(this.deviceProxyMap.has(address), 'Device does not exist'); | 107 assert(this.deviceProxyMap.has(address), 'Device does not exist'); |
108 | 108 |
109 return Promise.resolve({ | 109 return Promise.resolve({ |
110 result: this.connectResult_, | 110 result: this.connectResult_, |
111 device: this.deviceProxyMap.get( | 111 device: this.deviceProxyMap.get( |
112 address).binding.createInterfacePtrAndBind(), | 112 address).binding.createInterfacePtrAndBind(), |
113 }); | 113 }); |
114 }, | 114 }, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 | 146 |
147 /** | 147 /** |
148 * A test Device proxy for the chrome://bluetooth-internals | 148 * A test Device proxy for the chrome://bluetooth-internals |
149 * page. Proxies are generated by a TestAdapterProxy which provides | 149 * page. Proxies are generated by a TestAdapterProxy which provides |
150 * the DeviceInfo. | 150 * the DeviceInfo. |
151 * @constructor | 151 * @constructor |
152 * @extends {TestBrowserProxyBase} | 152 * @extends {TestBrowserProxyBase} |
153 * @param {!device.DeviceInfo} info | 153 * @param {!device.DeviceInfo} info |
154 */ | 154 */ |
155 var TestDeviceProxy = function(info) { | 155 var TestDeviceProxy = function(info) { |
156 settings.TestBrowserProxy.call(this, [ | 156 test.TestBrowserProxy.call(this, [ |
157 'getInfo', | 157 'getInfo', |
158 'getServices', | 158 'getServices', |
159 ]); | 159 ]); |
160 | 160 |
161 this.binding = new bindings.Binding(device.Device, this); | 161 this.binding = new bindings.Binding(device.Device, this); |
162 this.info_ = info; | 162 this.info_ = info; |
163 this.services_ = []; | 163 this.services_ = []; |
164 } | 164 } |
165 | 165 |
166 TestDeviceProxy.prototype = { | 166 TestDeviceProxy.prototype = { |
167 __proto__: settings.TestBrowserProxy.prototype, | 167 __proto__: test.TestBrowserProxy.prototype, |
168 | 168 |
169 disconnect: function() { | 169 disconnect: function() { |
170 this.binding.close(); | 170 this.binding.close(); |
171 }, | 171 }, |
172 | 172 |
173 getInfo: function() { | 173 getInfo: function() { |
174 this.methodCalled('getInfo'); | 174 this.methodCalled('getInfo'); |
175 return Promise.resolve({info: this.info_}); | 175 return Promise.resolve({info: this.info_}); |
176 }, | 176 }, |
177 | 177 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
934 test('ValueControl_ConvertValue_Decimal_ThreeValues', function() { | 934 test('ValueControl_ConvertValue_Decimal_ThreeValues', function() { |
935 valueControl.typeSelect_.value = ValueDataType.DECIMAL | 935 valueControl.typeSelect_.value = ValueDataType.DECIMAL |
936 valueControl.value_.setAs(ValueDataType.DECIMAL, '97-98-99' /* abc */); | 936 valueControl.value_.setAs(ValueDataType.DECIMAL, '97-98-99' /* abc */); |
937 expectDeepEquals([aCode, bCode, cCode], valueControl.value_.getArray()); | 937 expectDeepEquals([aCode, bCode, cCode], valueControl.value_.getArray()); |
938 }); | 938 }); |
939 }); | 939 }); |
940 | 940 |
941 // Run all registered tests. | 941 // Run all registered tests. |
942 mocha.run(); | 942 mocha.run(); |
943 }); | 943 }); |
OLD | NEW |