Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/tizen_package_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.4.3

* Return a null icon path (instead of an empty string) when a package has no
icon, and ignore `package_info_get_icon` failures since the icon is optional.
* Add 13 integration test cases.

## 0.4.2

* Remove Ecore API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Comment on lines +48 to +50

Copy link
Copy Markdown
Member

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.

});

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

});
}
2 changes: 1 addition & 1 deletion packages/tizen_package_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: tizen_package_manager
description: Tizen package manager APIs. Used to get information about packages installed on a Tizen device.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/tizen_package_manager
version: 0.4.2
version: 0.4.3

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,15 @@ std::optional<PackageInfo> TizenPackageManager::GetPackageData(
result.type = type;
free(type);

// The icon path is optional: a package may have no icon, so a failure here is
// not treated as fatal. Only use the value when the call succeeds and the
// path is non-empty.
char *icon_path = nullptr;
ret = package_info_get_icon(handle, &icon_path);
if (icon_path) {
if (ret == PACKAGE_MANAGER_ERROR_NONE && icon_path && icon_path[0] != '\0') {
result.icon_path = icon_path;
}
if (icon_path) {
free(icon_path);
}

Expand Down
Loading