new change to use intaleq_map sdk 04-16-4

This commit is contained in:
Hamza-Ayed
2026-04-16 19:45:03 +03:00
parent 0aa1f15f25
commit a54a7a4189
850 changed files with 83282 additions and 3075 deletions

View File

@@ -0,0 +1,71 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Get.bottomSheet smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
Get.bottomSheet(Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.music_note),
title: const Text('Music'),
onTap: () {},
),
],
));
await tester.pumpAndSettle();
expect(find.byIcon(Icons.music_note), findsOneWidget);
});
testWidgets("Get.bottomSheet close test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
Get.bottomSheet(Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.music_note),
title: const Text('Music'),
onTap: () {},
),
],
));
expect(Get.isBottomSheetOpen, true);
Get.back();
expect(Get.isBottomSheetOpen, false);
// expect(() => Get.bottomSheet(Container(), isScrollControlled: null),
// throwsAssertionError);
// expect(() => Get.bottomSheet(Container(), isDismissible: null),
// throwsAssertionError);
// expect(() => Get.bottomSheet(Container(), enableDrag: null),
// throwsAssertionError);
await tester.pumpAndSettle();
});
// testWidgets(
// "GetMaterialApp with debugShowMaterialGrid null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// debugShowMaterialGrid: null,
// ),
// throwsAssertionError,
// );
// },
// );
}

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Get.defaultDialog smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
Get.defaultDialog(
onConfirm: () => print("Ok"),
middleText: "Dialog made in 3 lines of code");
await tester.pumpAndSettle();
expect(find.text("Ok"), findsOneWidget);
});
testWidgets("Get.dialog smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
Get.dialog(const YourDialogWidget());
await tester.pumpAndSettle();
expect(find.byType(YourDialogWidget), findsOneWidget);
});
testWidgets("Get.dialog close test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
Get.dialog(const YourDialogWidget());
expect(Get.isDialogOpen, true);
Get.back();
expect(Get.isDialogOpen, false);
await tester.pumpAndSettle();
});
}
class YourDialogWidget extends StatelessWidget {
const YourDialogWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}

View File

@@ -0,0 +1,77 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Test dispose dependencies with unnamed routes", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
expect(Get.isRegistered<Controller2>(), false);
expect(Get.isRegistered<Controller>(), false);
Get.to(const First());
await tester.pumpAndSettle();
expect(find.byType(First), findsOneWidget);
expect(Get.isRegistered<Controller>(), true);
Get.to(const Second());
await tester.pumpAndSettle();
expect(find.byType(Second), findsOneWidget);
expect(Get.isRegistered<Controller>(), true);
expect(Get.isRegistered<Controller2>(), true);
Get.back();
await tester.pumpAndSettle();
expect(find.byType(First), findsOneWidget);
expect(Get.isRegistered<Controller>(), true);
expect(Get.isRegistered<Controller2>(), false);
Get.back();
await tester.pumpAndSettle();
expect(Get.isRegistered<Controller>(), false);
expect(Get.isRegistered<Controller2>(), false);
});
}
class Controller extends GetxController {}
class Controller2 extends GetxController {}
class First extends StatelessWidget {
const First({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Get.put(Controller());
return const Center(
child: Text("first"),
);
}
}
class Second extends StatelessWidget {
const Second({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Get.put(Controller2());
return const Center(
child: Text("second"),
);
}
}

View File

@@ -0,0 +1,513 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Get.to navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets("Get.toNamed navigates to provided named route", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.toNamed('/second');
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("unknowroute", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
unknownRoute: GetPage(name: '/404', page: Scaffold.new),
getPages: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.toNamed('/secondd');
await tester.pumpAndSettle();
expect(Get.currentRoute, '/404');
});
testWidgets("Get.off navigates to provided route", (tester) async {
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
Get.off(const SecondScreen());
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("Get.off removes current route", (tester) async {
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
Get.off(const SecondScreen());
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsNothing);
});
testWidgets("Get.offNamed navigates to provided named route", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: FirstScreen.new),
GetPage(name: '/second', page: SecondScreen.new),
GetPage(name: '/third', page: ThirdScreen.new),
],
));
Get.offNamed('/second');
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("Get.offNamed removes current route", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: FirstScreen.new),
GetPage(name: '/second', page: SecondScreen.new),
GetPage(name: '/third', page: ThirdScreen.new),
],
));
Get.offNamed('/second');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsNothing);
});
testWidgets("Get.offNamed removes only current route", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: FirstScreen.new),
GetPage(name: '/second', page: SecondScreen.new),
GetPage(name: '/third', page: ThirdScreen.new),
],
));
Get.toNamed('/second');
Get.offNamed('/third');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets("Get.offAll navigates to provided route", (tester) async {
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
Get.offAll(const SecondScreen());
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("Get.offAll removes all previous routes", (tester) async {
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
Get.to(const SecondScreen());
Get.offAll(const ThirdScreen());
Get.back();
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsNothing);
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsNothing);
});
testWidgets("Get.offAllNamed navigates to provided named route",
(tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.toNamed('/second');
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("Get.offAllNamed removes all previous routes", (tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.toNamed('/second');
Get.offAllNamed('/third');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsNothing);
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsNothing);
});
testWidgets("Get.offAndToNamed navigates to provided route", (tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.offAndToNamed('/second');
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets("Get.offAndToNamed removes previous route", (tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.offAndToNamed('/second');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsNothing);
});
testWidgets("Get.offUntil navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(const FirstScreen());
Get.offUntil(GetPageRoute(page: ThirdScreen.new),
(route) => (route as GetPageRoute).routeName == '/FirstScreen');
await tester.pumpAndSettle();
expect(find.byType(ThirdScreen), findsOneWidget);
});
testWidgets(
"Get.offUntil removes previous routes if they don't match predicate",
(tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(const FirstScreen());
Get.to(const SecondScreen());
Get.offUntil(GetPageRoute(page: ThirdScreen.new),
(route) => (route as GetPageRoute).routeName == '/FirstScreen');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsNothing);
});
testWidgets(
"Get.offUntil leaves previous routes that match provided predicate",
(tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(const FirstScreen());
Get.to(const SecondScreen());
Get.offUntil(GetPageRoute(page: ThirdScreen.new),
(route) => (route as GetPageRoute).routeName == '/FirstScreen');
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets("Get.offNamedUntil navigates to provided route", (tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.offNamedUntil('/second', ModalRoute.withName('/first'));
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
testWidgets(
"Get.offNamedUntil removes previous routes if they don't match predicate",
(tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third')
],
));
Get.toNamed('/second');
Get.offNamedUntil('/third', ModalRoute.withName('/first'));
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsNothing);
});
testWidgets(
"Get.offNamedUntil leaves previous routes that match provided predicate",
(tester) async {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: FirstScreen.new, name: '/first'),
GetPage(page: SecondScreen.new, name: '/second'),
GetPage(page: ThirdScreen.new, name: '/third'),
],
));
Get.toNamed('/second');
Get.offNamedUntil('/third', ModalRoute.withName('/first'));
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets("Get.back navigates back", (tester) async {
await tester.pumpWidget(
const Wrapper(
defaultTransition: Transition.circularReveal,
child: FirstScreen(),
),
);
Get.to(const SecondScreen());
Get.back();
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets(
"Get.back with closeOverlays pops both snackbar and current route",
(tester) async {
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
Get.to(const SecondScreen());
Get.snackbar('title', "message");
Get.back(closeOverlays: true);
await tester.pumpAndSettle();
expect(Get.isSnackbarOpen, false);
expect(find.byType(FirstScreen), findsOneWidget);
});
testWidgets("Get.defaultTransition smoke test", (tester) async {
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.fadeIn,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.downToUp,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.fade,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.leftToRight,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.leftToRightWithFade,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.rightToLeft,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.rightToLeftWithFade,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.cupertino,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
await tester.pumpWidget(
Wrapper(
defaultTransition: Transition.size,
child: Container(),
),
);
Get.to(const FirstScreen());
await tester.pumpAndSettle();
expect(find.byType(FirstScreen), findsOneWidget);
});
}
class FirstScreen extends StatelessWidget {
const FirstScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Text('FirstScreen');
}
}
class SecondScreen extends StatelessWidget {
const SecondScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}
class ThirdScreen extends StatelessWidget {
const ThirdScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}

View File

@@ -0,0 +1,35 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'get_main_test.dart';
class RedirectMiddleware extends GetMiddleware {
@override
RouteSettings redirect(String? route) => const RouteSettings(name: '/second');
}
void main() {
testWidgets("Middleware redirect smoke test", (tester) async {
await tester.pumpWidget(
GetMaterialApp(
initialRoute: '/',
getPages: [
GetPage(name: '/', page: Container.new),
GetPage(
name: '/first',
page: FirstScreen.new,
middlewares: [RedirectMiddleware()]),
GetPage(name: '/second', page: SecondScreen.new),
GetPage(name: '/third', page: ThirdScreen.new),
],
),
);
Get.toNamed('/first');
await tester.pumpAndSettle();
expect(find.byType(SecondScreen), findsOneWidget);
});
}

View File

@@ -0,0 +1,192 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get/get_navigation/src/root/parse_route.dart';
void main() {
test('Parse Page with children', () {
final testParams = {'hi': 'value'};
final pageTree = GetPage(
name: '/city',
page: Container.new,
children: [
GetPage(
name: '/home',
page: Container.new,
transition: Transition.rightToLeftWithFade,
children: [
GetPage(
name: '/bed-room',
transition: Transition.size,
page: Container.new,
),
GetPage(
name: '/living-room',
transition: Transition.topLevel,
page: Container.new,
),
],
),
GetPage(
name: '/work',
transition: Transition.upToDown,
page: Container.new,
children: [
GetPage(
name: '/office',
transition: Transition.zoom,
page: Container.new,
children: [
GetPage(
name: '/pen',
transition: Transition.cupertino,
page: Container.new,
parameters: testParams,
),
GetPage(
name: '/paper',
page: Container.new,
transition: Transition.downToUp,
),
],
),
GetPage(
name: '/meeting-room',
transition: Transition.fade,
page: Container.new,
),
],
),
],
);
final tree = ParseRouteTree(routes: <GetPage>[]);
tree.addRoute(pageTree);
// tree.addRoute(pageTree);
const searchRoute = '/city/work/office/pen';
final match = tree.matchRoute(searchRoute);
expect(match, isNotNull);
expect(match.route!.name, searchRoute);
final testRouteParam = match.route!.parameters!;
for (final tParam in testParams.entries) {
expect(testRouteParam[tParam.key], tParam.value);
}
});
test('Parse Page without children', () {
final pageTree = [
GetPage(
name: '/city', page: Container.new, transition: Transition.cupertino),
GetPage(
name: '/city/home',
page: Container.new,
transition: Transition.downToUp),
GetPage(
name: '/city/home/bed-room',
page: Container.new,
transition: Transition.fade),
GetPage(
name: '/city/home/living-room',
page: Container.new,
transition: Transition.fadeIn),
GetPage(
name: '/city/work',
page: Container.new,
transition: Transition.leftToRight),
GetPage(
name: '/city/work/office',
page: Container.new,
transition: Transition.leftToRightWithFade),
GetPage(
name: '/city/work/office/pen',
page: Container.new,
transition: Transition.native),
GetPage(
name: '/city/work/office/paper',
page: Container.new,
transition: Transition.noTransition),
GetPage(
name: '/city/work/meeting-room',
page: Container.new,
transition: Transition.rightToLeft),
];
final tree = ParseRouteTree(routes: pageTree);
// for (var p in pageTree) {
// tree.addRoute(p);
// }
const searchRoute = '/city/work/office/pen';
final match = tree.matchRoute(searchRoute);
expect(match, isNotNull);
expect(match.route!.name, searchRoute);
});
testWidgets(
'test params from dynamic route',
(tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first/juan',
getPages: [
GetPage(page: Container.new, name: '/first/:name'),
GetPage(page: Container.new, name: '/second/:id'),
GetPage(page: Container.new, name: '/third'),
GetPage(page: Container.new, name: '/last/:id/:name/profile')
],
));
expect(Get.parameters['name'], 'juan');
Get.toNamed('/second/1234');
await tester.pumpAndSettle();
expect(Get.parameters['id'], '1234');
Get.toNamed('/third?name=jonny&job=dev');
await tester.pumpAndSettle();
expect(Get.parameters['name'], 'jonny');
expect(Get.parameters['job'], 'dev');
Get.toNamed('/last/1234/ana/profile');
await tester.pumpAndSettle();
expect(Get.parameters['id'], '1234');
expect(Get.parameters['name'], 'ana');
},
);
testWidgets(
'params in url by parameters',
(tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first/juan',
getPages: [
GetPage(page: Container.new, name: '/first/:name'),
GetPage(page: Container.new, name: '/italy'),
],
));
// Get.parameters = ({"varginias": "varginia", "vinis": "viniiss"});
var parameters = <String, String>{
"varginias": "varginia",
"vinis": "viniiss"
};
// print("Get.parameters: ${Get.parameters}");
parameters.addAll({"a": "b", "c": "d"});
Get.toNamed("/italy", parameters: parameters);
await tester.pumpAndSettle();
expect(Get.parameters['varginias'], 'varginia');
expect(Get.parameters['vinis'], 'viniiss');
expect(Get.parameters['a'], 'b');
expect(Get.parameters['c'], 'd');
},
);
}

View File

@@ -0,0 +1,102 @@
// import 'package:flutter_test/flutter_test.dart';
// import 'package:get/get.dart';
void main() {
// testWidgets(
// "GetMaterialApp with routes null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// routes: null,
// ),
// throwsAssertionError);
// },
// );
// testWidgets(
// "GetMaterialApp with navigatorObservers null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// navigatorObservers: null,
// ),
// throwsAssertionError);
// },
// );
// testWidgets(
// "GetMaterialApp with title null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// title: null,
// ),
// throwsAssertionError);
// },
// );
// testWidgets(
// "GetMaterialApp with debugShowMaterialGrid null",
// (test) async {
// expect(
// () => GetMaterialApp(
// debugShowMaterialGrid: null,
// ),
// throwsAssertionError,
// );
// },
// );
// testWidgets(
// "GetMaterialApp with showPerformanceOverlay null",
// (test) async {
// expect(
// () => GetMaterialApp(
// showPerformanceOverlay: null,
// ),
// throwsAssertionError,
// );
// },
// );
// testWidgets(
// "GetMaterialApp with showSemanticsDebugger null",
// (test) async {
// expect(
// () => GetMaterialApp(
// showSemanticsDebugger: null,
// ),
// throwsAssertionError,
// );
// },
// );
// testWidgets(
// "GetMaterialApp with debugShowCheckedModeBanner null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// debugShowCheckedModeBanner: null,
// ),
// throwsAssertionError);
// },
// );
// testWidgets(
// "GetMaterialApp with checkerboardRasterCacheImages null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// checkerboardRasterCacheImages: null,
// ),
// throwsAssertionError);
// },
// );
// testWidgets(
// "GetMaterialApp with checkerboardOffscreenLayers null",
// (tester) async {
// expect(
// () => GetMaterialApp(
// checkerboardOffscreenLayers: null,
// ),
// throwsAssertionError,
// );
// },
// );
}

View File

@@ -0,0 +1,120 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
void main() {
testWidgets('Back swipe dismiss interrupted by route push', (tester) async {
// final scaffoldKey = GlobalKey();
await tester.pumpWidget(
GetCupertinoApp(
popGesture: true,
home: CupertinoPageScaffold(
// key: scaffoldKey,
child: Center(
child: CupertinoButton(
onPressed: () {
Get.to(() => const CupertinoPageScaffold(
child: Center(child: Text('route')),
));
},
child: const Text('push'),
),
),
),
),
);
// Check the basic iOS back-swipe dismiss transition. Dragging the pushed
// route halfway across the screen will trigger the iOS dismiss animation
await tester.tap(find.text('push'));
await tester.pumpAndSettle();
expect(find.text('route'), findsOneWidget);
expect(find.text('push'), findsNothing);
var gesture = await tester.startGesture(const Offset(5, 300));
await gesture.moveBy(const Offset(400, 0));
await gesture.up();
await tester.pump();
expect(
// The 'route' route has been dragged to the right, halfway across
// the screen
tester.getTopLeft(find.ancestor(
of: find.text('route'),
matching: find.byType(CupertinoPageScaffold))),
const Offset(400, 0),
);
expect(
// The 'push' route is sliding in from the left.
tester
.getTopLeft(find.ancestor(
of: find.text('push'),
matching: find.byType(CupertinoPageScaffold)))
.dx,
0,
);
await tester.pumpAndSettle();
expect(find.text('push'), findsOneWidget);
expect(
tester.getTopLeft(find.ancestor(
of: find.text('push'), matching: find.byType(CupertinoPageScaffold))),
Offset.zero,
);
expect(find.text('route'), findsNothing);
// Run the dismiss animation 60%, which exposes the route "push" button,
// and then press the button.
await tester.tap(find.text('push'));
await tester.pumpAndSettle();
expect(find.text('route'), findsOneWidget);
expect(find.text('push'), findsNothing);
gesture = await tester.startGesture(const Offset(5, 300));
await gesture.moveBy(const Offset(400, 0)); // Drag halfway.
await gesture.up();
// Trigger the snapping animation.
// Since the back swipe drag was brought to >=50% of the screen, it will
// self snap to finish the pop transition as the gesture is lifted.
//
// This drag drop animation is 400ms when dropped exactly halfway
// (800 / [pixel distance remaining], see
// _CupertinoBackGestureController.dragEnd). It follows a curve that is very
// steep initially.
await tester.pump();
expect(
tester.getTopLeft(find.ancestor(
of: find.text('route'),
matching: find.byType(CupertinoPageScaffold))),
const Offset(400, 0),
);
// Let the dismissing snapping animation go 60%.
await tester.pump(const Duration(milliseconds: 240));
expect(
tester
.getTopLeft(find.ancestor(
of: find.text('route'),
matching: find.byType(CupertinoPageScaffold)))
.dx,
moreOrLessEquals(798, epsilon: 1),
);
// Use the navigator to push a route instead of tapping the 'push' button.
// The topmost route (the one that's animating away), ignores input while
// the pop is underway because route.navigator.userGestureInProgress.
Get.to(() => const CupertinoPageScaffold(
child: Center(child: Text('route')),
));
await tester.pumpAndSettle();
expect(find.text('route'), findsOneWidget);
expect(find.text('push'), findsNothing);
expect(
tester
.state<NavigatorState>(find.byType(Navigator))
.userGestureInProgress,
false,
);
});
}

View File

@@ -0,0 +1,247 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
void main() {
testWidgets("test if Get.isSnackbarOpen works with Get.snackbar",
(tester) async {
await tester.pumpWidget(
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: const Text('Open Snackbar'),
onPressed: () {
Get.snackbar(
'title',
"message",
duration: const Duration(seconds: 1),
mainButton:
TextButton(onPressed: () {}, child: const Text('button')),
isDismissible: false,
);
},
),
),
);
expect(Get.isSnackbarOpen, false);
await tester.tap(find.text('Open Snackbar'));
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(seconds: 1));
expect(Get.isSnackbarOpen, false);
});
testWidgets("Get.rawSnackbar test", (tester) async {
await tester.pumpWidget(
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: const Text('Open Snackbar'),
onPressed: () {
Get.rawSnackbar(
title: 'title',
message: "message",
onTap: (_) {
print('snackbar tapped');
},
shouldIconPulse: true,
icon: const Icon(Icons.alarm),
showProgressIndicator: true,
duration: const Duration(seconds: 1),
isDismissible: true,
leftBarIndicatorColor: Colors.amber,
overlayBlur: 1.0,
);
},
),
),
);
expect(Get.isSnackbarOpen, false);
await tester.tap(find.text('Open Snackbar'));
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(seconds: 1));
expect(Get.isSnackbarOpen, false);
});
testWidgets("test snackbar queue", (tester) async {
const messageOne = Text('title');
const messageTwo = Text('titleTwo');
await tester.pumpWidget(
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: const Text('Open Snackbar'),
onPressed: () {
Get.rawSnackbar(
messageText: messageOne, duration: const Duration(seconds: 1));
Get.rawSnackbar(
messageText: messageTwo, duration: const Duration(seconds: 1));
},
),
),
);
expect(Get.isSnackbarOpen, false);
await tester.tap(find.text('Open Snackbar'));
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(milliseconds: 500));
expect(find.text('title'), findsOneWidget);
expect(find.text('titleTwo'), findsNothing);
await tester.pump(const Duration(milliseconds: 500));
expect(find.text('title'), findsNothing);
expect(find.text('titleTwo'), findsOneWidget);
Get.closeAllSnackbars();
});
testWidgets("test snackbar dismissible", (tester) async {
const dismissDirection = DismissDirection.vertical;
const snackBarTapTarget = Key('snackbar-tap-target');
late final GetSnackBar getBar;
await tester.pumpWidget(GetMaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return Column(
children: <Widget>[
GestureDetector(
key: snackBarTapTarget,
onTap: () {
getBar = const GetSnackBar(
message: 'bar1',
duration: Duration(seconds: 2),
isDismissible: true,
dismissDirection: dismissDirection,
);
Get.showSnackbar(getBar);
},
behavior: HitTestBehavior.opaque,
child: const SizedBox(
height: 100.0,
width: 100.0,
),
),
],
);
},
),
),
));
expect(Get.isSnackbarOpen, false);
expect(find.text('bar1'), findsNothing);
await tester.tap(find.byKey(snackBarTapTarget));
await tester.pumpAndSettle();
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(milliseconds: 500));
expect(find.byWidget(getBar), findsOneWidget);
await tester.ensureVisible(find.byWidget(getBar));
await tester.drag(find.byWidget(getBar), const Offset(0.0, 50.0));
await tester.pump(const Duration(milliseconds: 500));
expect(Get.isSnackbarOpen, false);
});
testWidgets("test snackbar onTap", (tester) async {
const dismissDirection = DismissDirection.vertical;
const snackBarTapTarget = Key('snackbar-tap-target');
var counter = 0;
late final GetSnackBar getBar;
late final SnackbarController getBarController;
await tester.pumpWidget(GetMaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return Column(
children: <Widget>[
GestureDetector(
key: snackBarTapTarget,
onTap: () {
getBar = GetSnackBar(
message: 'bar1',
onTap: (_) {
counter++;
},
duration: const Duration(seconds: 2),
isDismissible: true,
dismissDirection: dismissDirection,
);
getBarController = Get.showSnackbar(getBar);
},
behavior: HitTestBehavior.opaque,
child: const SizedBox(
height: 100.0,
width: 100.0,
),
),
],
);
},
),
),
));
await tester.pumpAndSettle();
expect(Get.isSnackbarOpen, false);
expect(find.text('bar1'), findsNothing);
await tester.tap(find.byKey(snackBarTapTarget));
await tester.pumpAndSettle();
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(milliseconds: 500));
expect(find.byWidget(getBar), findsOneWidget);
await tester.ensureVisible(find.byWidget(getBar));
await tester.tap(find.byWidget(getBar));
expect(counter, 1);
await tester.pump(const Duration(milliseconds: 3000));
await getBarController.close(withAnimations: false);
});
testWidgets("Get test actions and icon", (tester) async {
const icon = Icon(Icons.alarm);
final action = TextButton(onPressed: () {}, child: const Text('button'));
late final GetSnackBar getBar;
await tester.pumpWidget(const GetMaterialApp(home: Scaffold()));
expect(Get.isSnackbarOpen, false);
expect(find.text('bar1'), findsNothing);
getBar = GetSnackBar(
message: 'bar1',
icon: icon,
mainButton: action,
leftBarIndicatorColor: Colors.yellow,
showProgressIndicator: true,
// maxWidth: 100,
borderColor: Colors.red,
duration: const Duration(seconds: 1),
isDismissible: false,
);
Get.showSnackbar(getBar);
expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(milliseconds: 500));
expect(find.byWidget(getBar), findsOneWidget);
expect(find.byWidget(icon), findsOneWidget);
expect(find.byWidget(action), findsOneWidget);
await tester.pump(const Duration(milliseconds: 500));
expect(Get.isSnackbarOpen, false);
});
}

View File

@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class Wrapper extends StatelessWidget {
final Widget? child;
final List<GetPage>? namedRoutes;
final String? initialRoute;
final Transition? defaultTransition;
const Wrapper({
Key? key,
this.child,
this.namedRoutes,
this.initialRoute,
this.defaultTransition,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
defaultTransition: defaultTransition,
initialRoute: initialRoute,
translations: WrapperTranslations(),
locale: WrapperTranslations.locale,
getPages: namedRoutes,
home: Scaffold(
body: child,
),
);
}
}
class WrapperNamed extends StatelessWidget {
final Widget? child;
final List<GetPage>? namedRoutes;
final String? initialRoute;
final Transition? defaultTransition;
const WrapperNamed({
Key? key,
this.child,
this.namedRoutes,
this.initialRoute,
this.defaultTransition,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
defaultTransition: defaultTransition,
initialRoute: initialRoute,
getPages: namedRoutes,
);
}
}
class WrapperTranslations extends Translations {
static Locale fallbackLocale = const Locale('en', 'US');
static Locale? get locale => const Locale('en', 'US');
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
'covid': 'Corona Virus',
'total_confirmed': 'Total Confirmed',
'total_deaths': 'Total Deaths',
},
'pt_BR': {
'covid': 'Corona Vírus',
'total_confirmed': 'Total confirmado',
'total_deaths': 'Total de mortes',
},
};
}