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

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

Issue 2571903003: Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: remove the changes to web_ui_mojo.js which seemed to cause flakiness. Created 3 years, 12 months 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/router', 7 'mojo/public/js/bindings',
8 ]).then(mojo => { 8 ]).then(mojo => {
9 let [batteryMonitor, batteryStatus, router] = mojo.modules; 9 let [batteryMonitor, batteryStatus, bindings] = mojo.modules;
10 10
11 class MockBatteryMonitor extends batteryMonitor.BatteryMonitor.stubClass { 11 class MockBatteryMonitor {
12 constructor(interfaceProvider) { 12 constructor(interfaceProvider) {
13 super();
14 interfaceProvider.addInterfaceOverrideForTesting( 13 interfaceProvider.addInterfaceOverrideForTesting(
15 batteryMonitor.BatteryMonitor.name, 14 batteryMonitor.BatteryMonitor.name,
16 handle => this.connect_(handle)); 15 handle => this.bindingSet_.addBinding(this, handle));
17 16
18 this.interfaceProvider_ = interfaceProvider; 17 this.interfaceProvider_ = interfaceProvider;
19 this.pendingRequests_ = []; 18 this.pendingRequests_ = [];
20 this.status_ = null; 19 this.status_ = null;
21 } 20 this.bindingSet_ = new bindings.BindingSet(batteryMonitor.BatteryMonitor);
22
23 connect_(handle) {
24 this.router_ = new router.Router(handle);
25 this.router_.setIncomingReceiver(this);
26 } 21 }
27 22
28 queryNextStatus() { 23 queryNextStatus() {
29 let result = new Promise(resolve => this.pendingRequests_.push(resolve)); 24 let result = new Promise(resolve => this.pendingRequests_.push(resolve));
30 this.runCallbacks_(); 25 this.runCallbacks_();
31 return result; 26 return result;
32 } 27 }
33 28
34 updateBatteryStatus(charging, chargingTime, dischargingTime, level) { 29 updateBatteryStatus(charging, chargingTime, dischargingTime, level) {
35 this.status_ = new batteryStatus.BatteryStatus(); 30 this.status_ = new batteryStatus.BatteryStatus();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 'lastSetMockBatteryInfo.dischargingTime'); 72 'lastSetMockBatteryInfo.dischargingTime');
78 shouldBe('batteryInfo.level', 'lastSetMockBatteryInfo.level'); 73 shouldBe('batteryInfo.level', 'lastSetMockBatteryInfo.level');
79 } 74 }
80 75
81 function batteryStatusFailure() { 76 function batteryStatusFailure() {
82 testFailed('failed to successfully resolve the promise'); 77 testFailed('failed to successfully resolve the promise');
83 setTimeout(finishJSTest, 0); 78 setTimeout(finishJSTest, 0);
84 } 79 }
85 80
86 var mockBatteryMonitorReady = mockBatteryMonitor.then(); 81 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