[gjs] tests: Ensure a Cairo context is fully created in GI



commit 23fb49b949b67da932164959563ae8732897e03e
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Apr 4 19:47:02 2017 -0700

    tests: Ensure a Cairo context is fully created in GI
    
    According to the bug report, if you created a Cairo context through a GI
    function such as Gdk.cairo_create(), it would be an empty wrapper. At some
    point this was fixed, I suspect in SpiderMonkey itself, by associating the
    prototype object with the JSClass and having JS_NewObject() look for it.
    
    However, this behaviour may have changed in SpiderMonkey 45, so we should
    add a test to make sure it doesn't regress.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=614413

 installed-tests/js/testCairo.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/installed-tests/js/testCairo.js b/installed-tests/js/testCairo.js
index 6dc6f1f..0d08eee 100644
--- a/installed-tests/js/testCairo.js
+++ b/installed-tests/js/testCairo.js
@@ -1,4 +1,6 @@
 const Cairo = imports.cairo;
+const Gdk = imports.gi.Gdk;
+const Gtk = imports.gi.Gtk;
 const Regress = imports.gi.Regress;
 
 function _ts(obj) {
@@ -6,6 +8,10 @@ function _ts(obj) {
 }
 
 describe('Cairo', function () {
+    beforeAll(function () {
+        Gtk.init(null);
+    });
+
     let cr, surface;
     beforeEach(function () {
         surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, 1, 1);
@@ -163,6 +169,17 @@ describe('Cairo', function () {
             o.emit_sig_with_foreign_struct();
             expect(foreignSpy).toHaveBeenCalledWith(o, cr);
         });
+
+        it('has methods when created from a C function', function () {
+            let win = new Gtk.OffscreenWindow();
+            let da = new Gtk.DrawingArea();
+            win.add(da);
+            da.realize();
+
+            cr = Gdk.cairo_create(da.window);
+            expect(cr.save).toBeDefined();
+            expect(_ts(cr.getTarget())).toEqual('CairoSurface');
+        });
     });
 
     describe('solid pattern', function () {


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