|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
| 5 | +import 'package:flutter/services.dart'; |
5 | 6 | import 'package:flutter_test/flutter_test.dart'; |
6 | 7 | import 'package:integration_test/integration_test.dart'; |
7 | 8 | import 'package:tizen_app_manager/tizen_app_manager.dart'; |
@@ -35,4 +36,70 @@ void main() { |
35 | 36 | expect(context.processId, isPositive); |
36 | 37 | expect(context.isTerminated, isFalse); |
37 | 38 | }); |
| 39 | + |
| 40 | + group('AppManager', () { |
| 41 | + group('getInstalledApps', () { |
| 42 | + testWidgets('returns non-empty list', (WidgetTester _) async { |
| 43 | + final List<AppInfo> apps = await AppManager.getInstalledApps(); |
| 44 | + expect(apps, isNotEmpty); |
| 45 | + }); |
| 46 | + |
| 47 | + testWidgets('includes the current app', (WidgetTester _) async { |
| 48 | + final String appId = await AppManager.currentAppId; |
| 49 | + final List<AppInfo> apps = await AppManager.getInstalledApps(); |
| 50 | + expect(apps.any((AppInfo app) => app.appId == appId), isTrue); |
| 51 | + }); |
| 52 | + }); |
| 53 | + |
| 54 | + group('isRunning', () { |
| 55 | + testWidgets('returns true for running app', (WidgetTester _) async { |
| 56 | + final String appId = await AppManager.currentAppId; |
| 57 | + expect(await AppManager.isRunning(appId), isTrue); |
| 58 | + }); |
| 59 | + |
| 60 | + testWidgets('returns false for non-running app', (WidgetTester _) async { |
| 61 | + expect( |
| 62 | + await AppManager.isRunning('org.tizen.nonexistent'), |
| 63 | + isFalse, |
| 64 | + ); |
| 65 | + }); |
| 66 | + |
| 67 | + testWidgets('throws ArgumentError for empty appId', |
| 68 | + (WidgetTester _) async { |
| 69 | + await expectLater(AppManager.isRunning(''), throwsArgumentError); |
| 70 | + }); |
| 71 | + }); |
| 72 | + |
| 73 | + group('getAppInfo', () { |
| 74 | + testWidgets('returns all AppInfo fields', (WidgetTester _) async { |
| 75 | + final String appId = await AppManager.currentAppId; |
| 76 | + final AppInfo appInfo = await AppManager.getAppInfo(appId); |
| 77 | + expect(appInfo.appId, appId); |
| 78 | + expect(appInfo.executablePath, isNotEmpty); |
| 79 | + expect(appInfo.sharedResourcePath, isNotEmpty); |
| 80 | + }); |
| 81 | + |
| 82 | + testWidgets('throws ArgumentError for empty appId', |
| 83 | + (WidgetTester _) async { |
| 84 | + await expectLater(AppManager.getAppInfo(''), throwsArgumentError); |
| 85 | + }); |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + group('AppRunningContext', () { |
| 90 | + testWidgets('packageId matches current app', (WidgetTester _) async { |
| 91 | + final String appId = await AppManager.currentAppId; |
| 92 | + final AppRunningContext context = AppRunningContext(appId: appId); |
| 93 | + expect(context.packageId, 'org.tizen.tizen_app_manager_example'); |
| 94 | + }); |
| 95 | + |
| 96 | + testWidgets('throws PlatformException for non-running appId', ( |
| 97 | + WidgetTester _, |
| 98 | + ) async { |
| 99 | + expect( |
| 100 | + () => AppRunningContext(appId: 'org.tizen.nonexistent'), |
| 101 | + throwsA(isA<PlatformException>()), |
| 102 | + ); |
| 103 | + }); |
| 104 | + }); |
38 | 105 | } |
0 commit comments