-
Notifications
You must be signed in to change notification settings - Fork 52
[tizen_package_manager] Add integration tests and fix icon path handling #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seungsoo47
wants to merge
6
commits into
flutter-tizen:master
Choose a base branch
from
seungsoo47:tizen_package_manager-add-integration-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f021ef
[tizen_package_manager] Fix empty iconPath returned as empty string i…
seungsoo47 cbbfd9a
[tizen_package_manager] Add regression integration tests
seungsoo47 b0f3c3f
[tizen_package_manager] Fix formatting in integration test
seungsoo47 5673b98
[tizen_package_manager] Harden package icon path handling
seungsoo47 2f217b0
[tizen_package_manager] Use idiomatic async matchers in integration t…
seungsoo47 b640597
[tizen_package_manager] Simplify redundant assertions in integration …
seungsoo47 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
|
|
||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
| import 'package:tizen_package_manager/tizen_package_manager.dart'; | ||
|
|
@@ -37,4 +40,139 @@ void main() { | |
| final List<PackageInfo> infos = await PackageManager.getPackagesInfo(); | ||
| expect(infos.isNotEmpty, true); | ||
| }); | ||
|
|
||
| group('PackageInfo fields', () { | ||
| testWidgets('installedStorageType is a valid StorageType value', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final PackageInfo info = | ||
| await PackageManager.getPackageInfo(currentPackageId); | ||
| expect(StorageType.values, contains(info.installedStorageType)); | ||
| }); | ||
|
|
||
| testWidgets('iconPath is null or a non-empty string', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final PackageInfo info = | ||
| await PackageManager.getPackageInfo(currentPackageId); | ||
| expect(info.iconPath, anyOf(isNull, isNotEmpty)); | ||
| }); | ||
| }); | ||
|
|
||
| group('PackageSizeInfo fields', () { | ||
| testWidgets('all size fields are non-negative', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final PackageSizeInfo info = | ||
| await PackageManager.getPackageSizeInfo(currentPackageId); | ||
| expect(info.dataSize, greaterThanOrEqualTo(0)); | ||
| expect(info.cacheSize, greaterThanOrEqualTo(0)); | ||
| expect(info.appSize, greaterThanOrEqualTo(0)); | ||
| expect(info.externalDataSize, greaterThanOrEqualTo(0)); | ||
| expect(info.externalCacheSize, greaterThanOrEqualTo(0)); | ||
| expect(info.externalAppSize, greaterThanOrEqualTo(0)); | ||
| }); | ||
| }); | ||
|
|
||
| group('getPackagesInfo list items', () { | ||
| testWidgets('each PackageInfo item has valid field values', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final List<PackageInfo> infos = await PackageManager.getPackagesInfo(); | ||
| expect(infos, isNotEmpty); | ||
| for (final PackageInfo info in infos) { | ||
| // Field types are already guaranteed by PackageInfo.fromMap (it casts | ||
| // each field), so only the value-level expectations are asserted here. | ||
| expect(info.packageId, isNotEmpty); | ||
| expect(info.version, isNotEmpty); | ||
| expect(info.iconPath, anyOf(isNull, isNotEmpty)); | ||
| } | ||
| }); | ||
|
|
||
| testWidgets('getPackagesInfo contains current package', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final List<PackageInfo> infos = await PackageManager.getPackagesInfo(); | ||
| final Iterable<String> ids = infos.map((PackageInfo i) => i.packageId); | ||
| expect(ids, contains(currentPackageId)); | ||
| }); | ||
| }); | ||
|
|
||
| group('getPackageInfo error paths', () { | ||
| testWidgets('throws ArgumentError for empty packageId', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| await expectLater( | ||
| PackageManager.getPackageInfo(''), | ||
| throwsArgumentError, | ||
| ); | ||
| }); | ||
|
|
||
| testWidgets('throws PlatformException for invalid packageId', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| await expectLater( | ||
| PackageManager.getPackageInfo('invalid.package.id.that.does.not.exist'), | ||
| throwsA(isA<PlatformException>()), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| group('getPackageSizeInfo error paths', () { | ||
| testWidgets('throws ArgumentError for empty packageId', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| await expectLater( | ||
| PackageManager.getPackageSizeInfo(''), | ||
| throwsArgumentError, | ||
| ); | ||
| }); | ||
|
|
||
| // NOTE: The Tizen package_manager_get_package_size_info API does not | ||
| // return an error for a non-existent package ID; it silently returns | ||
| // zero-valued size info. This is a platform limitation, so no | ||
| // PlatformException test is included here. | ||
| }); | ||
|
|
||
| group('install error paths', () { | ||
| testWidgets('throws ArgumentError for empty packagePath', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| await expectLater(PackageManager.install(''), throwsArgumentError); | ||
| }); | ||
| }); | ||
|
|
||
| group('uninstall error paths', () { | ||
| testWidgets('throws ArgumentError for empty packageId', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| await expectLater(PackageManager.uninstall(''), throwsArgumentError); | ||
| }); | ||
| }); | ||
|
|
||
| group('event streams', () { | ||
| testWidgets('onInstallProgressChanged can be listened to without error', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final StreamSubscription<PackageEvent> subscription = | ||
| PackageManager.onInstallProgressChanged.listen(null); | ||
| await subscription.cancel(); | ||
| }); | ||
|
|
||
| testWidgets('onUninstallProgressChanged can be listened to without error', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final StreamSubscription<PackageEvent> subscription = | ||
| PackageManager.onUninstallProgressChanged.listen(null); | ||
| await subscription.cancel(); | ||
| }); | ||
|
|
||
| testWidgets('onUpdateProgressChanged can be listened to without error', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| final StreamSubscription<PackageEvent> subscription = | ||
| PackageManager.onUpdateProgressChanged.listen(null); | ||
| await subscription.cancel(); | ||
| }); | ||
|
Comment on lines
+137
to
+176
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test does not have an except process. Is it simply checking whether it works? If it is an await, you must check the result through a timeout or separate processing and verify the successful call status. |
||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test is invalid because the type of info.installedStorageType is StorageType and it must return one of them.