Fakultas Ilmu Komputer UI

Commit 28a07c47 authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[REFACTOR] move drawer test to different file and fixing error in drawer

parent e87bb5ef
Pipeline #42030 failed with stages
in 17 minutes and 15 seconds
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-20 14:48:37.594917","version":"1.15.17"}
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}]}
\ No newline at end of file
......@@ -6,7 +6,7 @@ class BisaGoDrawer extends StatelessWidget {
{'title': 'Beranda', 'icon': Icons.home},
{'title': 'Riwayat Pencarian', 'icon': Icons.history},
{'title': 'Tentang Aplikasi', 'icon': Icons.info},
{'title': 'Log out', 'icon': Icons.keyboard_backspace}
{'title': 'Login', 'icon': Icons.keyboard_backspace}
];
@override
......@@ -24,10 +24,13 @@ class BisaGoDrawer extends StatelessWidget {
),
child: Row(
children: <Widget>[
FloatingActionButton(
backgroundColor: Colors.white,
elevation: 0,
onPressed: () => {},
SizedBox(
width: 40,
child: FloatingActionButton(
backgroundColor: Colors.white,
elevation: 0,
onPressed: () => {},
),
),
Padding(
padding: EdgeInsets.all(doubleSpace),
......@@ -79,7 +82,9 @@ class BisaGoDrawer extends StatelessWidget {
),
),
onTap: () {
Navigator.pushNamed(context, '/login');
if(title == 'Login') {
_navigateToLogin(context);
}
},
),
decoration: BoxDecoration(
......@@ -90,4 +95,8 @@ class BisaGoDrawer extends StatelessWidget {
),
);
}
void _navigateToLogin(BuildContext context) {
}
}
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/component/bisago_drawer.dart';
void main() {
group('drawer tests', () {
testWidgets('my drawer test', (WidgetTester tester) async {
final loginText = "Login";
await tester.pumpWidget(MaterialApp(
home: Scaffold(
drawer: BisaGoDrawer(),
)));
await tester.dragFrom(tester.getTopLeft(find.byType(MaterialApp)), Offset(300, 0));
await tester.pumpAndSettle();
await tester.tap(find.text(loginText));
await tester.pumpAndSettle();
final textFieldLogin = 'Masuk ke Akun';
expect(find.text(textFieldLogin), findsOneWidget);
});
// Future<Null> _navigateToLoginPage(WidgetTester tester) async {
// final textToFind = 'Login';
// await tester.tap(find.text(textToFind));
// await tester.pump();
// }
//
// testWidgets(
// 'when tapping Login in drawer, should navigate to login',
// (WidgetTester tester) async {
// final textFieldLogin = 'Masuk ke Akun';
// await _navigateToLoginPage(tester);
//
// verify(mockObserver.didPush(any, any));
// expect(find.text(textFieldLogin), findsOneWidget);
// });
});
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ import 'package:mockito/mockito.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/network/network_interface.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
import 'package:ppl_disabilitas/component/bisago_drawer.dart';
import 'package:http/http.dart' as http;
import 'package:pedantic/pedantic.dart';
......@@ -84,24 +83,5 @@ void main() {
await tester.pumpAndSettle();
expect(popResult, 'Take me back');
});
Future<Null> _navigateToLoginPage(WidgetTester tester) async {
final drawer = find.byType(BisaGoDrawer);
await tester.tap(drawer);
final textToFind = 'Login';
await tester.tap(find.text(textToFind));
await tester.pump();
}
testWidgets(
'when tapping text form field, should navigate to pencarian page',
(WidgetTester tester) async {
final textFieldLogin = 'Masuk ke Akun';
await _buildDashboardPage(tester);
await _navigateToLoginPage(tester);
verify(mockObserver.didPush(any, any));
expect(find.text(textFieldLogin), findsOneWidget);
});
});
}
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