-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
2,836 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Check if lcov is installed | ||
if ! command -v lcov &> /dev/null | ||
then | ||
echo "lcov could not be found, please install it first." | ||
exit | ||
fi | ||
|
||
# Run the tests with coverage | ||
flutter test --coverage | ||
|
||
# Generate the LCOV report | ||
lcov --capture --directory coverage --output-file coverage/lcov.info | ||
|
||
# Remove unnecessary files from the report | ||
lcov --remove coverage/lcov.info 'lib/*/*.g.dart' 'lib/*/*.freezed.dart' -o coverage/lcov.info | ||
|
||
# Generate the HTML report | ||
genhtml coverage/lcov.info --output-directory coverage/html | ||
|
||
# Open the coverage report in the default browser | ||
if [ "$(uname)" == "Darwin" ]; then | ||
open coverage/html/index.html | ||
elif [ "$(uname)" == "Linux" ]; then | ||
xdg-open coverage/html/index.html | ||
elif [ "$(uname)" == "CYGWIN" ] || [ "$(uname)" == "MINGW32" ] || [ "$(uname)" == "MINGW64" ]; then | ||
start coverage/html/index.html | ||
fi | ||
|
||
echo "Coverage report generated and opened in the default browser." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
|
||
/// A mixin that combines the functionality of `Diagnosticable` and `EquatableMixin`. | ||
/// | ||
/// This mixin is useful for classes that need to be both equatable (i.e., support value comparison) | ||
/// and support Flutter's diagnostic capabilities (e.g., for improved debugging output). | ||
/// | ||
/// When using this mixin, ensure that the `toString` method conforms to the `Diagnosticable` signature, | ||
/// which accepts an optional `minLevel` parameter. | ||
mixin EquatableDiagnosticableMixin on EquatableMixin { | ||
@override | ||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { | ||
return '${super.toString()}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:zeta_flutter/src/theme/breakpoints.dart'; | ||
|
||
import '../../test_utils/test_app.dart'; | ||
|
||
void main() { | ||
group('BreakpointLocal extension', () { | ||
test('returns DeviceType.mobilePortrait for widths <= 479', () { | ||
const constraints = BoxConstraints(maxWidth: 479); | ||
expect(constraints.deviceType, DeviceType.mobilePortrait); | ||
}); | ||
|
||
test('returns DeviceType.mobileLandscape for widths <= 767', () { | ||
const constraints = BoxConstraints(maxWidth: 767); | ||
expect(constraints.deviceType, DeviceType.mobileLandscape); | ||
}); | ||
|
||
test('returns DeviceType.tablet for widths <= 991', () { | ||
const constraints = BoxConstraints(maxWidth: 991); | ||
expect(constraints.deviceType, DeviceType.tablet); | ||
}); | ||
|
||
test('returns DeviceType.desktop for widths <= 1279', () { | ||
const constraints = BoxConstraints(maxWidth: 1279); | ||
expect(constraints.deviceType, DeviceType.desktop); | ||
}); | ||
|
||
test('returns DeviceType.desktopL for widths <= 1439', () { | ||
const constraints = BoxConstraints(maxWidth: 1439); | ||
expect(constraints.deviceType, DeviceType.desktopL); | ||
}); | ||
|
||
test('returns DeviceType.desktopXL for widths > 1439', () { | ||
const constraints = BoxConstraints(maxWidth: 1920); | ||
expect(constraints.deviceType, DeviceType.desktopXL); | ||
}); | ||
}); | ||
|
||
group('BreakpointFull extension', () { | ||
testWidgets('returns DeviceType.mobilePortrait for widths <= 479', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(479, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.mobilePortrait); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('returns DeviceType.mobileLandscape for widths <= 767', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(767, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.mobileLandscape); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('returns DeviceType.tablet for widths <= 991', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(991, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.tablet); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('returns DeviceType.desktop for widths <= 1279', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(1279, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.desktop); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('returns DeviceType.desktopL for widths <= 1439', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(1439, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.desktopL); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('returns DeviceType.desktopXL for widths > 1439', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
home: MediaQuery( | ||
data: const MediaQueryData(size: Size(1920, 800)), | ||
child: Builder( | ||
builder: (context) { | ||
expect(context.deviceType, DeviceType.desktopXL); | ||
return Container(); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.