Compare commits

..

2 commits

Author SHA1 Message Date
Vadim
667cfe2b03 removed generated code from coverage 2023-06-20 08:31:36 +02:00
Vadim
d09b533a2d CameraContainerBloc equality tests 2023-06-20 08:26:25 +02:00
4 changed files with 120 additions and 1 deletions

View file

@ -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);
}

View file

@ -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);
});
},
);
}

View file

@ -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);
});
},
);
}

View file

@ -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