Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ void main() {
expect(received.operation, 'http://tizen.org/appcontrol/operation/default');
}, timeout: kTimeout);

testWidgets('Can find matching applications', (WidgetTester _) async {
final AppControl request = AppControl(
operation: 'http://tizen.org/appcontrol/operation/view',
uri: 'file:///opt/usr/globalapps/$kAppId/shared/res/ic_launcher.png',
mime: 'image/*',
);
final List<String> matches = await request.getMatchedAppIds();
expect(matches, isNotEmpty);
}, timeout: kTimeout);
Comment on lines +29 to +37
Copy link
Member Author

Choose a reason for hiding this comment

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

This test should not be run on TV emulators. I couldn't find any operation that is commonly available on both wearable and TV emulators.

Copy link
Contributor

Choose a reason for hiding this comment

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

how about tagging this test to mark "wearable only"?
https://pub.dev/packages/test#tagging-tests

Copy link
Member Author

@swift-kim swift-kim Sep 27, 2021

Choose a reason for hiding this comment

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

Could you elaborate on how to configure? How can the test runner detect the current device profile at runtime?


testWidgets('Can send and receive request', (WidgetTester _) async {
// Send a request to this app (the test runner itself).
final AppControl request = AppControl(
Expand Down
14 changes: 14 additions & 0 deletions packages/tizen_app_control/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class _MyAppState extends State<MyApp> {
'http://tizen.org/appcontrol/data/text': 'Some text',
},
);
final List<String> matches = await request.getMatchedAppIds();
if (matches.isEmpty) {
_messengerKey.currentState!.showSnackBar(
const SnackBar(content: Text('No application found.')),
);
return;
}
await request.sendLaunchRequest();
}

Expand All @@ -108,6 +115,13 @@ class _MyAppState extends State<MyApp> {
mime: 'image/*',
launchMode: LaunchMode.group,
);
final List<String> matches = await request.getMatchedAppIds();
if (matches.isEmpty) {
_messengerKey.currentState!.showSnackBar(
const SnackBar(content: Text('No application found.')),
);
return;
}
await request.sendLaunchRequest(
replyCallback: (
AppControl request,
Expand Down
14 changes: 11 additions & 3 deletions packages/tizen_app_control/lib/app_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ class AppControl {
.map((dynamic event) => ReceivedAppControl._fromMap(
Map<String, dynamic>.from(event as Map<dynamic, dynamic>)));

/// Returns a list of installed applications that can handle this request.
Future<List<String>> getMatchedAppIds() async {
await _setAppControlData();

final Map<String, dynamic> args = <String, dynamic>{'id': _id};
final dynamic response =
await _methodChannel.invokeMethod<dynamic>('getMatchedAppIds', args);
return List<String>.from(response as List<dynamic>);
}

/// Sends a launch request to an application.
///
/// The `http://tizen.org/privilege/appmanager.launch` privilege is required
Expand Down Expand Up @@ -197,9 +207,7 @@ class AppControl {
Future<void> sendTerminateRequest() async {
await _setAppControlData();

final Map<String, dynamic> args = <String, dynamic>{
'id': _id,
};
final Map<String, dynamic> args = <String, dynamic>{'id': _id};
await _methodChannel.invokeMethod<void>('sendTerminateRequest', args);
}

Expand Down