|
| 1 | +import 'package:app_widget/app_widget.dart'; |
| 2 | +import 'package:flutter_test/flutter_test.dart'; |
| 3 | +import 'package:integration_test/integration_test.dart'; |
| 4 | + |
| 5 | +// there is no way to test callback as it need to interact with actual widgets |
| 6 | +void main() { |
| 7 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 8 | + |
| 9 | + group('with androidPackageName', () { |
| 10 | + final AppWidgetPlugin appWidgetPlugin = AppWidgetPlugin( |
| 11 | + androidPackageName: 'tech.noxasch.app_widget_example', |
| 12 | + ); |
| 13 | + |
| 14 | + testWidgets('configureWidget', (tester) async { |
| 15 | + final res = await appWidgetPlugin.configureWidget( |
| 16 | + androidPackageName: 'tech.noxasch.diff_name', |
| 17 | + widgetId: 1, |
| 18 | + widgetLayout: 'example_layout', |
| 19 | + payload: '{"itemId": 1, "stringUid": "uid"}', |
| 20 | + url: 'https://google.come', |
| 21 | + ); |
| 22 | + expect(res, isTrue); |
| 23 | + }); |
| 24 | + |
| 25 | + testWidgets('cancelConfigureWidget', (tester) async { |
| 26 | + final res = await appWidgetPlugin.cancelConfigureWidget(); |
| 27 | + |
| 28 | + expect(res, isTrue); |
| 29 | + }); |
| 30 | + |
| 31 | + testWidgets('updateWidget', (tester) async { |
| 32 | + final res = await appWidgetPlugin.updateWidget( |
| 33 | + androidPackageName: 'tech.noxasch.diff_name', |
| 34 | + widgetId: 1, |
| 35 | + widgetLayout: 'example_layout', |
| 36 | + payload: '{"itemId": 1, "stringUid": "uid"}', |
| 37 | + url: 'https://google.come', |
| 38 | + textViews: {'widget_title': 'my title'}, |
| 39 | + ); |
| 40 | + |
| 41 | + expect(res, isTrue); |
| 42 | + }); |
| 43 | + |
| 44 | + testWidgets('getWidgetIds', (tester) async { |
| 45 | + final res = await appWidgetPlugin.getWidgetIds( |
| 46 | + androidPackageName: 'tech.noxasch.diff_name', |
| 47 | + androidProviderName: 'AppWidgetExampleDiffProvider', |
| 48 | + ); |
| 49 | + |
| 50 | + expect(res, []); |
| 51 | + }); |
| 52 | + |
| 53 | + testWidgets('reloadWidgets', (tester) async { |
| 54 | + final res = await appWidgetPlugin.reloadWidgets( |
| 55 | + androidPackageName: 'tech.noxasch.diff_name', |
| 56 | + androidProviderName: 'AppWidgetExampleDiffProvider', |
| 57 | + ); |
| 58 | + |
| 59 | + expect(res, isTrue); |
| 60 | + }); |
| 61 | + |
| 62 | + testWidgets('widgetExist', (tester) async { |
| 63 | + final res = await appWidgetPlugin.widgetExist(12); |
| 64 | + |
| 65 | + expect(res, isFalse); |
| 66 | + }); |
| 67 | + }); |
| 68 | +} |
0 commit comments