mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
Compare commits
2 commits
33274ad1f6
...
667cfe2b03
Author | SHA1 | Date | |
---|---|---|---|
|
667cfe2b03 | ||
|
d09b533a2d |
4 changed files with 120 additions and 1 deletions
|
@ -62,4 +62,14 @@ class CameraErrorState extends CameraContainerState {
|
|||
final CameraErrorType error;
|
||||
|
||||
const CameraErrorState(this.error);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other.runtimeType != runtimeType) return false;
|
||||
return other is CameraErrorState && other.error == error;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(error, runtimeType);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:lightmeter/screens/metering/components/camera_container/event_container_camera.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group(
|
||||
'`ZoomChangedEvent`',
|
||||
() {
|
||||
final a = ZoomChangedEvent(1.0);
|
||||
final b = ZoomChangedEvent(1.0);
|
||||
final c = ZoomChangedEvent(2.0);
|
||||
test('==', () {
|
||||
expect(a == b && b == a, true);
|
||||
expect(a != c && c != a, true);
|
||||
expect(b != c && c != b, true);
|
||||
});
|
||||
test('hashCode', () {
|
||||
expect(a.hashCode == b.hashCode, true);
|
||||
expect(a.hashCode != c.hashCode, true);
|
||||
expect(b.hashCode != c.hashCode, true);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
group(
|
||||
'`ExposureOffsetChangedEvent`',
|
||||
() {
|
||||
final a = ExposureOffsetChangedEvent(1.0);
|
||||
final b = ExposureOffsetChangedEvent(1.0);
|
||||
final c = ExposureOffsetChangedEvent(2.0);
|
||||
test('==', () {
|
||||
expect(a == b && b == a, true);
|
||||
expect(a != c && c != a, true);
|
||||
expect(b != c && c != b, true);
|
||||
});
|
||||
test('hashCode', () {
|
||||
expect(a.hashCode == b.hashCode, true);
|
||||
expect(a.hashCode != c.hashCode, true);
|
||||
expect(b.hashCode != c.hashCode, true);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/screens/metering/components/camera_container/models/camera_error_type.dart';
|
||||
import 'package:lightmeter/screens/metering/components/camera_container/state_container_camera.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group(
|
||||
'`CameraActiveState`',
|
||||
() {
|
||||
final a = CameraActiveState(
|
||||
zoomRange: RangeValues(1, 7),
|
||||
currentZoom: 1,
|
||||
exposureOffsetRange: RangeValues(-4, 4),
|
||||
currentExposureOffset: 0,
|
||||
exposureOffsetStep: 0.167,
|
||||
);
|
||||
final b = CameraActiveState(
|
||||
zoomRange: RangeValues(1, 7),
|
||||
currentZoom: 1,
|
||||
exposureOffsetRange: RangeValues(-4, 4),
|
||||
currentExposureOffset: 0,
|
||||
exposureOffsetStep: 0.167,
|
||||
);
|
||||
final c = CameraActiveState(
|
||||
zoomRange: RangeValues(1, 4),
|
||||
currentZoom: 3,
|
||||
exposureOffsetRange: RangeValues(-2, 2),
|
||||
currentExposureOffset: 0,
|
||||
exposureOffsetStep: 0.167,
|
||||
);
|
||||
test('==', () {
|
||||
expect(a == b && b == a, true);
|
||||
expect(a != c && c != a, true);
|
||||
expect(b != c && c != b, true);
|
||||
});
|
||||
test('hashCode', () {
|
||||
expect(a.hashCode == b.hashCode, true);
|
||||
expect(a.hashCode != c.hashCode, true);
|
||||
expect(b.hashCode != c.hashCode, true);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
group(
|
||||
'`CameraErrorState`',
|
||||
() {
|
||||
final a = CameraErrorState(CameraErrorType.noCamerasDetected);
|
||||
final b = CameraErrorState(CameraErrorType.noCamerasDetected);
|
||||
final c = CameraErrorState(CameraErrorType.other);
|
||||
test('==', () {
|
||||
expect(a == b && b == a, true);
|
||||
expect(a != c && c != a, true);
|
||||
expect(b != c && c != b, true);
|
||||
});
|
||||
test('hashCode', () {
|
||||
expect(a.hashCode == b.hashCode, true);
|
||||
expect(a.hashCode != c.hashCode, true);
|
||||
expect(b.hashCode != c.hashCode, true);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
flutter test --coverage
|
||||
genhtml coverage/lcov.info -o coverage/html
|
||||
lcov --remove coverage/lcov.info 'lib/generated/*' 'lib/l10n/*' -o coverage/new_lcov.info
|
||||
genhtml coverage/new_lcov.info -o coverage/html
|
||||
open coverage/html/index.html
|
Loading…
Reference in a new issue