[gjs: 6/7] tests: Test conditions for returning FD list from async DBus method
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 6/7] tests: Test conditions for returning FD list from async DBus method
- Date: Sun, 22 May 2022 05:49:02 +0000 (UTC)
commit 5264cfe1dc980e792ae442ad14435e98389adbef
Author: Philip Chimento <philip chimento gmail com>
Date: Fri Apr 1 17:05:09 2022 -0700
tests: Test conditions for returning FD list from async DBus method
An "Async" promise-based DBus method will return an FD list if it receives
one that is not falsy. This didn't match the behaviour of the "Remote"
callback-based DBus methods, which would always return either an FD list
or null as the third parameter to the callback.
So, when porting from "Remote" to "Async" you may get situations where a
null FD list is now undefined.
Add tests that encode this expectation.
installed-tests/js/testGDBus.js | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/installed-tests/js/testGDBus.js b/installed-tests/js/testGDBus.js
index 2bbe784df..70418e44a 100644
--- a/installed-tests/js/testGDBus.js
+++ b/installed-tests/js/testGDBus.js
@@ -679,6 +679,16 @@ describe('Exported DBus object', function () {
});
});
+ it('can call an async/await method with a Unix FD', async function () {
+ const encoder = new TextEncoder();
+ const expectedBytes = encoder.encode('some bytes');
+ const fd = GjsTestTools.open_bytes(expectedBytes);
+ const fdList = Gio.UnixFDList.new_from_array([fd]);
+ const [bytes, outFdList] = await proxy.fdInAsync(0, fdList);
+ expect(outFdList).not.toBeDefined();
+ expect(bytes).toEqual(expectedBytes);
+ });
+
it('can call an asynchronously implemented remote method with a Unix FD', function (done) {
const expectedBytes = ByteArray.fromString('some bytes');
const fd = GjsTestTools.open_bytes(expectedBytes);
@@ -691,6 +701,16 @@ describe('Exported DBus object', function () {
});
});
+ it('can call an asynchronously implemented async/await method with a Unix FD', async function () {
+ const encoder = new TextEncoder();
+ const expectedBytes = encoder.encode('some bytes');
+ const fd = GjsTestTools.open_bytes(expectedBytes);
+ const fdList = Gio.UnixFDList.new_from_array([fd]);
+ const [bytes, outFdList] = await proxy.fdIn2Async(0, fdList);
+ expect(outFdList).not.toBeDefined();
+ expect(bytes).toEqual(expectedBytes);
+ });
+
function readBytesFromFdSync(fd) {
const stream = new Gio.UnixInputStream({fd, closeFd: true});
const bytes = stream.read_bytes(4096, null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]