Commit 481cf8ca authored by Michael Checo's avatar Michael Checo Committed by Commit Bot

Diagnostics: Support reset on the fake provider

- Add reset method to fake provider
- Move method resolvers and observables to class methods

Tests are in a follow up CL

Bug: 1125150
Test: browser_tests --gtest_filter=DiagnosticsApp*
Change-Id: Ib36194af7511da82991a012325f6a12018d12239
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437027
Commit-Queue: Michael Checo <michaelcheco@google.com>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812121}
parent 23c657d5
...@@ -19,16 +19,8 @@ export class FakeSystemDataProvider { ...@@ -19,16 +19,8 @@ export class FakeSystemDataProvider {
/** @private {!FakeObservables} */ /** @private {!FakeObservables} */
this.observables_ = new FakeObservables(); this.observables_ = new FakeObservables();
// Setup method resolvers. this.registerMethods();
this.methods_.register('getSystemInfo'); this.registerObservables();
this.methods_.register('getBatteryInfo');
// Setup observables.
this.observables_.register(
'BatteryChargeStatusObserver_onBatteryChargeStatusUpdated');
this.observables_.register('BatteryHealthObserver_onBatteryHealthUpdated');
this.observables_.register('CpuUsageObserver_onCpuUsageUpdated');
this.observables_.register('MemoryUsageObserver_onMemoryUsageUpdated');
} }
/** /**
...@@ -193,4 +185,36 @@ export class FakeSystemDataProvider { ...@@ -193,4 +185,36 @@ export class FakeSystemDataProvider {
stopTriggerIntervals() { stopTriggerIntervals() {
this.observables_.stopAllTriggerIntervals(); this.observables_.stopAllTriggerIntervals();
} }
/**
* Setup method resolvers.
*/
registerMethods() {
this.methods_.register('getSystemInfo');
this.methods_.register('getBatteryInfo');
}
/**
* Setup observables.
*/
registerObservables() {
this.observables_.register(
'BatteryChargeStatusObserver_onBatteryChargeStatusUpdated');
this.observables_.register('BatteryHealthObserver_onBatteryHealthUpdated');
this.observables_.register('CpuUsageObserver_onCpuUsageUpdated');
this.observables_.register('MemoryUsageObserver_onMemoryUsageUpdated');
}
/**
* Disables all observers and resets provider to its initial state.
*/
reset() {
this.observables_.stopAllTriggerIntervals();
this.methods_ = new FakeMethodResolver();
this.observables_ = new FakeObservables();
this.registerMethods();
this.registerObservables();
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment