[gjs/wip/3v1n0/toggle-queue-tests: 4/15] testGObjectDestructionAccess: Check toggle events after the wrapper destruction
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/3v1n0/toggle-queue-tests: 4/15] testGObjectDestructionAccess: Check toggle events after the wrapper destruction
- Date: Tue, 4 May 2021 04:39:07 +0000 (UTC)
commit 4f0912136971eb0c520f42e45b5915b9fbab55fd
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu Apr 29 06:25:41 2021 +0200
testGObjectDestructionAccess: Check toggle events after the wrapper destruction
installed-tests/js/testGObjectDestructionAccess.js | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
---
diff --git a/installed-tests/js/testGObjectDestructionAccess.js
b/installed-tests/js/testGObjectDestructionAccess.js
index ca647ac4..900edbdf 100644
--- a/installed-tests/js/testGObjectDestructionAccess.js
+++ b/installed-tests/js/testGObjectDestructionAccess.js
@@ -628,4 +628,47 @@ describe('Disposed or finalized GObject', function () {
file.ref();
GjsTestTools.unref_other_thread(file);
});
+
+ it('can be toggled up-down from various threads when the wrapper is gone', function () {
+ let file = Gio.File.new_for_path('/');
+ file.expandMeWithToggleRef = true;
+
+ // We also check that late thread events won't affect the destroyed wrapper
+ const threads = [];
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 0));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 100000));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 200000));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 300000));
+ GjsTestTools.save_object(file);
+ GjsTestTools.save_weak(file);
+ file = null;
+ System.gc();
+
+ threads.forEach(th => th.join());
+ GjsTestTools.clear_saved();
+ System.gc();
+
+ expect(GjsTestTools.get_weak()).toBeNull();
+ });
+
+ it('can be toggled up-down from various threads when disposed and the wrapper is gone', function () {
+ let file = Gio.File.new_for_path('/');
+ file.expandMeWithToggleRef = true;
+
+ // We also check that late thread events won't affect the destroyed wrapper
+ const threads = [];
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 0));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 100000));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 200000));
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 300000));
+ GjsTestTools.save_object(file);
+ GjsTestTools.save_weak(file);
+ file.run_dispose();
+ file = null;
+ System.gc();
+
+ threads.forEach(th => th.join());
+ GjsTestTools.clear_saved();
+ expect(GjsTestTools.get_weak()).toBeNull();
+ });
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]