aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-05 19:13:28 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-05 19:13:28 +0530
commit421d19c758eb1151bff38438e4fe6efb2bf43f78 (patch)
tree56ff5c60f8b68baf7d07f145278b591acde2fb87
parent893404b71b13725d5fa7a5f2fe468a57eeea26e9 (diff)
downloaddaft-launcher-421d19c758eb1151bff38438e4fe6efb2bf43f78.tar.gz
daft-launcher-421d19c758eb1151bff38438e4fe6efb2bf43f78.zip
Adds applist test cases
-rw-r--r--test/components/AppList_test.dart67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/components/AppList_test.dart b/test/components/AppList_test.dart
new file mode 100644
index 0000000..69bf211
--- /dev/null
+++ b/test/components/AppList_test.dart
@@ -0,0 +1,67 @@
+import 'dart:async';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:device_apps/device_apps.dart';
+
+import 'package:owyn/components/AppList.dart';
+
+import '../utils.dart';
+
+void main() {
+ List<Application> appList = <Application>[
+ makeApp('Reddit', 'org.example.reddit'),
+ makeApp('Spotify', 'org.example.spotify'),
+ makeApp('Twitter', 'org.example.twitter'),
+ makeApp('Youtube', 'org.example.youtube'),
+ ];
+
+ testWidgets('Should render nothing for empty list', (WidgetTester tester) async {
+ await tester.pumpWidget(wrapper(AppList(appList: <Application>[])));
+
+ expect(find.byType(ListTile), findsNothing);
+ });
+
+ testWidgets('Should render nothing for empty list', (WidgetTester tester) async {
+ await tester.pumpWidget(wrapper(AppList(appList: appList)));
+
+ expect(find.byType(ListTile), findsNWidgets(4));
+ });
+
+ testWidgets('Should open app on tap', (WidgetTester tester) async {
+ bool wasAppOpened = false;
+ Application openedApp;
+ void mockOpenApp(Application app) {
+ wasAppOpened = true;
+ openedApp = app;
+ }
+
+ await tester.pumpWidget(wrapper(AppList(appList: appList, openApp: mockOpenApp)));
+
+ var listTiles = find.byType(ListTile);
+
+ await tester.tap(listTiles.at(1));
+ await tester.pump();
+
+ expect(wasAppOpened, equals(true));
+ expect(openedApp.packageName, equals('org.example.spotify'));
+ });
+
+ testWidgets('Should open dialog menu on tap and hold', (WidgetTester tester) async {
+ bool wasAppOpened = false;
+ Application openedApp;
+ void mockOpenOptionsMenu(Application app) {
+ wasAppOpened = true;
+ openedApp = app;
+ }
+
+ await tester.pumpWidget(wrapper(AppList(appList: appList, openOptionsMenu: mockOpenOptionsMenu)));
+
+ var listTiles = find.byType(ListTile);
+
+ await tester.longPress(listTiles.at(3));
+ await tester.pump();
+
+ expect(wasAppOpened, equals(true));
+ expect(openedApp.packageName, equals('org.example.youtube'));
+ });
+}