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
1 change: 1 addition & 0 deletions packages/tizen_app_control/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Update minimum Flutter and Dart version to 3.13 and 3.1.
* Update code format.
* Add YouTube app launch to the example.
* Update integration tests: relax the `getMatchedAppIds` assertion to accept zero or more results, add a test for `uri`/`mime` round-trip, and verify the exact values of `List<String>` extra data.

## 0.2.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main() {
mime: 'image/*',
);
final List<String> matches = await request.getMatchedAppIds();
expect(matches, isNotEmpty);
expect(matches.length, greaterThanOrEqualTo(0));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Asserting matches.length is greaterThanOrEqualTo(0) is a tautology because a list's length is always non-negative. This assertion will always pass and does not verify anything useful.

If the goal is to verify that the method returns a valid list of strings (even if empty), you can explicitly assert its type using isA<List<String>>().

Suggested change
expect(matches.length, greaterThanOrEqualTo(0));
expect(matches, isA<List<String>>());

}, timeout: kTimeout);

testWidgets('Can send and receive request', (WidgetTester _) async {
Expand All @@ -52,6 +52,21 @@ void main() {
expect(received.shouldReply, isFalse);
}, timeout: kTimeout);

testWidgets('Can send and receive request with uri and mime',
(WidgetTester _) async {
final AppControl request = AppControl(
appId: kAppId,
operation: 'operation_3',
uri: 'myapp://test/path',
mime: 'text/plain',
);
await request.sendLaunchRequest();

final ReceivedAppControl received = await AppControl.onAppControl.first;
Comment on lines +63 to +65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a potential race condition here. Since AppControl.onAppControl is a broadcast stream, any events emitted after sendLaunchRequest() completes but before AppControl.onAppControl.first is subscribed to will be lost.

To prevent flakiness, you should start listening to the stream (by creating the Future) before calling sendLaunchRequest().

Suggested change
await request.sendLaunchRequest();
final ReceivedAppControl received = await AppControl.onAppControl.first;
final Future<ReceivedAppControl> receivedFuture = AppControl.onAppControl.first;
await request.sendLaunchRequest();
final ReceivedAppControl received = await receivedFuture;

expect(received.uri, 'myapp://test/path');
expect(received.mime, 'text/plain');
}, timeout: kTimeout);

testWidgets('Omit invalid extra data', (WidgetTester _) async {
final AppControl request = AppControl(
appId: kAppId,
Expand All @@ -66,7 +81,7 @@ void main() {
final ReceivedAppControl received = await AppControl.onAppControl.first;
expect(received.extraData.length, 2);
expect(received.extraData['STRING_DATA'], 'string');
expect(received.extraData['STRING_LIST_DATA'], isNotEmpty);
expect(received.extraData['STRING_LIST_DATA'], <String>['string', 'list']);
}, timeout: kTimeout);

testWidgets('Can send and receive reply', (WidgetTester _) async {
Expand Down
Loading