mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
Compare commits
No commits in common. "5aa6dccd3cc14bb69bceb2633892cfcfdb59659b" and "6cffcd1998cf000b57ce8d7521fd7d5320c178cb" have entirely different histories.
5aa6dccd3c
...
6cffcd1998
2 changed files with 9 additions and 7 deletions
2
.github/workflows/pr_check.yml
vendored
2
.github/workflows/pr_check.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
analyze_and_test:
|
||||
name: Analyze & test
|
||||
runs-on: macos-11
|
||||
timeout-minutes: 10
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: 8BitJonny/gh-get-current-pr@2.2.0
|
||||
id: PR
|
||||
|
|
|
@ -2,11 +2,13 @@ import 'dart:math';
|
|||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:light_sensor/light_sensor.dart';
|
||||
|
||||
const _systemFeatureMethodChannel = MethodChannel('system_feature');
|
||||
const _lightSensorMethodChannel = MethodChannel("light.eventChannel");
|
||||
|
||||
void setLightSensorAvilability({required bool hasSensor}) {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
LightSensor.methodChannel,
|
||||
_systemFeatureMethodChannel,
|
||||
(methodCall) async {
|
||||
switch (methodCall.method) {
|
||||
case "sensor":
|
||||
|
@ -20,7 +22,7 @@ void setLightSensorAvilability({required bool hasSensor}) {
|
|||
|
||||
void resetLightSensorAvilability() {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
LightSensor.methodChannel,
|
||||
_systemFeatureMethodChannel,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
@ -29,7 +31,7 @@ Future<void> sendMockIncidentEv(double ev) => sendMockLux((2.5 * pow(2, ev)).toI
|
|||
|
||||
Future<void> sendMockLux([int lux = 100]) async {
|
||||
await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
|
||||
LightSensor.eventChannel.name,
|
||||
_lightSensorMethodChannel.name,
|
||||
const StandardMethodCodec().encodeSuccessEnvelope(lux),
|
||||
(ByteData? data) {},
|
||||
);
|
||||
|
@ -37,7 +39,7 @@ Future<void> sendMockLux([int lux = 100]) async {
|
|||
|
||||
void setupLightSensorStreamHandler() {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
MethodChannel(LightSensor.eventChannel.name),
|
||||
_lightSensorMethodChannel,
|
||||
(methodCall) async {
|
||||
switch (methodCall.method) {
|
||||
case "listen":
|
||||
|
@ -53,7 +55,7 @@ void setupLightSensorStreamHandler() {
|
|||
|
||||
void resetLightSensorStreamHandler() {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
MethodChannel(LightSensor.eventChannel.name),
|
||||
_lightSensorMethodChannel,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue