Skip to content

Commit a0b1e4d

Browse files
committed
test(gdscript): add GUT and an integration test
We used the latest stable GUT, but a feature we're going to need was merged today, so we'll need to update it either to master or to the next release at some point.
1 parent 206cef9 commit a0b1e4d

File tree

101 files changed

+14078
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+14078
-2
lines changed

modules/openapi-generator/src/main/resources/gdscript/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ You can copy them all (or parts) and override them as needed.
77

88
## Domain Overview
99

10-
1110
### ApiBee
1211

1312
Base class for all Api endpoints classes.
1413
Holds most of the nitty-gritty.
1514

1615

16+
### ApiConfig
17+
18+
Reusable configuration (host, port, etc.) for Apis, injected into their constructor.
19+
20+
1721
### ApiError
1822

1923
Godot does not have an `Exception` (`try / catch`) mechanism, by design.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"background_color": "262626ff",
3+
"compact_mode": false,
4+
"config_file": "res://.gutconfig.json",
5+
"dirs": [
6+
"res://test/integration"
7+
],
8+
"disable_colors": false,
9+
"double_strategy": "partial",
10+
"font_color": "ccccccff",
11+
"font_name": "CourierPrime",
12+
"font_size": 16,
13+
"gut_on_top": true,
14+
"hide_orphans": false,
15+
"ignore_pause": false,
16+
"include_subdirs": false,
17+
"inner_class": null,
18+
"junit_xml_file": "",
19+
"junit_xml_timestamp": false,
20+
"log_level": 1,
21+
"opacity": 100,
22+
"paint_after": 0.5,
23+
"panel_options": {
24+
"font_name": "CourierPrime",
25+
"font_size": 30,
26+
"hide_output_text": false,
27+
"hide_result_tree": false,
28+
"hide_settings": false,
29+
"use_colors": false
30+
},
31+
"post_run_script": "",
32+
"pre_run_script": "",
33+
"prefix": "test_",
34+
"selected": null,
35+
"should_exit": false,
36+
"should_exit_on_success": false,
37+
"should_maximize": false,
38+
"show_help": false,
39+
"suffix": ".gd",
40+
"tests": [],
41+
"unit_test_name": null
42+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[main]
2+
3+
run_all=Object(Shortcut,"resource_local_to_scene":false,"resource_name":"","events":[Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
4+
],"script":null)
5+
6+
run_current_script=Object(Shortcut,"resource_local_to_scene":false,"resource_name":"","events":[Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
7+
],"script":null)
8+
9+
run_current_inner=Object(Shortcut,"resource_local_to_scene":false,"resource_name":"","events":[Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
10+
],"script":null)
11+
12+
run_current_test=Object(Shortcut,"resource_local_to_scene":false,"resource_name":"","events":[Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
13+
],"script":null)
14+
15+
panel_button=Object(Shortcut,"resource_local_to_scene":false,"resource_name":"","events":[Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
16+
],"script":null)
17+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"background_color": null,
3+
"compact_mode": null,
4+
"dirs": [
5+
"res://test/integration"
6+
],
7+
"disable_colors": null,
8+
"double_strategy": null,
9+
"font_color": null,
10+
"font_name": null,
11+
"font_size": null,
12+
"gut_on_top": null,
13+
"hide_orphans": null,
14+
"ignore_pause": null,
15+
"include_subdirs": null,
16+
"inner_class": null,
17+
"junit_xml_file": null,
18+
"junit_xml_timestamp": null,
19+
"log_level": null,
20+
"opacity": null,
21+
"paint_after": null,
22+
"post_run_script": null,
23+
"pre_run_script": null,
24+
"prefix": null,
25+
"selected": null,
26+
"should_exit": null,
27+
"should_exit_on_success": null,
28+
"should_maximize": null,
29+
"suffix": null,
30+
"tests": null,
31+
"unit_test_name": null
32+
}

samples/client/petstore/gdscript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ See https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests
1919

2020
## Run
2121

22-
godot --headless samples/client/petstore/gdscript
22+
godot --path samples/client/petstore/gdscript -d -s addons/gut/gut_cmdln.gd
2323

2424
The command should return a zero exit code if all tests passed.
2525
You may want to add `--verbose` for more logs when debugging.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
extends Node2D
2+
# ##############################################################################
3+
# This is a wrapper around the normal and compact gui controls and serves as
4+
# the interface between gut.gd and the gui. The GutRunner creates an instance
5+
# of this and then this takes care of managing the different GUI controls.
6+
# ##############################################################################
7+
@onready var _normal_gui = $Normal
8+
@onready var _compact_gui = $Compact
9+
var gut = null :
10+
set(val):
11+
gut = val
12+
_set_gut(val)
13+
14+
15+
func _ready():
16+
_normal_gui.switch_modes.connect(use_compact_mode.bind(true))
17+
_compact_gui.switch_modes.connect(use_compact_mode.bind(false))
18+
19+
_normal_gui.set_title("GUT")
20+
_compact_gui.set_title("GUT")
21+
22+
_normal_gui.align_right()
23+
_compact_gui.to_bottom_right()
24+
25+
use_compact_mode(false)
26+
27+
if(get_parent() == get_tree().root):
28+
_test_running_setup()
29+
30+
func _test_running_setup():
31+
_normal_gui.get_textbox().text = "hello world, how are you doing?"
32+
33+
# ------------------------
34+
# Private
35+
# ------------------------
36+
func _set_gut(val):
37+
_normal_gui.set_gut(val)
38+
_compact_gui.set_gut(val)
39+
40+
val.start_run.connect(_on_gut_start_run)
41+
val.end_run.connect(_on_gut_end_run)
42+
val.start_pause_before_teardown.connect(_on_gut_pause)
43+
val.end_pause_before_teardown.connect(_on_pause_end)
44+
45+
func _set_both_titles(text):
46+
_normal_gui.set_title(text)
47+
_compact_gui.set_title(text)
48+
49+
50+
# ------------------------
51+
# Events
52+
# ------------------------
53+
func _on_gut_start_run():
54+
_set_both_titles('Running')
55+
56+
func _on_gut_end_run():
57+
_set_both_titles('Finished')
58+
59+
func _on_gut_pause():
60+
_set_both_titles('-- Paused --')
61+
62+
func _on_pause_end():
63+
_set_both_titles('Running')
64+
65+
66+
# ------------------------
67+
# Public
68+
# ------------------------
69+
func get_textbox():
70+
return _normal_gui.get_textbox()
71+
72+
73+
func set_font_size(new_size):
74+
return
75+
var rtl = _normal_gui.get_textbox()
76+
if(rtl.get('custom_fonts/normal_font') != null):
77+
rtl.get('custom_fonts/bold_italics_font').size = new_size
78+
rtl.get('custom_fonts/bold_font').size = new_size
79+
rtl.get('custom_fonts/italics_font').size = new_size
80+
rtl.get('custom_fonts/normal_font').size = new_size
81+
82+
83+
func set_font(font_name):
84+
_set_all_fonts_in_rtl(_normal_gui.get_textbox(), font_name)
85+
86+
87+
func _set_font(rtl, font_name, custom_name):
88+
if(font_name == null):
89+
rtl.add_theme_font_override(custom_name, null)
90+
else:
91+
var dyn_font = FontFile.new()
92+
dyn_font.load_dynamic_font('res://addons/gut/fonts/' + font_name + '.ttf')
93+
rtl.add_theme_font_override(custom_name, dyn_font)
94+
95+
96+
func _set_all_fonts_in_rtl(rtl, base_name):
97+
if(base_name == 'Default'):
98+
_set_font(rtl, null, 'normal_font')
99+
_set_font(rtl, null, 'bold_font')
100+
_set_font(rtl, null, 'italics_font')
101+
_set_font(rtl, null, 'bold_italics_font')
102+
else:
103+
_set_font(rtl, base_name + '-Regular', 'normal_font')
104+
_set_font(rtl, base_name + '-Bold', 'bold_font')
105+
_set_font(rtl, base_name + '-Italic', 'italics_font')
106+
_set_font(rtl, base_name + '-BoldItalic', 'bold_italics_font')
107+
108+
109+
func set_default_font_color(color):
110+
_normal_gui.get_textbox().set('custom_colors/default_color', color)
111+
112+
113+
func set_background_color(color):
114+
_normal_gui.set_bg_color(color)
115+
116+
117+
func use_compact_mode(should=true):
118+
_compact_gui.visible = should
119+
_normal_gui.visible = !should
120+
121+
122+
func set_opacity(val):
123+
_normal_gui.modulate.a = val
124+
_compact_gui.modulate.a = val
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[gd_scene load_steps=4 format=3 uid="uid://m28heqtswbuq"]
2+
3+
[ext_resource type="Script" path="res://addons/gut/GutScene.gd" id="1_b4m8y"]
4+
[ext_resource type="PackedScene" uid="uid://duxblir3vu8x7" path="res://addons/gut/gui/NormalGui.tscn" id="2_j6ywb"]
5+
[ext_resource type="PackedScene" uid="uid://cnqqdfsn80ise" path="res://addons/gut/gui/MinGui.tscn" id="3_3glw1"]
6+
7+
[node name="GutScene" type="Node2D"]
8+
script = ExtResource("1_b4m8y")
9+
10+
[node name="Normal" parent="." instance=ExtResource("2_j6ywb")]
11+
12+
[node name="Compact" parent="." instance=ExtResource("3_3glw1")]
13+
offset_left = 5.0
14+
offset_top = 273.0
15+
offset_right = 265.0
16+
offset_bottom = 403.0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
=====================
3+
4+
Copyright (c) 2018 Tom "Butch" Wesley
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
extends Window
2+
3+
@onready var rtl = $TextDisplay/RichTextLabel
4+
5+
func _get_file_as_text(path):
6+
var to_return = null
7+
var f = FileAccess.open(path, FileAccess.READ)
8+
if(f != null):
9+
to_return = f.get_as_text()
10+
else:
11+
to_return = str('ERROR: Could not open file. Error code ', FileAccess.get_open_error())
12+
return to_return
13+
14+
func _ready():
15+
rtl.clear()
16+
17+
func _on_OpenFile_pressed():
18+
$FileDialog.popup_centered()
19+
20+
func _on_FileDialog_file_selected(path):
21+
show_file(path)
22+
23+
func _on_Close_pressed():
24+
self.hide()
25+
26+
func show_file(path):
27+
var text = _get_file_as_text(path)
28+
if(text == ''):
29+
text = '<Empty File>'
30+
rtl.set_text(text)
31+
self.window_title = path
32+
33+
func show_open():
34+
self.popup_centered()
35+
$FileDialog.popup_centered()
36+
37+
func get_rich_text_label():
38+
return $TextDisplay/RichTextLabel
39+
40+
func _on_Home_pressed():
41+
rtl.scroll_to_line(0)
42+
43+
func _on_End_pressed():
44+
rtl.scroll_to_line(rtl.get_line_count() -1)
45+
46+
func _on_Copy_pressed():
47+
return
48+
# OS.clipboard = rtl.text
49+
50+
func _on_file_dialog_visibility_changed():
51+
if rtl.text.length() == 0 and not $FileDialog.visible:
52+
self.hide()

0 commit comments

Comments
 (0)