Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fujidaiti committed Dec 19, 2024
1 parent ecd076e commit ed42e4a
Showing 1 changed file with 51 additions and 25 deletions.
76 changes: 51 additions & 25 deletions test/paged/paged_sheet_geometry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:smooth_sheets/src/foundation/sheet_activity.dart';
import 'package:smooth_sheets/src/foundation/sheet_position.dart';
import 'package:smooth_sheets/src/foundation/sheet_status.dart';
import 'package:smooth_sheets/src/paged/paged_sheet_geometry.dart';
import 'package:smooth_sheets/src/paged/paged_sheet_route.dart';
import 'package:smooth_sheets/src/paged/route_transition_observer.dart';
Expand Down Expand Up @@ -65,45 +66,30 @@ void main() {
initialMaxOffset: const SheetAnchor.proportional(1),
);

final (newRoute, newRouteTransitionController) = _createRoute(
final (newRoute, newRouteTransitionController) = _pushRoute(
geometry: geometryUnderTest,
currentRoute: initialRoute,
routeContentSize: const Size(400, 600),
initialOffset: const SheetAnchor.proportional(1),
minOffset: const SheetAnchor.proportional(1),
maxOffset: const SheetAnchor.proportional(1),
transitionDuration: const Duration(milliseconds: 200),
);

final pushTransition = _startForwardTransition(
geometry: geometryUnderTest,
currentRoute: initialRoute,
newRoute: newRoute,
newRouteContentSize: const Size(400, 600),
newRouteTransitionController: newRouteTransitionController,
);
expect(geometryUnderTest.maybePixels, 200);
expect(geometryUnderTest.maybeContentSize, const Size(400, 400));
expect(geometryUnderTest.activity, isA<RouteTransitionSheetActivity>());

pushTransition
..tickAndSettle()
..end();
expect(geometryUnderTest.maybePixels, 600);
expect(geometryUnderTest.maybeMinPixels, 600);
expect(geometryUnderTest.maybeMaxPixels, 600);
expect(geometryUnderTest.maybeContentSize, const Size(400, 600));
expect(geometryUnderTest.activity, isA<IdleSheetActivity>());

final popTransition = _startBackwardTransition(
_popRoute(
geometry: geometryUnderTest,
currentRoute: newRoute,
destinationRoute: initialRoute,
currentRouteTransitionController: newRouteTransitionController,
);
expect(geometryUnderTest.maybePixels, 600);
expect(geometryUnderTest.maybeContentSize, const Size(400, 600));
expect(geometryUnderTest.activity, isA<RouteTransitionSheetActivity>());

popTransition
..tickAndSettle()
..end();
expect(geometryUnderTest.maybePixels, 200);
expect(geometryUnderTest.maybeMinPixels, 200);
expect(geometryUnderTest.maybeMaxPixels, 400);
expect(geometryUnderTest.maybeContentSize, const Size(400, 400));
expect(geometryUnderTest.activity, isA<IdleSheetActivity>());
});
Expand Down Expand Up @@ -223,7 +209,40 @@ void main() {
expect(geometryUnderTest.maybeContentSize, const Size(400, 400));
});

test('Maintain offsets of each route throughout the transitions', () {});
test('Maintain offsets of each route throughout the transitions', () {

Check failure on line 212 in test/paged/paged_sheet_geometry_test.dart

View workflow job for this annotation

GitHub Actions / Test Report (with Flutter 3.22.3)

test/paged/paged_sheet_geometry_test.dart ► Transition test ► Maintain offsets of each route throughout the transitions

Failed test found in: /home/runner/work/smooth_sheets/smooth_sheets/flutter-test-report.json Error: LateInitializationError: Field 'controller' has not been initialized.
Raw output
package:smooth_sheets/src/foundation/sheet_activity.dart                    ControlledSheetActivityMixin.controller
package:smooth_sheets/src/foundation/sheet_activity.dart 578:5              ControlledSheetActivityMixin.dispose
package:smooth_sheets/src/foundation/sheet_position.dart 457:16             SheetPosition.dispose
package:smooth_sheets/src/scrollable/scrollable_sheet_position.dart 111:11  DraggableScrollableSheetPosition.dispose
test/paged/paged_sheet_geometry_test.dart 28:23                             main.<fn>
final initialRoute = _firstBuild(
geometry: geometryUnderTest,
initialRouteContentSize: const Size(400, 400),
viewportSize: const Size(400, 800),
initialOffset: const SheetAnchor.proportional(0.5),
initialMinOffset: const SheetAnchor.proportional(0.5),
initialMaxOffset: const SheetAnchor.proportional(1),
);

final testActivity = _TestSheetActivity();
geometryUnderTest.beginActivity(testActivity);
testActivity.setOffset(400);
expect(geometryUnderTest.maybePixels, 400);

final (newRoute, newRouteTransitionController) = _pushRoute(
geometry: geometryUnderTest,
currentRoute: initialRoute,
initialOffset: const SheetAnchor.proportional(1),
minOffset: const SheetAnchor.proportional(1),
maxOffset: const SheetAnchor.proportional(1),
routeContentSize: const Size(400, 600),
transitionDuration: const Duration(milliseconds: 200),
);
expect(geometryUnderTest.maybePixels, 600);

_popRoute(
geometry: geometryUnderTest,
currentRoute: newRoute,
destinationRoute: initialRoute,
currentRouteTransitionController: newRouteTransitionController,
);
expect(geometryUnderTest.maybePixels, 450);
});

test('Sync offset with progress of the swipe-back gesture', () {
final initialRoute = _firstBuild(
Expand Down Expand Up @@ -499,3 +518,10 @@ void _popRoute({
..tickAndSettle()
..end();
}

class _TestSheetActivity extends SheetActivity {
void setOffset(double offset) => owner.setPixels(offset);

@override
SheetStatus get status => SheetStatus.animating;
}

0 comments on commit ed42e4a

Please sign in to comment.