scarpe 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +36 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +13 -3
- data/LICENSE.txt +7 -1
- data/README.md +77 -14
- data/Rakefile +67 -0
- data/examples/Edit_box_Styles.rb +8 -0
- data/examples/Kerning.rb +7 -0
- data/examples/border.rb +11 -0
- data/examples/check.rb +2 -0
- data/examples/download_and_show_image.rb +3 -0
- data/examples/flags/finland.rb +15 -0
- data/examples/flags/italy.rb +11 -0
- data/examples/flags/mauritius.rb +14 -0
- data/examples/font_family.rb +17 -0
- data/examples/font_shorthand.rb +9 -0
- data/examples/gen.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/append.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
- data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
- data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
- data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
- data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
- data/examples/legacy/working/shoes_manual/alert_button.rb +2 -0
- data/examples/legacy/working/shoes_manual/animate.rb +7 -0
- data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
- data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
- data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
- data/examples/legacy/working/shoes_manual/download.rb +12 -0
- data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
- data/examples/legacy/working/shoes_manual/editline.rb +7 -0
- data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
- data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
- data/examples/legacy/working/shoes_manual/image.rb +5 -0
- data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/message.rb +18 -0
- data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
- data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
- data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/stack.rb +7 -0
- data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
- data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
- data/examples/legacy/working/shoes_manual/width.rb +4 -0
- data/examples/local_assets/multi_image.rb +5 -0
- data/examples/local_assets/small.png +0 -0
- data/examples/local_fonts.rb +3 -0
- data/examples/margin.rb +13 -0
- data/examples/margin_check.rb +27 -0
- data/examples/oval-with-kwargs.rb +3 -0
- data/examples/oval.rb +26 -0
- data/examples/para_font_styles.rb +17 -0
- data/examples/para_font_variant.rb +6 -0
- data/examples/para_fontweight.rb +13 -0
- data/examples/parse_xl_funnies.rb +3 -0
- data/examples/rect.rb +1 -1
- data/examples/scarpe_ext.rb +3 -0
- data/examples/shapes/star.rb +1 -3
- data/examples/spacing.rb +1 -1
- data/examples/span.rb +4 -2
- data/lacci/lacci.gemspec +2 -2
- data/lacci/lib/lacci/scarpe_cli.rb +0 -1
- data/lacci/lib/lacci/version.rb +1 -1
- data/lacci/lib/scarpe/niente/display_service.rb +5 -1
- data/lacci/lib/scarpe/niente/drawable.rb +2 -0
- data/lacci/lib/scarpe/niente/shoes_spec.rb +7 -1
- data/lacci/lib/scarpe/niente.rb +14 -2
- data/lacci/lib/shoes/app.rb +44 -50
- data/lacci/lib/shoes/constants.rb +23 -2
- data/lacci/lib/shoes/display_service.rb +43 -4
- data/lacci/lib/shoes/drawable.rb +309 -35
- data/lacci/lib/shoes/drawables/arc.rb +2 -24
- data/lacci/lib/shoes/drawables/arrow.rb +2 -22
- data/lacci/lib/shoes/drawables/border.rb +28 -0
- data/lacci/lib/shoes/drawables/button.rb +4 -20
- data/lacci/lib/shoes/drawables/check.rb +7 -3
- data/lacci/lib/shoes/drawables/document_root.rb +4 -4
- data/lacci/lib/shoes/drawables/edit_box.rb +6 -5
- data/lacci/lib/shoes/drawables/edit_line.rb +5 -4
- data/lacci/lib/shoes/drawables/flow.rb +3 -5
- data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
- data/lacci/lib/shoes/drawables/image.rb +2 -2
- data/lacci/lib/shoes/drawables/line.rb +4 -7
- data/lacci/lib/shoes/drawables/link.rb +5 -8
- data/lacci/lib/shoes/drawables/list_box.rb +8 -5
- data/lacci/lib/shoes/drawables/oval.rb +48 -0
- data/lacci/lib/shoes/drawables/para.rb +106 -18
- data/lacci/lib/shoes/drawables/progress.rb +2 -1
- data/lacci/lib/shoes/drawables/radio.rb +5 -3
- data/lacci/lib/shoes/drawables/rect.rb +5 -4
- data/lacci/lib/shoes/drawables/shape.rb +2 -1
- data/lacci/lib/shoes/drawables/slot.rb +99 -8
- data/lacci/lib/shoes/drawables/stack.rb +6 -11
- data/lacci/lib/shoes/drawables/star.rb +8 -30
- data/lacci/lib/shoes/drawables/text_drawable.rb +93 -34
- data/lacci/lib/shoes/drawables/video.rb +3 -2
- data/lacci/lib/shoes/drawables/widget.rb +8 -3
- data/lacci/lib/shoes/drawables.rb +2 -1
- data/lacci/lib/shoes/errors.rb +13 -3
- data/lacci/lib/shoes/margin_helper.rb +79 -0
- data/lacci/lib/shoes.rb +4 -3
- data/lacci/test/.gitignore +1 -0
- data/lacci/test/test_draw_context.rb +167 -0
- data/lacci/test/test_font_helper.rb +57 -0
- data/lacci/test/test_helper.rb +31 -4
- data/lacci/test/test_lacci.rb +93 -6
- data/lacci/test/test_margin_helper.rb +82 -0
- data/lacci/test/test_niente_test_infra.rb +26 -0
- data/lacci/test/test_oval.rb +82 -0
- data/lacci/test/test_parenting.rb +140 -0
- data/lacci/test/test_text_drawables.rb +23 -0
- data/lib/scarpe/assets.rb +18 -0
- data/lib/scarpe/cats_cradle.rb +57 -98
- data/lib/scarpe/shoes_spec.rb +22 -43
- data/lib/scarpe/version.rb +1 -1
- data/lib/scarpe/wv/app.rb +1 -0
- data/lib/scarpe/wv/arc.rb +0 -4
- data/lib/scarpe/wv/border.rb +15 -0
- data/lib/scarpe/wv/control_interface.rb +2 -10
- data/lib/scarpe/wv/document_root.rb +2 -2
- data/lib/scarpe/wv/drawable.rb +6 -40
- data/lib/scarpe/wv/edit_box.rb +4 -1
- data/lib/scarpe/wv/edit_line.rb +5 -2
- data/lib/scarpe/wv/image.rb +2 -5
- data/lib/scarpe/wv/link.rb +4 -2
- data/lib/scarpe/wv/oval.rb +13 -0
- data/lib/scarpe/wv/para.rb +1 -0
- data/lib/scarpe/wv/scarpe_extensions.rb +8 -0
- data/lib/scarpe/wv/shape.rb +10 -5
- data/lib/scarpe/wv/text_drawable.rb +72 -14
- data/lib/scarpe/wv/web_wrangler.rb +33 -11
- data/lib/scarpe/wv/webview_local_display.rb +6 -2
- data/lib/scarpe/wv.rb +8 -1
- data/scarpe-components/Gemfile +4 -1
- data/scarpe-components/Gemfile.lock +2 -3
- data/scarpe-components/README.md +2 -2
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
- data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +22 -0
- data/scarpe-components/lib/scarpe/components/calzini/{art_widgets.rb → art_drawables.rb} +42 -18
- data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
- data/scarpe-components/lib/scarpe/components/calzini/button.rb +6 -8
- data/scarpe-components/lib/scarpe/components/calzini/misc.rb +7 -17
- data/scarpe-components/lib/scarpe/components/calzini/para.rb +213 -11
- data/scarpe-components/lib/scarpe/components/calzini/slots.rb +14 -60
- data/scarpe-components/lib/scarpe/components/calzini.rb +88 -1
- data/scarpe-components/lib/scarpe/components/errors.rb +4 -0
- data/scarpe-components/lib/scarpe/components/html.rb +4 -1
- data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +11 -3
- data/scarpe-components/lib/scarpe/components/minitest_result.rb +41 -0
- data/scarpe-components/lib/scarpe/components/print_logger.rb +17 -2
- data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +1 -1
- data/scarpe-components/lib/scarpe/components/tiranti.rb +42 -100
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +3 -1
- data/scarpe-components/lib/scarpe/components/version.rb +1 -1
- data/scarpe-components/test/assets/big-image.png +0 -0
- data/scarpe-components/test/assets/big-stylesheet.css +497 -0
- data/scarpe-components/test/assets/little-image.png +0 -0
- data/scarpe-components/test/assets/little-stylesheet.css +1 -0
- data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +7 -7
- data/scarpe-components/test/calzini/test_calzini_button.rb +7 -5
- data/scarpe-components/test/calzini/test_calzini_misc.rb +9 -9
- data/scarpe-components/test/calzini/test_calzini_para.rb +6 -9
- data/scarpe-components/test/calzini/test_calzini_slots.rb +12 -57
- data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +83 -18
- data/scarpe-components/test/calzini/test_various.rb +133 -0
- data/scarpe-components/test/test_asset_server.rb +72 -0
- data/scarpe-components/test/test_components.rb +31 -2
- data/scarpe-components/test/test_helper.rb +0 -1
- data/scarpe-components/test/test_minitest_result.rb +7 -0
- data/scarpe-components/test/test_segmented_app_files.rb +2 -0
- data/tasks/check_html_fixtures.rb +140 -0
- data/tasks/regenerate_html_fixtures.rb +104 -0
- data/templates/class_template_with_shapes.erb +0 -11
- metadata +180 -32
- data/lacci/lib/scarpe/niente/logger.rb +0 -29
- data/lacci/lib/shoes/drawables/span.rb +0 -27
- data/lacci/lib/shoes/spacing.rb +0 -9
- data/lib/scarpe/evented_assertions.rb +0 -121
- data/lib/scarpe/wv/span.rb +0 -44
- data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +0 -65
- /data/examples/legacy/{not_checked → working}/shoes3-tests/editline/editline.rb +0 -0
data/lacci/test/test_helper.rb
CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
4
4
|
require "shoes"
|
5
5
|
|
6
6
|
require "scarpe/components/unit_test_helpers"
|
7
|
+
require "scarpe/components/minitest_result"
|
7
8
|
|
8
9
|
require "minitest/autorun"
|
9
10
|
|
@@ -35,29 +36,55 @@ class NienteTest < Minitest::Test
|
|
35
36
|
timeout: 5.0,
|
36
37
|
class_name: self.class,
|
37
38
|
method_name: self.name,
|
38
|
-
|
39
|
+
expect_process_fail: false,
|
40
|
+
expect_minitest_exception: false,
|
41
|
+
display_service: "niente",
|
42
|
+
log_level: "warn"
|
39
43
|
)
|
44
|
+
sspec_file = File.expand_path(File.join __dir__, "niente_test.json")
|
45
|
+
File.unlink sspec_file rescue nil
|
46
|
+
|
40
47
|
with_tempfiles([
|
41
48
|
#["scarpe_log_config.json", JSON.dump(log_config_for_test)],
|
42
49
|
[["shoes_spec_code", ".rb"], app_test_code],
|
43
50
|
]) do |shoes_spec_path,_|
|
44
51
|
system(
|
45
52
|
"LOCALAPPDATA=\"#{Dir.tmpdir}\" " +
|
53
|
+
"NIENTE_LOG_LEVEL=#{log_level} " +
|
46
54
|
"SHOES_SPEC_TEST=\"#{shoes_spec_path}\" " +
|
47
55
|
"SCARPE_DISPLAY_SERVICE=\"#{display_service}\" " +
|
48
|
-
"SHOES_MINITEST_EXPORT_FILE
|
56
|
+
"SHOES_MINITEST_EXPORT_FILE=#{sspec_file} " +
|
49
57
|
"SHOES_MINITEST_CLASS_NAME=\"#{class_name}\" " +
|
50
58
|
"SHOES_MINITEST_METHOD_NAME=\"#{method_name}\" " +
|
51
59
|
"ruby #{SCARPE_EXE} --dev #{test_app_location}"
|
52
60
|
)
|
53
61
|
end
|
54
62
|
|
63
|
+
if expect_process_fail
|
64
|
+
assert(false, "Expected app to fail but it succeeded!") if $?.success?
|
65
|
+
return
|
66
|
+
end
|
67
|
+
|
55
68
|
# Check if the process exited normally or crashed (segfault, failure, timeout)
|
56
69
|
unless $?.success?
|
57
|
-
assert(false, "
|
70
|
+
assert(false, "App failed with exit code: #{$?.exitstatus}")
|
58
71
|
return
|
59
72
|
end
|
60
73
|
|
61
|
-
|
74
|
+
result = Scarpe::Components::MinitestResult.new(sspec_file)
|
75
|
+
if result.error?
|
76
|
+
if expect_minitest_exception
|
77
|
+
assert_equal true, true
|
78
|
+
else
|
79
|
+
raise result.error_message
|
80
|
+
end
|
81
|
+
elsif result.fail?
|
82
|
+
assert false, result.fail_message
|
83
|
+
elsif result.skip?
|
84
|
+
skip
|
85
|
+
else
|
86
|
+
# Count out the correct number of assertions
|
87
|
+
result.assertions.times { assert true }
|
88
|
+
end
|
62
89
|
end
|
63
90
|
end
|
data/lacci/test/test_lacci.rb
CHANGED
@@ -5,14 +5,101 @@ require_relative "test_helper"
|
|
5
5
|
class TestLacci < NienteTest
|
6
6
|
def test_simple_button_click
|
7
7
|
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
Shoes.app do
|
9
|
+
@b = button "OK" do
|
10
|
+
@b.text = "Yup"
|
11
|
+
end
|
11
12
|
end
|
12
|
-
end
|
13
13
|
SHOES_APP
|
14
|
-
|
15
|
-
|
14
|
+
button().trigger_click
|
15
|
+
assert_equal "Yup", button().text
|
16
|
+
SHOES_SPEC
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_positional_default_values
|
20
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
21
|
+
Shoes.app do
|
22
|
+
star 15, 35
|
23
|
+
end
|
24
|
+
SHOES_APP
|
25
|
+
s = star()
|
26
|
+
assert_equal 10, s.points
|
27
|
+
assert_equal 50, s.inner
|
28
|
+
SHOES_SPEC
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_positional_args
|
32
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
33
|
+
Shoes.app do
|
34
|
+
star 10, 25, 8 # Leave outer and inner as default
|
35
|
+
end
|
36
|
+
SHOES_APP
|
37
|
+
s = star()
|
38
|
+
assert_equal 10, s.left
|
39
|
+
assert_equal 25, s.top
|
40
|
+
assert_equal 8, s.points
|
41
|
+
assert_equal 50, s.inner
|
42
|
+
SHOES_SPEC
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_keyword_args
|
46
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
47
|
+
Shoes.app do
|
48
|
+
star 5, 6, points: 8, inner: 30
|
49
|
+
end
|
50
|
+
SHOES_APP
|
51
|
+
s = star()
|
52
|
+
assert_equal 5, s.left
|
53
|
+
assert_equal 6, s.top
|
54
|
+
assert_equal 8, s.points
|
55
|
+
assert_equal 100, s.outer
|
56
|
+
assert_equal 30, s.inner
|
57
|
+
SHOES_SPEC
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_too_many_positional_args
|
61
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
62
|
+
Shoes.app do
|
63
|
+
@s = stack {}
|
64
|
+
end
|
65
|
+
SHOES_APP
|
66
|
+
s = stack("@s")
|
67
|
+
assert_raises Shoes::Errors::BadArgumentListError do
|
68
|
+
s.star 5, 6, 7, 8, 9, 10, 11
|
69
|
+
end
|
70
|
+
SHOES_SPEC
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_too_few_positional_args
|
74
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
75
|
+
Shoes.app do
|
76
|
+
@s = stack {}
|
77
|
+
end
|
78
|
+
SHOES_APP
|
79
|
+
s = stack("@s")
|
80
|
+
assert_raises Shoes::Errors::BadArgumentListError do
|
81
|
+
s.star 5
|
82
|
+
end
|
83
|
+
SHOES_SPEC
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_unsupported_feature
|
87
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC, expect_process_fail: true)
|
88
|
+
Shoes.app(features: :html) do
|
89
|
+
para "Not supported by Niente, though."
|
90
|
+
end
|
91
|
+
SHOES_APP
|
92
|
+
assert true
|
93
|
+
SHOES_SPEC
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_unknown_feature
|
97
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
98
|
+
Shoes.app(features: :squid) do
|
99
|
+
para "No such feature, though."
|
100
|
+
end
|
101
|
+
SHOES_APP
|
102
|
+
assert true
|
16
103
|
SHOES_SPEC
|
17
104
|
end
|
18
105
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
load "lacci/lib/shoes/margin_helper.rb"
|
4
|
+
|
5
|
+
|
6
|
+
class TestMarginHelper < Minitest::Test
|
7
|
+
include MarginHelper
|
8
|
+
|
9
|
+
def test_one_Number_margin
|
10
|
+
|
11
|
+
kwargs = {:margin => 20}
|
12
|
+
|
13
|
+
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 20, :margin_bottom => 20},margin_parse(kwargs))
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_Array_four_margin
|
18
|
+
|
19
|
+
kwargs = {:margin => [20,20,30,40]}
|
20
|
+
|
21
|
+
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 30, :margin_bottom => 40},margin_parse(kwargs))
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_Array_one_margin
|
26
|
+
|
27
|
+
kwargs = {:margin => [20]}
|
28
|
+
|
29
|
+
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 20, :margin_bottom => 20},margin_parse(kwargs))
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_String_four_margin
|
35
|
+
|
36
|
+
kwargs = {:margin => "20 30 40 50"}
|
37
|
+
|
38
|
+
assert_equal({:margin => nil, :margin_left => "20", :margin_top => "30", :margin_right => "40", :margin_bottom => "50"},margin_parse(kwargs))
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_String_one_margin
|
43
|
+
|
44
|
+
kwargs = {:margin => "20"}
|
45
|
+
|
46
|
+
assert_equal({:margin => nil, :margin_left => "20", :margin_top => "20", :margin_right => "20", :margin_bottom => "20"},margin_parse(kwargs))
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_Hash_four_margin
|
51
|
+
|
52
|
+
kwargs = {:margin => {left:20,top:20,right:30,bottom:30}}
|
53
|
+
|
54
|
+
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 30, :margin_bottom => 30},margin_parse(kwargs))
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_Hash_three_margin
|
59
|
+
|
60
|
+
kwargs = {:margin => {top:20,right:30,bottom:30}}
|
61
|
+
|
62
|
+
assert_equal({:margin => nil, :margin_top => 20, :margin_right => 30, :margin_bottom => 30},margin_parse(kwargs))
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_Hash_two_margin
|
67
|
+
|
68
|
+
kwargs = {:margin => {left:20,top:20}}
|
69
|
+
|
70
|
+
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20},margin_parse(kwargs))
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_Hash_one_margin
|
75
|
+
|
76
|
+
kwargs = {:margin => {bottom:30}}
|
77
|
+
|
78
|
+
assert_equal({:margin => nil, :margin_bottom => 30},margin_parse(kwargs))
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "test_helper"
|
4
|
+
|
5
|
+
class TestNienteTestInfra < NienteTest
|
6
|
+
def test_app_fail_in_test
|
7
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC, expect_process_fail: true)
|
8
|
+
Shoes.app do
|
9
|
+
@b = button "OK"
|
10
|
+
raise "ERROR!"
|
11
|
+
end
|
12
|
+
SHOES_APP
|
13
|
+
assert_equal true, true
|
14
|
+
SHOES_SPEC
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_app_fail_in_spec
|
18
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC, expect_minitest_exception: true)
|
19
|
+
Shoes.app do
|
20
|
+
@b = button "OK"
|
21
|
+
end
|
22
|
+
SHOES_APP
|
23
|
+
raise "ERROR!"
|
24
|
+
SHOES_SPEC
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "test_helper"
|
4
|
+
|
5
|
+
class TestLacciOval < NienteTest
|
6
|
+
# For an oval, the args go left, top, radius, height
|
7
|
+
def test_simple_oval_values
|
8
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
9
|
+
Shoes.app do
|
10
|
+
oval 5, 10, 25 # circle with radius 25 with its upper-left point at 5, 10
|
11
|
+
end
|
12
|
+
SHOES_APP
|
13
|
+
ov = oval()
|
14
|
+
assert_equal 5, ov.left
|
15
|
+
assert_equal 10, ov.top
|
16
|
+
assert_equal 25, ov.radius
|
17
|
+
assert_equal 50, ov.width
|
18
|
+
assert_equal 50, ov.height
|
19
|
+
SHOES_SPEC
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_oval_with_height
|
23
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
24
|
+
Shoes.app do
|
25
|
+
oval 5, 10, 25, 35 # oval with radius 25, 50 wide, 35 tall
|
26
|
+
end
|
27
|
+
SHOES_APP
|
28
|
+
ov = oval()
|
29
|
+
assert_equal 5, ov.left
|
30
|
+
assert_equal 10, ov.top
|
31
|
+
assert_equal 25, ov.radius
|
32
|
+
assert_equal 50, ov.width
|
33
|
+
assert_equal 35, ov.height
|
34
|
+
SHOES_SPEC
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_simple_oval_keyword_values
|
38
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
39
|
+
Shoes.app do
|
40
|
+
oval left: 5, top: 10, radius: 25
|
41
|
+
end
|
42
|
+
SHOES_APP
|
43
|
+
ov = oval()
|
44
|
+
assert_equal 5, ov.left
|
45
|
+
assert_equal 10, ov.top
|
46
|
+
assert_equal 25, ov.radius
|
47
|
+
assert_equal 50, ov.height
|
48
|
+
assert_equal 50, ov.width
|
49
|
+
SHOES_SPEC
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_oval_keywords_with_height_but_no_radius
|
53
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
54
|
+
Shoes.app do
|
55
|
+
oval left: 5, top: 10, height: 25
|
56
|
+
end
|
57
|
+
SHOES_APP
|
58
|
+
ov = oval()
|
59
|
+
assert_equal 5, ov.left
|
60
|
+
assert_equal 10, ov.top
|
61
|
+
assert_equal 12, ov.radius
|
62
|
+
assert_equal 25, ov.height
|
63
|
+
assert_equal 25, ov.width
|
64
|
+
SHOES_SPEC
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_oval_strokewidth
|
68
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
69
|
+
Shoes.app do
|
70
|
+
strokewidth 3
|
71
|
+
oval 5, 10, 25
|
72
|
+
end
|
73
|
+
SHOES_APP
|
74
|
+
ov = oval()
|
75
|
+
assert_equal 5, ov.left
|
76
|
+
assert_equal 10, ov.top
|
77
|
+
assert_equal 25, ov.radius
|
78
|
+
assert_equal 3, ov.draw_context["strokewidth"]
|
79
|
+
# assert_equal 3, ov.strokewidth # This should work but doesn't yet, see issue #476
|
80
|
+
SHOES_SPEC
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "test_helper"
|
4
|
+
|
5
|
+
class TestParenting < NienteTest
|
6
|
+
def test_simple_button
|
7
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
8
|
+
Shoes.app do
|
9
|
+
button "OK"
|
10
|
+
end
|
11
|
+
SHOES_APP
|
12
|
+
# Test that Lacci has set parents properly
|
13
|
+
doc_root = button().parent
|
14
|
+
assert_equal Shoes::DocumentRoot, doc_root.class
|
15
|
+
assert_equal [button().obj], doc_root.contents
|
16
|
+
|
17
|
+
# Test that Niente has set parents properly
|
18
|
+
assert_equal "DocumentRoot", button().display.parent.shoes_type
|
19
|
+
SHOES_SPEC
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_button_in_stack
|
23
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
24
|
+
Shoes.app do
|
25
|
+
stack do
|
26
|
+
button "OK"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
SHOES_APP
|
30
|
+
# Test that Lacci has set parents properly
|
31
|
+
assert_equal Shoes::DocumentRoot, stack().parent.class
|
32
|
+
assert_equal Shoes::Stack, button().parent.class
|
33
|
+
assert_equal [button().obj], stack().contents
|
34
|
+
|
35
|
+
# Test that Niente has set parents properly
|
36
|
+
assert_equal "DocumentRoot", stack().display.parent.shoes_type
|
37
|
+
assert_equal "Stack", button().display.parent.shoes_type
|
38
|
+
assert_equal [button().display], stack().display.children
|
39
|
+
SHOES_SPEC
|
40
|
+
end
|
41
|
+
|
42
|
+
# We had a bug with this. It wasn't setting @children properly.
|
43
|
+
def test_clear_with_no_contents
|
44
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
45
|
+
Shoes.app do
|
46
|
+
@s = stack do
|
47
|
+
end
|
48
|
+
button "Clear" do
|
49
|
+
@s.clear do
|
50
|
+
para "cleared"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
SHOES_APP
|
55
|
+
button().trigger_click
|
56
|
+
assert_equal "cleared", para.text
|
57
|
+
SHOES_SPEC
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_stack_clear
|
61
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
62
|
+
Shoes.app do
|
63
|
+
@s = stack do
|
64
|
+
@p = para "Here"
|
65
|
+
end
|
66
|
+
button "Clear" do
|
67
|
+
@s.clear
|
68
|
+
end
|
69
|
+
end
|
70
|
+
SHOES_APP
|
71
|
+
button.trigger_click
|
72
|
+
assert_equal [], stack.contents
|
73
|
+
SHOES_SPEC
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_drawable_remove
|
77
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
78
|
+
Shoes.app do
|
79
|
+
@s = stack do
|
80
|
+
@p = para "Here"
|
81
|
+
end
|
82
|
+
button "Clear" do
|
83
|
+
@p.remove
|
84
|
+
end
|
85
|
+
end
|
86
|
+
SHOES_APP
|
87
|
+
p = para # grab it while it's still there
|
88
|
+
button.trigger_click
|
89
|
+
assert_equal [], stack.contents
|
90
|
+
assert_nil p.parent
|
91
|
+
SHOES_SPEC
|
92
|
+
end
|
93
|
+
|
94
|
+
# I don't think Shoes does this. We have to use Lacci-specific methods.
|
95
|
+
# It's still good to have a test for it.
|
96
|
+
def test_drawable_reparent
|
97
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
98
|
+
Shoes.app do
|
99
|
+
@s1 = stack do
|
100
|
+
@p = para "Move me"
|
101
|
+
end
|
102
|
+
|
103
|
+
@s2 = stack do
|
104
|
+
end
|
105
|
+
|
106
|
+
button "Move It!" do
|
107
|
+
@p.set_parent(@s2)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
SHOES_APP
|
111
|
+
button.trigger_click
|
112
|
+
|
113
|
+
# Check parents in Lacci
|
114
|
+
assert_equal [], stack("@s1").contents
|
115
|
+
assert_equal stack("@s2").obj, para.parent
|
116
|
+
assert_equal [para.obj], stack("@s2").contents
|
117
|
+
|
118
|
+
# Check parents in Niente
|
119
|
+
assert_equal [], stack("@s1").display.children
|
120
|
+
assert_equal stack("@s2").display, para.display.parent
|
121
|
+
assert_equal [para.display], stack("@s2").display.children
|
122
|
+
SHOES_SPEC
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_add_to_non_current_slot
|
126
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
127
|
+
Shoes.app do
|
128
|
+
@s = stack do
|
129
|
+
end
|
130
|
+
button "Add a Button" do
|
131
|
+
@ok_button = @s.button "OK"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
SHOES_APP
|
135
|
+
button.trigger_click
|
136
|
+
assert_equal [button("@ok_button").obj], stack.contents
|
137
|
+
assert_equal stack.obj, button("@ok_button").parent
|
138
|
+
SHOES_SPEC
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "test_helper"
|
4
|
+
|
5
|
+
class TestTextDrawables < NienteTest
|
6
|
+
def test_simple_button
|
7
|
+
run_test_niente_code(<<~'SHOES_APP', app_test_code: <<~'SHOES_SPEC')
|
8
|
+
Shoes.app do
|
9
|
+
para "These are ", em("emphatically"), " ", strong("strongly"), " text drawables!"
|
10
|
+
end
|
11
|
+
SHOES_APP
|
12
|
+
assert_equal "These are emphatically strongly text drawables!", para.text
|
13
|
+
|
14
|
+
# Test that Lacci has set parents properly
|
15
|
+
assert_equal Shoes::DocumentRoot, para.parent.class
|
16
|
+
assert_equal [Shoes::Para], para.parent.contents.map(&:class)
|
17
|
+
|
18
|
+
# Test that Niente has set parents properly
|
19
|
+
assert_equal "DocumentRoot", para().display.parent.shoes_type
|
20
|
+
assert_equal ["Para"], document_root.display.children.map(&:shoes_type), "Doc root should have only para as a child!"
|
21
|
+
SHOES_SPEC
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "scarpe/components/asset_server"
|
4
|
+
|
5
|
+
module Scarpe::Webview
|
6
|
+
def self.asset_server
|
7
|
+
return @asset_server if @asset_server
|
8
|
+
|
9
|
+
@asset_server = Scarpe::Components::AssetServer.new app_dir: Shoes::App.instance.dir
|
10
|
+
|
11
|
+
# at_exit doesn't work reliably under webview. Give this a try.
|
12
|
+
::Scarpe::Webview::DisplayService.instance.control_interface.on_event(:shutdown) do
|
13
|
+
@asset_server&.kill_server
|
14
|
+
end
|
15
|
+
|
16
|
+
@asset_server
|
17
|
+
end
|
18
|
+
end
|