| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 function sensor_mocks(mojo) { | 3 function sensor_mocks(mojo) { |
| 4 return define('Generic Sensor API mocks', [ | 4 return define('Generic Sensor API mocks', [ |
| 5 'mojo/public/js/core', | 5 'mojo/public/js/core', |
| 6 'mojo/public/js/bindings', | 6 'mojo/public/js/bindings', |
| 7 'mojo/public/js/connection', | 7 'mojo/public/js/connection', |
| 8 'device/generic_sensor/public/interfaces/sensor_provider.mojom', | 8 'device/generic_sensor/public/interfaces/sensor_provider.mojom', |
| 9 'device/generic_sensor/public/interfaces/sensor.mojom', | 9 'device/generic_sensor/public/interfaces/sensor.mojom', |
| 10 ], (core, bindings, connection, sensor_provider, sensor) => { | 10 ], (core, bindings, connection, sensor_provider, sensor) => { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 this.shared_buffer_handle_ = rv.handle; | 187 this.shared_buffer_handle_ = rv.handle; |
| 188 this.active_sensor_ = null; | 188 this.active_sensor_ = null; |
| 189 this.get_sensor_should_fail_ = false; | 189 this.get_sensor_should_fail_ = false; |
| 190 this.resolve_func_ = null; | 190 this.resolve_func_ = null; |
| 191 this.is_continuous_ = false; | 191 this.is_continuous_ = false; |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Returns initialized Sensor proxy to the client. | 194 // Returns initialized Sensor proxy to the client. |
| 195 getSensor(type, stub) { | 195 getSensor(type, stub) { |
| 196 if (this.get_sensor_should_fail_) { | 196 if (this.get_sensor_should_fail_) { |
| 197 return getSensorResponse(null, null); | 197 return getSensorResponse(null, |
| 198 connection.bindProxy(null, sensor.SensorClient)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 let offset = | 201 let offset = |
| 201 (sensor.SensorType.LAST - type) * this.reading_size_in_bytes_; | 202 (sensor.SensorType.LAST - type) * this.reading_size_in_bytes_; |
| 202 let reporting_mode = sensor.ReportingMode.ON_CHANGE; | 203 let reporting_mode = sensor.ReportingMode.ON_CHANGE; |
| 203 if (this.is_continuous_) { | 204 if (this.is_continuous_) { |
| 204 reporting_mode = sensor.ReportingMode.CONTINUOUS; | 205 reporting_mode = sensor.ReportingMode.CONTINUOUS; |
| 205 } | 206 } |
| 206 | 207 |
| 207 if (this.active_sensor_ == null) { | 208 if (this.active_sensor_ == null) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 }); | 293 }); |
| 293 } | 294 } |
| 294 | 295 |
| 295 function sensor_test(func, name, properties) { | 296 function sensor_test(func, name, properties) { |
| 296 mojo_test(mojo => sensor_mocks(mojo).then(sensor => { | 297 mojo_test(mojo => sensor_mocks(mojo).then(sensor => { |
| 297 let result = Promise.resolve(func(sensor)); | 298 let result = Promise.resolve(func(sensor)); |
| 298 let cleanUp = () => { sensor.mockSensorProvider.reset(); }; | 299 let cleanUp = () => { sensor.mockSensorProvider.reset(); }; |
| 299 return result.then(cleanUp, cleanUp); | 300 return result.then(cleanUp, cleanUp); |
| 300 }), name, properties); | 301 }), name, properties); |
| 301 } | 302 } |
| OLD | NEW |