Skip to content

Commit ea3234a

Browse files
committed
Fix tests
1 parent 221dce5 commit ea3234a

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

packages/flutter_adaptive_scaffold/lib/src/breakpoints.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ class Breakpoint {
247247
final bool isHeightActive = isDesktop ||
248248
orientation == Orientation.portrait ||
249249
(orientation == Orientation.landscape && andUp
250-
? height >= lowerBoundHeight
250+
? isWidthActive && height <= lowerBoundHeight ||
251+
height >= lowerBoundHeight
251252
: height >= lowerBoundHeight && height < upperBoundHeight);
252253

253254
return isWidthActive && isHeightActive && isRightPlatform;

packages/flutter_adaptive_scaffold/test/breakpoint_test.dart

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ void main() {
525525
await tester.pumpWidget(
526526
SimulatedLayout.smallLandscapeMediumPortrait.slot(tester));
527527
await tester.pumpAndSettle();
528-
expect(find.byKey(const Key('Breakpoints.smallMobile')), findsOneWidget);
528+
expect(find.byKey(const Key('Breakpoints.smallMobile')), findsNothing);
529529
expect(find.byKey(const Key('Breakpoints.mediumMobile')), findsNothing);
530530
});
531531

@@ -545,7 +545,7 @@ void main() {
545545
await tester.pumpWidget(
546546
SimulatedLayout.smallLandscapeMediumLargePortrait.slot(tester));
547547
await tester.pumpAndSettle();
548-
expect(find.byKey(const Key('Breakpoints.smallMobile')), findsOneWidget);
548+
expect(find.byKey(const Key('Breakpoints.smallMobile')), findsNothing);
549549
expect(find.byKey(const Key('Breakpoints.largeMobile')), findsNothing);
550550
});
551551
});
@@ -627,6 +627,53 @@ void main() {
627627
expect(find.byKey(const Key('Breakpoints.small')), findsNothing);
628628
});
629629
});
630+
631+
group('Slot And Up Layout Tests with Portrait and Landscape Mixed Layout',
632+
() {
633+
testWidgets(
634+
'slotAndUp shows correct slot for smallPortraitMediumLandscape layout',
635+
(WidgetTester tester) async {
636+
// smallPortraitMediumLandscape layout should only show the small slot.
637+
await tester.pumpWidget(
638+
SimulatedLayout.smallPortraitMediumLandscape.slotAndUp(tester));
639+
await tester.pumpAndSettle();
640+
expect(find.byKey(const Key('Breakpoints.small')), findsOneWidget);
641+
expect(find.byKey(const Key('Breakpoints.mediumAndUp')), findsNothing);
642+
});
643+
644+
testWidgets(
645+
'slotAndUp shows correct slot for smallLandscapeMediumPortrait layout',
646+
(WidgetTester tester) async {
647+
// smallLandscapeMediumPortrait layout should show the small slot.
648+
await tester.pumpWidget(
649+
SimulatedLayout.smallLandscapeMediumPortrait.slotAndUp(tester));
650+
await tester.pumpAndSettle();
651+
expect(find.byKey(const Key('Breakpoints.small')), findsNothing);
652+
expect(find.byKey(const Key('Breakpoints.mediumAndUp')), findsOneWidget);
653+
});
654+
655+
testWidgets(
656+
'slotAndUp shows correct slot for smallPortraitMediumLargeLandscape layout',
657+
(WidgetTester tester) async {
658+
// smallPortraitMediumLargeLandscape layout should show the small slot.
659+
await tester.pumpWidget(
660+
SimulatedLayout.smallPortraitMediumLargeLandscape.slotAndUp(tester));
661+
await tester.pumpAndSettle();
662+
expect(find.byKey(const Key('Breakpoints.small')), findsOneWidget);
663+
expect(find.byKey(const Key('Breakpoints.mediumAndUp')), findsNothing);
664+
});
665+
666+
testWidgets(
667+
'slotAndUp shows correct slot for smallLandscapeMediumLargePortrait layout',
668+
(WidgetTester tester) async {
669+
// smallLandscapeMediumLargePortrait layout should show the small slot.
670+
await tester.pumpWidget(
671+
SimulatedLayout.smallLandscapeMediumLargePortrait.slotAndUp(tester));
672+
await tester.pumpAndSettle();
673+
expect(find.byKey(const Key('Breakpoints.small')), findsNothing);
674+
expect(find.byKey(const Key('Breakpoints.mediumAndUp')), findsOneWidget);
675+
});
676+
});
630677
}
631678

632679
class DummyWidget extends StatelessWidget {

packages/flutter_adaptive_scaffold/test/simulated_layout.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ enum SimulatedLayout {
123123
smallPortraitMediumLargeLandscape(
124124
width: 360, height: 900, navSlotKey: 'bottomNavigation'),
125125
smallLandscapeMediumLargePortrait(
126-
width: 900, height: 360, navSlotKey: 'bottomNavigation');
126+
width: 900, height: 360, navSlotKey: 'primaryNavigation');
127127

128128
const SimulatedLayout({
129129
required double width,

0 commit comments

Comments
 (0)