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

Side by Side Diff: third_party/WebKit/LayoutTests/battery-status/resources/mock-battery-monitor.js

Issue 2590393002: Revert of Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: Created 4 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
1 "use strict"; 1 "use strict";
2 2
3 let mockBatteryMonitor = loadMojoModules( 3 let mockBatteryMonitor = loadMojoModules(
4 'mockBatteryMonitor', 4 'mockBatteryMonitor',
5 ['device/battery/battery_monitor.mojom', 5 ['device/battery/battery_monitor.mojom',
6 'device/battery/battery_status.mojom', 6 'device/battery/battery_status.mojom',
7 'mojo/public/js/bindings', 7 'mojo/public/js/router',
8 ]).then(mojo => { 8 ]).then(mojo => {
9 let [batteryMonitor, batteryStatus, bindings] = mojo.modules; 9 let [batteryMonitor, batteryStatus, router] = mojo.modules;
10 10
11 class MockBatteryMonitor { 11 class MockBatteryMonitor extends batteryMonitor.BatteryMonitor.stubClass {
12 constructor(interfaceProvider) { 12 constructor(interfaceProvider) {
13 super();
13 interfaceProvider.addInterfaceOverrideForTesting( 14 interfaceProvider.addInterfaceOverrideForTesting(
14 batteryMonitor.BatteryMonitor.name, 15 batteryMonitor.BatteryMonitor.name,
15 handle => this.bindingSet_.addBinding(this, handle)); 16 handle => this.connect_(handle));
16 17
17 this.interfaceProvider_ = interfaceProvider; 18 this.interfaceProvider_ = interfaceProvider;
18 this.pendingRequests_ = []; 19 this.pendingRequests_ = [];
19 this.status_ = null; 20 this.status_ = null;
20 this.bindingSet_ = new bindings.BindingSet(batteryMonitor.BatteryMonitor); 21 }
22
23 connect_(handle) {
24 this.router_ = new router.Router(handle);
25 this.router_.setIncomingReceiver(this);
21 } 26 }
22 27
23 queryNextStatus() { 28 queryNextStatus() {
24 let result = new Promise(resolve => this.pendingRequests_.push(resolve)); 29 let result = new Promise(resolve => this.pendingRequests_.push(resolve));
25 this.runCallbacks_(); 30 this.runCallbacks_();
26 return result; 31 return result;
27 } 32 }
28 33
29 updateBatteryStatus(charging, chargingTime, dischargingTime, level) { 34 updateBatteryStatus(charging, chargingTime, dischargingTime, level) {
30 this.status_ = new batteryStatus.BatteryStatus(); 35 this.status_ = new batteryStatus.BatteryStatus();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 'lastSetMockBatteryInfo.dischargingTime'); 77 'lastSetMockBatteryInfo.dischargingTime');
73 shouldBe('batteryInfo.level', 'lastSetMockBatteryInfo.level'); 78 shouldBe('batteryInfo.level', 'lastSetMockBatteryInfo.level');
74 } 79 }
75 80
76 function batteryStatusFailure() { 81 function batteryStatusFailure() {
77 testFailed('failed to successfully resolve the promise'); 82 testFailed('failed to successfully resolve the promise');
78 setTimeout(finishJSTest, 0); 83 setTimeout(finishJSTest, 0);
79 } 84 }
80 85
81 var mockBatteryMonitorReady = mockBatteryMonitor.then(); 86 var mockBatteryMonitorReady = mockBatteryMonitor.then();
OLDNEW
« no previous file with comments | « ios/web/test/data/mojo_test.js ('k') | third_party/WebKit/LayoutTests/fast/dom/Geolocation/resources/geolocation-mock.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698