[gjs: 2/5] testGObject: Verify that GType name is computed for registered classes
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/5] testGObject: Verify that GType name is computed for registered classes
- Date: Thu, 24 Oct 2019 05:22:40 +0000 (UTC)
commit ccfb970bf9108a952d9dec6aa698af906d22d4bf
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sun Sep 1 09:08:17 2019 +0200
testGObject: Verify that GType name is computed for registered classes
installed-tests/js/testGObjectClass.js | 54 ++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
---
diff --git a/installed-tests/js/testGObjectClass.js b/installed-tests/js/testGObjectClass.js
index 77c6f3ab..f4bfafa7 100644
--- a/installed-tests/js/testGObjectClass.js
+++ b/installed-tests/js/testGObjectClass.js
@@ -469,3 +469,57 @@ describe('GObject creation using base classes without registered GType', functio
.toThrowError(/Object 0x[a-f0-9]+ is not a subclass of GObject_Object, it's a Object/);
});
});
+
+describe('Register GType name', function () {
+ beforeAll(function () {
+ expect(GObject.gtypeNameBasedOnJSPath).toBeFalsy();
+ });
+
+ afterEach(function () {
+ GObject.gtypeNameBasedOnJSPath = false;
+ });
+
+ it('uses the class name', function () {
+ const GTypeTestAutoName = GObject.registerClass(
+ class GTypeTestAutoName extends GObject.Object { });
+
+ expect(GTypeTestAutoName.$gtype.name).toEqual(
+ 'Gjs_GTypeTestAutoName');
+ });
+
+ it('uses the sanitized class name', function () {
+ const GTypeTestAutoName = GObject.registerClass(
+ class GTypeTestAutoCla$$Name extends GObject.Object { });
+
+ expect(GTypeTestAutoName.$gtype.name).toEqual(
+ 'Gjs_GTypeTestAutoCla__Name');
+ });
+
+ it('use the file path and class name', function () {
+ GObject.gtypeNameBasedOnJSPath = true;
+ const GTypeTestAutoName = GObject.registerClass(
+ class GTypeTestAutoName extends GObject.Object {});
+
+ /* Update this test if the file is moved */
+ expect(GTypeTestAutoName.$gtype.name).toEqual(
+ 'Gjs_js_testGObjectClass_GTypeTestAutoName');
+ });
+
+ it('use the file path and sanitized class name', function () {
+ GObject.gtypeNameBasedOnJSPath = true;
+ const GTypeTestAutoName = GObject.registerClass(
+ class GTypeTestAutoCla$$Name extends GObject.Object { });
+
+ /* Update this test if the file is moved */
+ expect(GTypeTestAutoName.$gtype.name).toEqual(
+ 'Gjs_js_testGObjectClass_GTypeTestAutoCla__Name');
+ });
+
+ it('use provided class name', function () {
+ const GtypeClass = GObject.registerClass({
+ GTypeName: 'GTypeTestManualName',
+ }, class extends GObject.Object {});
+
+ expect(GtypeClass.$gtype.name).toEqual('GTypeTestManualName');
+ });
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]