Commit 3721128d authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

sensor-helpers.js: Reference Mojo signature for each function being implemented

Also group them together. This makes it easier to know which values must be
returned and which functions are not Mojo function implementations.

Bug: 987639
Change-Id: Ia21b98acaed90902dcf42e798a6c37077e4cc8dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718333
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684264}
parent 224c2397
...@@ -30,11 +30,17 @@ function sensorMocks() { ...@@ -30,11 +30,17 @@ function sensorMocks() {
}); });
} }
// device.mojom.Sensor implementation
// Mojo functions that return a value must be async and return an object
// whose keys match the names declared in Mojo.
// GetDefaultConfiguration() => (SensorConfiguration configuration)
// Returns default configuration. // Returns default configuration.
async getDefaultConfiguration() { async getDefaultConfiguration() {
return { frequency: DEFAULT_FREQUENCY }; return { frequency: DEFAULT_FREQUENCY };
} }
// AddConfiguration(SensorConfiguration configuration) => (bool success)
// Adds configuration for the sensor and starts reporting fake data // Adds configuration for the sensor and starts reporting fake data
// through setSensorReading function. // through setSensorReading function.
async addConfiguration(configuration) { async addConfiguration(configuration) {
...@@ -54,6 +60,7 @@ function sensorMocks() { ...@@ -54,6 +60,7 @@ function sensorMocks() {
return { success: !this.startShouldFail_ }; return { success: !this.startShouldFail_ };
} }
// RemoveConfiguration(SensorConfiguration configuration)
// Removes sensor configuration from the list of active configurations and // Removes sensor configuration from the list of active configurations and
// stops notification about sensor reading changes if // stops notification about sensor reading changes if
// requestedFrequencies_ is empty. // requestedFrequencies_ is empty.
...@@ -71,7 +78,7 @@ function sensorMocks() { ...@@ -71,7 +78,7 @@ function sensorMocks() {
this.stopReading(); this.stopReading();
} }
// Suspends sensor. // Suspend()
suspend() { suspend() {
this.stopReading(); this.stopReading();
if (this.suspendCalled_ != null) { if (this.suspendCalled_ != null) {
...@@ -79,7 +86,7 @@ function sensorMocks() { ...@@ -79,7 +86,7 @@ function sensorMocks() {
} }
} }
// Resumes sensor. // Resume()
resume() { resume() {
assert_equals(this.sensorReadingTimerId_, null); assert_equals(this.sensorReadingTimerId_, null);
this.startReading(); this.startReading();
...@@ -88,6 +95,13 @@ function sensorMocks() { ...@@ -88,6 +95,13 @@ function sensorMocks() {
} }
} }
// ConfigureReadingChangeNotifications(bool enabled)
// Configures whether to report a reading change when in ON_CHANGE
// reporting mode.
configureReadingChangeNotifications(notifyOnReadingChange) {
this.notifyOnReadingChange_ = notifyOnReadingChange;
}
// Mock functions // Mock functions
// Resets mock Sensor state. // Resets mock Sensor state.
...@@ -123,12 +137,6 @@ function sensorMocks() { ...@@ -123,12 +137,6 @@ function sensorMocks() {
this.startShouldFail_ = shouldFail; this.startShouldFail_ = shouldFail;
} }
// Configures whether to report a reading change when in ON_CHANGE
// reporting mode.
configureReadingChangeNotifications(notifyOnReadingChange) {
this.notifyOnReadingChange_ = notifyOnReadingChange;
}
// Returns resolved promise if suspend() was called, rejected otherwise. // Returns resolved promise if suspend() was called, rejected otherwise.
suspendCalled() { suspendCalled() {
return new Promise(resolve => { return new Promise(resolve => {
...@@ -229,6 +237,12 @@ function sensorMocks() { ...@@ -229,6 +237,12 @@ function sensorMocks() {
this.interceptor_.start(); this.interceptor_.start();
} }
// device.mojom.SensorProvider implementation
// Mojo functions that return a value must be async and return an object
// whose keys match the names declared in Mojo.
// GetSensor(SensorType type) => (SensorCreationResult result,
// SensorInitParams? init_params)
// Returns initialized Sensor proxy to the client. // Returns initialized Sensor proxy to the client.
async getSensor(type) { async getSensor(type) {
if (this.getSensorShouldFail_.get(type)) { if (this.getSensorShouldFail_.get(type)) {
......
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