Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Aug 30, 2024
1 parent 3638d3e commit 946cc4a
Showing 1 changed file with 58 additions and 69 deletions.
127 changes: 58 additions & 69 deletions packages/flutter_adaptive_scaffold/test/breakpoint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -686,19 +686,7 @@ void main() {
.element(find.byKey(const Key('Breakpoints.smallMobile'))))
.spacing,
kMaterialCompactSpacing);
}, variant: TargetPlatformVariant.desktop());

testWidgets('isMobile returns true on mobile platforms',
(WidgetTester tester) async {
await tester.pumpWidget(SimulatedLayout.medium.slot(tester));
await tester.pumpAndSettle();

expect(Breakpoint.isDesktop(tester.element(find.byType(TestScaffold))),
isTrue);

expect(Breakpoint.isMobile(tester.element(find.byType(TestScaffold))),
isFalse);
}, variant: TargetPlatformVariant.mobile());
});

testWidgets('returns kMaterialMediumAndUpSpacing for medium breakpoint',
(WidgetTester tester) async {
Expand Down Expand Up @@ -970,62 +958,63 @@ void main() {
.maxPanes,
3);
}, variant: TargetPlatformVariant.mobile());
group('Breakpoint method tests', () {
testWidgets('isDesktop returns true on desktop platforms',
(WidgetTester tester) async {
await tester.pumpWidget(const DummyWidget());
await tester.pumpAndSettle();

expect(Breakpoint.isDesktop(tester.element(find.byType(DummyWidget))),
isTrue);

expect(Breakpoint.isMobile(tester.element(find.byType(DummyWidget))),
isFalse);
}, variant: TargetPlatformVariant.desktop());

testWidgets('isMobile returns true on mobile platforms',
(WidgetTester tester) async {
await tester.pumpWidget(const DummyWidget());
await tester.pumpAndSettle();

expect(Breakpoint.isMobile(tester.element(find.byType(DummyWidget))),
isTrue);

expect(Breakpoint.isDesktop(tester.element(find.byType(DummyWidget))),
isFalse);
}, variant: TargetPlatformVariant.mobile());

test('Breakpoint comparison operators work correctly', () {
const Breakpoint small = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;
const Breakpoint large = Breakpoints.large;

expect(small < medium, isTrue);
expect(large > medium, isTrue);
expect(small <= Breakpoints.small, isTrue);
expect(large >= medium, isTrue);
});

test('Breakpoint equality and hashCode', () {
const Breakpoint small1 = Breakpoints.small;
const Breakpoint small2 = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;

expect(small1 == small2, isTrue);
expect(small1 == medium, isFalse);
expect(small1.hashCode == small2.hashCode, isTrue);
expect(small1.hashCode == medium.hashCode, isFalse);
});

test('Breakpoint between method works correctly', () {
const Breakpoint small = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;
const Breakpoint large = Breakpoints.large;

expect(medium.between(small, large), isTrue);
expect(small.between(medium, large), isFalse);
expect(large.between(small, medium), isFalse);
});
});

group('Breakpoint method tests', () {
testWidgets('isMobile returns true on mobile platforms',
(WidgetTester tester) async {
await tester.pumpWidget(SimulatedLayout.medium.scaffold(tester));
await tester.pumpAndSettle();

expect(Breakpoint.isMobile(tester.element(find.byType(TestScaffold))),
isTrue);

expect(Breakpoint.isDesktop(tester.element(find.byType(TestScaffold))),
isFalse);
}, variant: TargetPlatformVariant.mobile());

testWidgets('isDesktop returns true on desktop platforms',
(WidgetTester tester) async {
await tester.pumpWidget(SimulatedLayout.medium.scaffold(tester));
await tester.pumpAndSettle();

expect(Breakpoint.isDesktop(tester.element(find.byType(TestScaffold))),
isTrue);

expect(Breakpoint.isMobile(tester.element(find.byType(TestScaffold))),
isFalse);
}, variant: TargetPlatformVariant.desktop());

test('Breakpoint comparison operators work correctly', () {
const Breakpoint small = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;
const Breakpoint large = Breakpoints.large;

expect(small < medium, isTrue);
expect(large > medium, isTrue);
expect(small <= Breakpoints.small, isTrue);
expect(large >= medium, isTrue);
});

test('Breakpoint equality and hashCode', () {
const Breakpoint small1 = Breakpoints.small;
const Breakpoint small2 = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;

expect(small1 == small2, isTrue);
expect(small1 == medium, isFalse);
expect(small1.hashCode == small2.hashCode, isTrue);
expect(small1.hashCode == medium.hashCode, isFalse);
});

test('Breakpoint between method works correctly', () {
const Breakpoint small = Breakpoints.small;
const Breakpoint medium = Breakpoints.medium;
const Breakpoint large = Breakpoints.large;

expect(medium.between(small, large), isTrue);
expect(small.between(medium, large), isFalse);
expect(large.between(small, medium), isFalse);
});
});
}
Expand Down

0 comments on commit 946cc4a

Please sign in to comment.