Fakultas Ilmu Komputer UI

Commit b4989f04 authored by Fakhira Devina's avatar Fakhira Devina
Browse files
parents e28b03c4 68058279
Pipeline #33222 failed with stages
in 34 minutes and 3 seconds
......@@ -62,11 +62,12 @@ class DashboardState extends State<Dashboard> {
void _navigateToPencarianPage(BuildContext context) {
void _navigateToPencarianPage(BuildContext context) {
final route = MaterialPageRoute(builder: (_) => Pencarian());
static const textFieldKey = Key('Text Field Mau Kemana');
Widget build(BuildContext context) {
return Scaffold(
import 'package:flutter/material.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
class MockNavigatorObserver extends Mock implements NavigatorObserver {}
void main() {
group('Dashboard navigation tests', () {
NavigatorObserver mockObserver;
setUp(() {
mockObserver = MockNavigatorObserver();
Future<Null> _buildDashboardPage(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Dashboard(),
/// This mocked observer will now receive all navigation events
/// that happen in our app.
navigatorObservers: [mockObserver],
/// The tester.pumpWidget() call above just built our app widget
/// and triggered the pushObserver method on the mockObserver once.
verify(mockObserver.didPush(any, any));
Future<Null> _navigateToPencarianPage(WidgetTester tester) async {
final textFieldKey = Key("Text Field Mau Kemana");
await tester.tap(find.byKey(textFieldKey));
await tester.pumpAndSettle();
'when tapping text form field, should navigate to pencarina page',
(WidgetTester tester) async {
final textFieldKeyPencarian = Key("Text Field Mau Kemana");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
verify(mockObserver.didPush(any, any));
expect(find.byKey(textFieldKeyPencarian), findsOneWidget);
testWidgets('tapping the back button should navigate back to the dashboard',
(WidgetTester tester) async {
final backIconKey = Key("Back Icon Key");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
final Route pushedRoute =verify(mockObserver.didPush(captureAny, any)).captured.single;
String popResult;
pushedRoute.popped.then((result) => popResult = result);
await tester.tap(find.byKey(backIconKey));
await tester.pumpAndSettle();
expect(popResult, 'Take me back');
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment