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