Skip to content

Commit

Permalink
Test: Tilt.LightShadowMode
Browse files Browse the repository at this point in the history
  • Loading branch information
AmosHuKe committed Dec 11, 2024
1 parent 5b067b1 commit 5010d9a
Show file tree
Hide file tree
Showing 20 changed files with 1,538 additions and 977 deletions.
4 changes: 2 additions & 2 deletions test/config/tilt_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_tilt/src/config/tilt_config.dart';

void main() {
group('TiltConfig', () {
group('TiltConfig ::', () {
test('copyWith', () {
const TiltConfig tiltConfig = TiltConfig();
final TiltConfig tiltConfigExpect = TiltConfig(
Expand Down Expand Up @@ -57,7 +57,7 @@ void main() {
expect(tiltConfigCopyWith.hashCode, tiltConfigExpect.hashCode);
});
});
group('TiltDirection', () {
group('TiltDirection ::', () {
test('value', () {
final TiltDirection tiltDirection = -const TiltDirection(1.0, 1.0);
expect(tiltDirection.dx, -1.0);
Expand Down
2 changes: 1 addition & 1 deletion test/config/tilt_light_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_tilt/src/config/tilt_light_config.dart';
import 'package:flutter_tilt/src/enums.dart';

void main() {
group('LightConfig', () {
group('LightConfig ::', () {
test('assert', () {
expect(
() => LightConfig(
Expand Down
2 changes: 1 addition & 1 deletion test/config/tilt_shadow_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_tilt/src/config/tilt_shadow_config.dart';
import 'package:flutter_tilt/src/enums.dart';

void main() {
group('ShadowConfig', () {
group('ShadowConfig ::', () {
test('assert', () {
expect(
() => ShadowConfig(minIntensity: 1.0, maxIntensity: 0.0),
Expand Down
6 changes: 3 additions & 3 deletions test/data/tilt_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_tilt/src/data/tilt_data.dart';
import 'package:flutter_tilt/src/enums.dart';

void main() {
group('TiltData', () {
group('TiltData ::', () {
test('tiltTransform', () {
expect(
const TiltData(
Expand Down Expand Up @@ -72,7 +72,7 @@ void main() {
});
});

group('TiltDataModel', () {
group('TiltDataModel ::', () {
test('hashCode', () {
final TiltDataModel tiltDataModel = TiltDataModel(
position: const Offset(5, 5),
Expand All @@ -91,7 +91,7 @@ void main() {
});
});

group('TiltStreamModel', () {
group('TiltStreamModel ::', () {
test('hashCode', () {
const TiltStreamModel tiltStreamModel = TiltStreamModel(
position: Offset(5, 5),
Expand Down
2 changes: 1 addition & 1 deletion test/internal/tilt_decoration_mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_tilt/src/enums.dart';
import 'package:flutter_tilt/src/internal/tilt_decoration_mixin.dart';

void main() {
group('TiltDecoration', () {
group('TiltDecoration ::', () {
final tiltDecorationTest = TiltDecorationTest();
final tiltDecorationDirectionProgress =
tiltDecorationTest.tiltDecorationDirectionProgress;
Expand Down
2 changes: 1 addition & 1 deletion test/internal/tilt_tween_animation_mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_tilt/src/enums.dart';
import 'package:flutter_tilt/src/internal/tilt_tween_animation_mixin.dart';

void main() {
group('TiltTweenAnimation', () {
group('TiltTweenAnimation ::', () {
final tiltTweenAnimationTest = TiltTweenAnimationTest();
test('tiltTweenAnimationEnd', () {
final tiltTweenAnimationEnd =
Expand Down
2 changes: 1 addition & 1 deletion test/tilt_parallax_widget/tilt_parallax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_tilt/flutter_tilt.dart';
import 'tilt_parallax_widget.dart';

void main() {
group('tilt parallax', () {
group('tilt parallax ::', () {
testWidgets('default', (WidgetTester tester) async {
final Finder outerFinder = find.text('outer');
final Finder innerFinder = find.text('inner');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_tilt/flutter_tilt.dart';

void main() {
group('LightShadowMode.base :: tilt gestures drag ::', () {
testWidgets('scroll', (WidgetTester tester) async {
final Finder childFinder = find.text('Tilt');
final Finder scrollFinder = find.byKey(const Key('scroll'));
final ScrollController scrollController = ScrollController();

debugDefaultTargetPlatformOverride = TargetPlatform.windows;

/// 回调赋值
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ListView(
controller: scrollController,
children: const <Widget>[
Tilt(
key: Key('tilt_widget'),
child: SizedBox(width: 100, height: 100, child: Text('Tilt')),
),
SizedBox(key: Key('scroll'), height: 100, width: 100),
SizedBox(height: 1000),
],
),
),
),
);
debugDefaultTargetPlatformOverride = null;

/// onVerticalDragUpdate
await tester.timedDrag(
childFinder,
const Offset(0.0, -100.0),
const Duration(milliseconds: 1000),
);
await tester.pumpAndSettle();
expect(scrollController.offset, 0.0);
expect(childFinder, findsOneWidget);

/// onHorizontalDragUpdate
await tester.timedDrag(
childFinder,
const Offset(-100.0, 0.0),
const Duration(milliseconds: 1000),
);
await tester.pumpAndSettle();
expect(scrollController.offset, 0.0);
expect(childFinder, findsOneWidget);

/// scroll
await tester.timedDrag(
scrollFinder,
const Offset(0.0, -100.0),
const Duration(milliseconds: 1000),
warnIfMissed: false,
);
await tester.pumpAndSettle();
expect(scrollController.offset, 100.0);
expect(childFinder, findsNothing);
});
});
}
Loading

0 comments on commit 5010d9a

Please sign in to comment.