-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f095ff
commit 2683b48
Showing
1 changed file
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,60 @@ | ||
void main() {} | ||
import 'dart:io'; | ||
|
||
import 'package:dbus/dbus.dart'; | ||
import 'package:xdg_status_notifier_item/xdg_status_notifier_item.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
class MockNotifierWatcherObject extends DBusObject { | ||
MockNotifierWatcherObject() : super(DBusObjectPath('/StatusNotifierWatcher')); | ||
|
||
@override | ||
Future<DBusMethodResponse> handleMethodCall(DBusMethodCall methodCall) async { | ||
if (methodCall.interface != 'org.kde.StatusNotifierWatcher') { | ||
return DBusMethodErrorResponse.unknownInterface(); | ||
} | ||
|
||
switch (methodCall.name) { | ||
case 'RegisterStatusNotifierItem': | ||
return DBusMethodSuccessResponse(); | ||
|
||
default: | ||
return DBusMethodErrorResponse.unknownMethod(); | ||
} | ||
} | ||
} | ||
|
||
class MockNotifierWatcherServer extends DBusClient { | ||
late final MockNotifierWatcherObject _root; | ||
|
||
MockNotifierWatcherServer(DBusAddress clientAddress) : super(clientAddress) { | ||
_root = MockNotifierWatcherObject(); | ||
} | ||
|
||
Future<void> start() async { | ||
await requestName('org.kde.StatusNotifierWatcher'); | ||
await registerObject(_root); | ||
} | ||
} | ||
|
||
void main() { | ||
test('connect', () async { | ||
var server = DBusServer(); | ||
var clientAddress = | ||
await server.listenAddress(DBusAddress.unix(dir: Directory.systemTemp)); | ||
addTearDown(() async { | ||
await server.close(); | ||
}); | ||
|
||
var watcher = MockNotifierWatcherServer(clientAddress); | ||
await watcher.start(); | ||
addTearDown(() async { | ||
await watcher.close(); | ||
}); | ||
|
||
var client = StatusNotifierItemClient(id: 'test', menu: DBusMenuItem()); | ||
addTearDown(() async { | ||
await client.close(); | ||
}); | ||
await client.connect(); | ||
}); | ||
} |