[gjs: 2/3] tests: Add tests for new signal functionality



commit 49844ddd4cfeb5ce47b484ed0d0159b1e83d11b1
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed May 9 23:47:03 2018 -0700

    tests: Add tests for new signal functionality
    
    This adds regression tests for:
    - signals on interfaces
    - signals with in-out parameters
    
    These tests were newly added to the Regress test suite, so this requires
    the latest gobject-introspection.
    
    The in-out parameter test is skipped because in-out parameters still
    don't yet work correctly.
    
    See #147 and gobject-introspection!32.

 configure.ac                                     |  2 +-
 installed-tests/js/testEverythingBasic.js        |  7 +++++++
 installed-tests/js/testEverythingEncapsulated.js | 17 +++++++++++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 24955d12..4ad1a775 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,7 +354,7 @@ AC_CONFIG_LINKS([
 AC_OUTPUT
 
 # Warn about conditions that affect runtime
-PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.53.4], [], [
+PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.57.2], [], [
     AC_MSG_WARN([You do not have a new enough version of
 gobject-introspection to run the tests. You can still build GJS, but some
 tests will fail.])])
diff --git a/installed-tests/js/testEverythingBasic.js b/installed-tests/js/testEverythingBasic.js
index 4b50f655..d8e6c250 100644
--- a/installed-tests/js/testEverythingBasic.js
+++ b/installed-tests/js/testEverythingBasic.js
@@ -565,6 +565,13 @@ describe('Life, the Universe and Everything', function () {
             o.emit('sig-with-array-len-prop', null);
             expect(handler).toHaveBeenCalledWith([jasmine.any(Object), null]);
         }).pend('Not yet implemented');
+
+        xit('signal with int in-out parameter', function() {
+            let handler = jasmine.createSpy('handler').and.callFake(() => 43);
+            o.connect('sig-with-inout-int', handler);
+            o.emit_sig_with_inout_int();
+            expect(handler.toHaveBeenCalledWith([jasmine.any(Object), 42]));
+        }).pend('Not yet implemented');
     });
 
     describe('Signal alternative syntax', function () {
diff --git a/installed-tests/js/testEverythingEncapsulated.js 
b/installed-tests/js/testEverythingEncapsulated.js
index d463fd75..b24d5cba 100644
--- a/installed-tests/js/testEverythingEncapsulated.js
+++ b/installed-tests/js/testEverythingEncapsulated.js
@@ -1,5 +1,4 @@
-const GLib = imports.gi.GLib;
-const Regress = imports.gi.Regress;
+const {GLib, GObject, Regress} = imports.gi;
 const System = imports.system;
 
 describe('Introspected structs', function () {
@@ -291,3 +290,17 @@ describe('Garbage collection of introspected objects', function () {
         GLib.idle_add(GLib.PRIORITY_LOW, () => done());
     });
 });
+
+describe('Introspected interface', function () {
+    const Implementor = GObject.registerClass({
+        Implements: [Regress.TestInterface],
+    }, class Implementor extends GObject.Object {});
+
+    it('correctly emits interface signals', function () {
+        let obj = new Implementor();
+        let handler = jasmine.createSpy('handler').and.callFake(() => {});
+        obj.connect('interface-signal', handler);
+        obj.emit_signal();
+        expect(handler).toHaveBeenCalled();
+    });
+});


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]