Compare commits

..

No commits in common. "5aa6dccd3cc14bb69bceb2633892cfcfdb59659b" and "6cffcd1998cf000b57ce8d7521fd7d5320c178cb" have entirely different histories.

2 changed files with 9 additions and 7 deletions

View file

@ -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: 10 timeout-minutes: 5
steps: steps:
- uses: 8BitJonny/gh-get-current-pr@2.2.0 - uses: 8BitJonny/gh-get-current-pr@2.2.0
id: PR id: PR

View file

@ -2,11 +2,13 @@ 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(
LightSensor.methodChannel, _systemFeatureMethodChannel,
(methodCall) async { (methodCall) async {
switch (methodCall.method) { switch (methodCall.method) {
case "sensor": case "sensor":
@ -20,7 +22,7 @@ void setLightSensorAvilability({required bool hasSensor}) {
void resetLightSensorAvilability() { void resetLightSensorAvilability() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
LightSensor.methodChannel, _systemFeatureMethodChannel,
null, null,
); );
} }
@ -29,7 +31,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(
LightSensor.eventChannel.name, _lightSensorMethodChannel.name,
const StandardMethodCodec().encodeSuccessEnvelope(lux), const StandardMethodCodec().encodeSuccessEnvelope(lux),
(ByteData? data) {}, (ByteData? data) {},
); );
@ -37,7 +39,7 @@ Future<void> sendMockLux([int lux = 100]) async {
void setupLightSensorStreamHandler() { void setupLightSensorStreamHandler() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
MethodChannel(LightSensor.eventChannel.name), _lightSensorMethodChannel,
(methodCall) async { (methodCall) async {
switch (methodCall.method) { switch (methodCall.method) {
case "listen": case "listen":
@ -53,7 +55,7 @@ void setupLightSensorStreamHandler() {
void resetLightSensorStreamHandler() { void resetLightSensorStreamHandler() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
MethodChannel(LightSensor.eventChannel.name), _lightSensorMethodChannel,
null, null,
); );
} }