Skip to content

Commit

Permalink
merged in maximzie option
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwes committed Jul 8, 2018
2 parents 531f522 + 9feb547 commit 99c12e3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gutconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"dirs":["res://test/unit/", "res://test/integration/"],
"should_maximize":false,
"should_exit":true,
"ignore_pause":true,
"log": 2,
"opacity":100
Expand Down
22 changes: 21 additions & 1 deletion addons/gut/gut.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extends "res://addons/gut/gut_gui.gd"
# ###########################
# Editor Variables
# ###########################
export var _should_maximize = false setget set_should_maximize, get_should_maximize
export var _run_on_load = false
export(String) var _select_script = null
export(String) var _tests_like = null
Expand Down Expand Up @@ -155,7 +156,7 @@ func _ready():
set_it_up()
set_process_input(true)
_connect_controls()
set_position(get_position() + Vector2(0, 20))
set_position(get_position() + title_offset)

add_child(_wait_timer)
_wait_timer.set_wait_time(1)
Expand Down Expand Up @@ -190,6 +191,10 @@ func _ready():

if(_run_on_load):
test_scripts(_select_script == null)

if(_should_maximize):
maximize()

show()

#####################
Expand Down Expand Up @@ -701,6 +706,21 @@ func select_script(script_name):
# MISC
#
################
# ------------------------------------------------------------------------------
# Maximize test runner window to fit the viewport.
# ------------------------------------------------------------------------------
func set_should_maximize(should):
_should_maximize = should

func get_should_maximize():
return _should_maximize

func maximize():
if(is_inside_tree()):
set_position(title_offset)
var vp_size_offset = get_viewport().size - title_offset
set_size(vp_size_offset)

func disable_strict_datatype_checks(should):
_disable_strict_datatype_checks = should

Expand Down
8 changes: 8 additions & 0 deletions addons/gut/gut_cmdln.gd
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ var _opts = []
# that I don't make any dumb typos and get the neat code-sense when I
# type a dot.
var options = {
should_maximize = false,
should_exit = false,
log_level = 1,
ignore_pause_before_teardown = false,
Expand Down Expand Up @@ -328,6 +329,7 @@ func setup_options():
opts.add('-gdir', [], 'Comma delimited list of directories to add tests from.')
opts.add('-gprefix', 'test_', 'Prefix used to find tests when specifying -gdir. Default "[default]"')
opts.add('-gsuffix', '.gd', 'Suffix used to find tests when specifying -gdir. Default "[default]"')
opts.add('-gmaximize', false, 'Maximizes test runner window to fit the viewport.')
opts.add('-gexit', false, 'Exit after running tests. If not specified you have to manually close the window.')
opts.add('-glog', 1, 'Log level. Default [default]')
opts.add('-gignore_pause', false, 'Ignores any calls to gut.pause_before_teardown.')
Expand All @@ -348,10 +350,12 @@ func setup_options():

# Parses options, applying them to the _tester or setting values
# in the options struct.

func extract_command_line_options(from, to):
to.tests = from.get_value('-gtest')
to.dirs = from.get_value('-gdir')
to.should_exit = from.get_value('-gexit')
to.should_maximize = from.get_value('-gmaximize')
to.log_level = from.get_value('-glog')
to.ignore_pause_before_teardown = from.get_value('-gignore_pause')
to.selected = from.get_value('-gselect')
Expand Down Expand Up @@ -392,6 +396,7 @@ func load_options_from_config_file(file_path, into):
return -1

into.dirs = get_value(results.result, 'dirs', [])
into.should_maximize = get_value(results.result, 'should_maximize', false)
into.should_exit = get_value(results.result, 'should_exit', false)
into.ignore_pause_before_teardown = get_value(results.result, 'ignore_pause', false)
into.log_level = get_value(results.result, 'log', 1)
Expand All @@ -409,6 +414,9 @@ func apply_options(opts):
_tester.set_modulate(Color(1.0, 1.0, 1.0, min(1.0, float(opts.opacity) / 100)))
_tester.show()

if(options.should_maximize):
_tester.maximize()

if(opts.inner_class != ''):
_tester.set_inner_class_name(opts.inner_class)
_tester.set_log_level(opts.log_level)
Expand Down
1 change: 1 addition & 0 deletions addons/gut/gut_gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var _summary = {

var _is_running = false
var min_size = Vector2(650, 400)
var title_offset = Vector2(0, get_constant("title_height"))

# controls
var _ctrls = {
Expand Down
6 changes: 1 addition & 5 deletions scenes/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
[ext_resource path="res://addons/gut/icon.png" type="Texture" id=3]

[node name="main" type="Node2D" index="0"]

script = ExtResource( 1 )
__meta__ = {
"__editor_plugin_screen__": "Script"
}

[node name="Gut" type="WindowDialog" parent="." index="0"]

visible = false
anchor_left = 0.0
anchor_top = 0.0
Expand All @@ -33,6 +31,7 @@ script = ExtResource( 2 )
__meta__ = {
"_editor_icon": ExtResource( 3 )
}
_should_maximize = false
_run_on_load = false
_select_script = null
_tests_like = null
Expand All @@ -54,7 +53,6 @@ _directory5 = ""
_directory6 = ""

[node name="RunGutTestsButton" type="Button" parent="." index="1"]

anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
Expand All @@ -79,5 +77,3 @@ flat = false
align = 1

[connection signal="pressed" from="RunGutTestsButton" to="." method="_on_RunGutTestsButton_pressed"]


1 change: 1 addition & 0 deletions templates/.gutconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dirs":["res://test/unit/", "res://test/integration/"],
"should_maximize":false,
"should_exit":true,
"ignore_pause":true,
"log": 2,
Expand Down

0 comments on commit 99c12e3

Please sign in to comment.