[gjs] tests: Split legacy Gtk.Widget tests out
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] tests: Split legacy Gtk.Widget tests out
- Date: Sat, 2 Sep 2017 03:54:23 +0000 (UTC)
commit e5afef17863d6b7ef83de417062f2ce4ec63f278
Author: Philip Chimento <philip chimento gmail com>
Date: Thu Aug 31 21:32:00 2017 -0700
tests: Split legacy Gtk.Widget tests out
This creates a new test file, testLegacyGtk.js, which is only run if the
GTK dependency is present.
https://bugzilla.gnome.org/show_bug.cgi?id=787113
Makefile-test.am | 6 ++-
installed-tests/js/testLegacyGObject.js | 103 -----------------------------
installed-tests/js/testLegacyGtk.js | 108 +++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+), 104 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 8cfaa32..879363c 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -252,7 +252,10 @@ jasmine_tests += installed-tests/js/testGDBus.js
endif
if ENABLE_GTK
-jasmine_tests += installed-tests/js/testGtk.js
+jasmine_tests += \
+ installed-tests/js/testGtk.js \
+ installed-tests/js/testLegacyGtk.js \
+ $(NULL)
endif
if ENABLE_CAIRO
@@ -264,6 +267,7 @@ EXTRA_DIST += \
installed-tests/js/testCairo.js \
installed-tests/js/testGtk.js \
installed-tests/js/testGDBus.js \
+ installed-tests/js/testLegacyGtk.js \
installed-tests/extra/gjs.supp \
installed-tests/extra/lsan.supp \
$(NULL)
diff --git a/installed-tests/js/testLegacyGObject.js b/installed-tests/js/testLegacyGObject.js
index 39f0150..38cd6ea 100644
--- a/installed-tests/js/testLegacyGObject.js
+++ b/installed-tests/js/testLegacyGObject.js
@@ -1,7 +1,6 @@
// -*- mode: js; indent-tabs-mode: nil -*-
imports.gi.versions.Gtk = '3.0';
-const ByteArray = imports.byteArray;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
@@ -750,108 +749,6 @@ describe('GObject interface', function () {
});
});
-const template = ' \
-<interface> \
- <template class="Gjs_MyComplexGtkSubclass" parent="GtkGrid"> \
- <property name="margin_top">10</property> \
- <property name="margin_bottom">10</property> \
- <property name="margin_start">10</property> \
- <property name="margin_end">10</property> \
- <property name="visible">True</property> \
- <child> \
- <object class="GtkLabel" id="label-child"> \
- <property name="label">Complex!</property> \
- <property name="visible">True</property> \
- </object> \
- </child> \
- <child> \
- <object class="GtkLabel" id="label-child2"> \
- <property name="label">Complex as well!</property> \
- <property name="visible">True</property> \
- </object> \
- </child> \
- <child> \
- <object class="GtkLabel" id="internal-label-child"> \
- <property name="label">Complex and internal!</property> \
- <property name="visible">True</property> \
- </object> \
- </child> \
- </template> \
-</interface>';
-
-const MyComplexGtkSubclass = new Lang.Class({
- Name: 'MyComplexGtkSubclass',
- Extends: Gtk.Grid,
- Template: ByteArray.fromString(template),
- Children: ['label-child', 'label-child2'],
- InternalChildren: ['internal-label-child'],
- CssName: 'complex-subclass',
-
- testChildrenExist: function () {
- this._internalLabel = this.get_template_child(MyComplexGtkSubclass, 'label-child');
- expect(this._internalLabel).toEqual(jasmine.anything());
-
- expect(this.label_child2).toEqual(jasmine.anything());
- expect(this._internal_label_child).toEqual(jasmine.anything());
- }
-});
-
-const MyComplexGtkSubclassFromResource = new Lang.Class({
- Name: 'MyComplexGtkSubclassFromResource',
- Extends: Gtk.Grid,
- Template: 'resource:///org/gjs/jsunit/complex.ui',
- Children: ['label-child', 'label-child2'],
- InternalChildren: ['internal-label-child'],
-
- testChildrenExist: function () {
- expect(this.label_child).toEqual(jasmine.anything());
- expect(this.label_child2).toEqual(jasmine.anything());
- expect(this._internal_label_child).toEqual(jasmine.anything());
- }
-});
-
-function validateTemplate(description, ClassName) {
- describe(description, function () {
- let win, content;
- beforeEach(function () {
- win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
- content = new ClassName();
- win.add(content);
- });
-
- it('sets up internal and public template children', function () {
- content.testChildrenExist();
- });
-
- it('sets up public template children with the correct widgets', function () {
- expect(content.label_child.get_label()).toEqual('Complex!');
- expect(content.label_child2.get_label()).toEqual('Complex as well!');
- });
-
- it('sets up internal template children with the correct widgets', function () {
- expect(content._internal_label_child.get_label())
- .toEqual('Complex and internal!');
- });
-
- afterEach(function () {
- win.destroy();
- });
- });
-}
-
-describe('Legacy Gtk overrides', function () {
- beforeAll(function () {
- Gtk.init(null);
- });
-
- validateTemplate('UI template', MyComplexGtkSubclass);
- validateTemplate('UI template from resource', MyComplexGtkSubclassFromResource);
-
- it('sets CSS names on classes', function () {
- expect(Gtk.Widget.get_css_name.call(MyComplexGtkSubclass)).toEqual('complex-subclass');
- });
-});
-
const LegacyInterface1 = new Lang.Interface({
Name: 'LegacyInterface1',
Requires: [GObject.Object],
diff --git a/installed-tests/js/testLegacyGtk.js b/installed-tests/js/testLegacyGtk.js
new file mode 100644
index 0000000..b812d29
--- /dev/null
+++ b/installed-tests/js/testLegacyGtk.js
@@ -0,0 +1,108 @@
+// -*- mode: js; indent-tabs-mode: nil -*-
+imports.gi.versions.Gtk = '3.0';
+
+const ByteArray = imports.byteArray;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const template = `
+<interface>
+ <template class="Gjs_MyComplexGtkSubclass" parent="GtkGrid">
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <property name="margin_start">10</property>
+ <property name="margin_end">10</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="label-child">
+ <property name="label">Complex!</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label-child2">
+ <property name="label">Complex as well!</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="internal-label-child">
+ <property name="label">Complex and internal!</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </template>
+</interface>`;
+
+const MyComplexGtkSubclass = new Lang.Class({
+ Name: 'MyComplexGtkSubclass',
+ Extends: Gtk.Grid,
+ Template: ByteArray.fromString(template),
+ Children: ['label-child', 'label-child2'],
+ InternalChildren: ['internal-label-child'],
+ CssName: 'complex-subclass',
+
+ testChildrenExist: function () {
+ this._internalLabel = this.get_template_child(MyComplexGtkSubclass, 'label-child');
+ expect(this._internalLabel).toEqual(jasmine.anything());
+
+ expect(this.label_child2).toEqual(jasmine.anything());
+ expect(this._internal_label_child).toEqual(jasmine.anything());
+ }
+});
+
+const MyComplexGtkSubclassFromResource = new Lang.Class({
+ Name: 'MyComplexGtkSubclassFromResource',
+ Extends: Gtk.Grid,
+ Template: 'resource:///org/gjs/jsunit/complex.ui',
+ Children: ['label-child', 'label-child2'],
+ InternalChildren: ['internal-label-child'],
+
+ testChildrenExist: function () {
+ expect(this.label_child).toEqual(jasmine.anything());
+ expect(this.label_child2).toEqual(jasmine.anything());
+ expect(this._internal_label_child).toEqual(jasmine.anything());
+ }
+});
+
+function validateTemplate(description, ClassName) {
+ describe(description, function () {
+ let win, content;
+ beforeEach(function () {
+ win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
+ content = new ClassName();
+ win.add(content);
+ });
+
+ it('sets up internal and public template children', function () {
+ content.testChildrenExist();
+ });
+
+ it('sets up public template children with the correct widgets', function () {
+ expect(content.label_child.get_label()).toEqual('Complex!');
+ expect(content.label_child2.get_label()).toEqual('Complex as well!');
+ });
+
+ it('sets up internal template children with the correct widgets', function () {
+ expect(content._internal_label_child.get_label())
+ .toEqual('Complex and internal!');
+ });
+
+ afterEach(function () {
+ win.destroy();
+ });
+ });
+}
+
+describe('Legacy Gtk overrides', function () {
+ beforeAll(function () {
+ Gtk.init(null);
+ });
+
+ validateTemplate('UI template', MyComplexGtkSubclass);
+ validateTemplate('UI template from resource', MyComplexGtkSubclassFromResource);
+
+ it('sets CSS names on classes', function () {
+ expect(Gtk.Widget.get_css_name.call(MyComplexGtkSubclass)).toEqual('complex-subclass');
+ });
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]