qml 0.0.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/.travis.yml +5 -9
- data/LICENSE.txt +1 -1
- data/README.md +84 -114
- data/changes.md +5 -0
- data/examples/fizzbuzz/fizzbuzz.rb +3 -4
- data/examples/todo_array/todo_array.rb +4 -4
- data/examples/todo_sequel/todo_sequel.rb +7 -7
- data/examples/twitter/twitter.rb +5 -3
- data/ext/qml/application.c +88 -0
- data/ext/qml/application.h +9 -0
- data/ext/qml/component.c +89 -0
- data/ext/qml/component.h +10 -0
- data/ext/qml/conversion.c +60 -0
- data/ext/qml/conversion.h +8 -0
- data/ext/qml/dispatcher.c +31 -0
- data/ext/qml/dispatcher.h +7 -0
- data/ext/qml/engine.c +135 -0
- data/ext/qml/engine.h +10 -0
- data/ext/qml/exporter.c +93 -0
- data/ext/qml/exporter.h +7 -0
- data/ext/qml/extconf.rb +38 -97
- data/ext/qml/interface.c +156 -0
- data/ext/qml/interface.h +11 -0
- data/ext/qml/js_array.c +47 -0
- data/ext/qml/js_array.h +7 -0
- data/ext/qml/js_function.c +109 -0
- data/ext/qml/js_function.h +7 -0
- data/ext/qml/js_object.c +284 -0
- data/ext/qml/js_object.h +19 -0
- data/ext/qml/js_wrapper.c +19 -0
- data/ext/qml/js_wrapper.h +7 -0
- data/ext/qml/lib/libqmlbind/.gitignore +38 -0
- data/ext/qml/lib/libqmlbind/.gitmodules +3 -0
- data/ext/qml/lib/libqmlbind/.travis.yml +14 -0
- data/ext/qml/lib/libqmlbind/LICENSE.txt +22 -0
- data/ext/qml/lib/libqmlbind/libqmlbind.pro +3 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind.h +14 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/application.h +18 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/component.h +21 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/engine.h +34 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/exporter.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/interface.h +16 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/iterator.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/metaobject.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/plugin.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/qmlbind_global.h +78 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/register.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/signal_emitter.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/string.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/value.h +100 -0
- data/ext/qml/lib/libqmlbind/qmlbind/qmlbind.pro +62 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_application.cpp +103 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_component.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_engine.cpp +65 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_exporter.cpp +52 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_interface.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_iterator.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_metaobject.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_plugin.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_register.cpp +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_signal_emitter.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_string.cpp +22 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_value.cpp +215 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.h +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.cpp +73 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.h +46 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.cpp +75 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.cpp +101 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.cpp +33 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.h +25 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.cpp +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.cpp +112 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.h +28 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/util.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.cpp +23 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.h +29 -0
- data/ext/qml/lib/libqmlbind/readme.md +14 -0
- data/ext/qml/lib/libqmlbind/test/api.c +1 -0
- data/ext/qml/lib/libqmlbind/test/application_test.cpp +16 -0
- data/ext/qml/lib/libqmlbind/test/component_test.cpp +57 -0
- data/ext/qml/lib/libqmlbind/test/engine_test.cpp +94 -0
- data/ext/qml/lib/libqmlbind/test/exporter_test.cpp +312 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.cpp +36 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.h +6 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/qmldir +2 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/iterator_test.cpp +37 -0
- data/ext/qml/lib/libqmlbind/test/main.cpp +11 -0
- data/ext/qml/lib/libqmlbind/test/plugin_test.cpp +41 -0
- data/ext/qml/lib/libqmlbind/test/test.pro +26 -0
- data/ext/qml/lib/libqmlbind/test/test_helper.h +20 -0
- data/ext/qml/lib/libqmlbind/test/value_test.cpp +252 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.cpp +11 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.h +21 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.json +3 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.pro +21 -0
- data/ext/qml/meta_object.c +81 -0
- data/ext/qml/meta_object.h +8 -0
- data/ext/qml/plugin_loader.c +71 -0
- data/ext/qml/plugin_loader.h +7 -0
- data/ext/qml/qml.c +95 -0
- data/ext/qml/qml.h +10 -0
- data/ext/qml/rubyqml-plugin/listmodel.cpp +102 -0
- data/ext/qml/rubyqml-plugin/listmodel.h +37 -0
- data/ext/qml/rubyqml-plugin/rubyqml-plugin.pro +19 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.cpp +25 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.h +19 -0
- data/ext/qml/signal_emitter.c +71 -0
- data/ext/qml/signal_emitter.h +9 -0
- data/lib/qml.rb +11 -10
- data/lib/qml/access.rb +64 -86
- data/lib/qml/application.rb +20 -71
- data/lib/qml/component.rb +41 -33
- data/lib/qml/core_ext.rb +1 -0
- data/lib/qml/core_ext/to_qml.rb +70 -0
- data/lib/qml/data.rb +1 -0
- data/lib/qml/data/array_model.rb +99 -101
- data/lib/qml/data/list_model.rb +107 -131
- data/lib/qml/data/list_model_access.rb +44 -0
- data/lib/qml/data/query_model.rb +45 -47
- data/lib/qml/dispatcher.rb +5 -13
- data/lib/qml/engine.rb +9 -58
- data/lib/qml/errors.rb +0 -21
- data/lib/qml/interface.rb +21 -0
- data/lib/qml/js_array.rb +8 -0
- data/lib/qml/js_object.rb +69 -0
- data/lib/qml/js_util.rb +18 -0
- data/lib/qml/plugin_loader.rb +1 -13
- data/lib/qml/plugins.rb +3 -17
- data/lib/qml/proc_access.rb +28 -0
- data/lib/qml/qt.rb +21 -3
- data/lib/qml/reactive.rb +147 -8
- data/lib/qml/signal.rb +67 -0
- data/lib/qml/version.rb +1 -1
- data/qml.gemspec +8 -2
- data/spec/qml/access_spec.rb +33 -120
- data/spec/qml/application_spec.rb +11 -24
- data/spec/qml/component_spec.rb +4 -4
- data/spec/qml/data/array_model_spec.rb +2 -2
- data/spec/qml/data/list_model_spec.rb +2 -2
- data/spec/qml/data/query_model_spec.rb +4 -4
- data/spec/qml/engine_spec.rb +23 -21
- data/spec/qml/interface_spec.rb +20 -0
- data/spec/qml/js_array_spec.rb +29 -0
- data/spec/qml/js_function_spec.rb +32 -0
- data/spec/qml/js_object_spec.rb +113 -0
- data/spec/qml/plugin_loader_spec.rb +9 -11
- data/spec/qml/qt_spec.rb +9 -0
- data/spec/qml/reactive_spec.rb +37 -0
- data/spec/qml/signal_connect_spec.rb +27 -0
- data/spec/qml/signal_spec.rb +73 -0
- data/spec/qml/to_qml_spec.rb +76 -0
- data/spec/shared/qml/access_example.rb +21 -0
- data/spec/shared/qml/data/list_model.rb +12 -13
- data/spec/spec_helper.rb +2 -3
- metadata +141 -166
- data/examples/imageprovider/imageprovider.rb +0 -57
- data/examples/imageprovider/main.qml +0 -51
- data/ext/qml/accessclass.cpp +0 -65
- data/ext/qml/accessclass.h +0 -19
- data/ext/qml/accessobject.cpp +0 -30
- data/ext/qml/accessobject.h +0 -22
- data/ext/qml/common.h +0 -18
- data/ext/qml/conversionerror.h +0 -14
- data/ext/qml/ext_accesswrapperfactory.cpp +0 -75
- data/ext/qml/ext_accesswrapperfactory.h +0 -39
- data/ext/qml/ext_anywrapper.cpp +0 -34
- data/ext/qml/ext_anywrapper.h +0 -23
- data/ext/qml/ext_kernel.cpp +0 -81
- data/ext/qml/ext_kernel.h +0 -9
- data/ext/qml/ext_metaobject.cpp +0 -399
- data/ext/qml/ext_metaobject.h +0 -60
- data/ext/qml/ext_pluginloader.cpp +0 -53
- data/ext/qml/ext_pluginloader.h +0 -30
- data/ext/qml/ext_pointer.cpp +0 -132
- data/ext/qml/ext_pointer.h +0 -41
- data/ext/qml/ext_testutil.cpp +0 -40
- data/ext/qml/ext_testutil.h +0 -9
- data/ext/qml/foreignclass.cpp +0 -72
- data/ext/qml/foreignclass.h +0 -88
- data/ext/qml/foreignmetaobject.cpp +0 -345
- data/ext/qml/foreignmetaobject.h +0 -46
- data/ext/qml/foreignobject.cpp +0 -22
- data/ext/qml/foreignobject.h +0 -21
- data/ext/qml/functioninfo.h +0 -16
- data/ext/qml/init.cpp +0 -67
- data/ext/qml/kernel.cpp +0 -39
- data/ext/qml/kernel.h +0 -32
- data/ext/qml/listmodel.cpp +0 -137
- data/ext/qml/listmodel.h +0 -45
- data/ext/qml/markable.h +0 -12
- data/ext/qml/objectdata.cpp +0 -26
- data/ext/qml/objectdata.h +0 -20
- data/ext/qml/objectgc.cpp +0 -69
- data/ext/qml/objectgc.h +0 -28
- data/ext/qml/plugins/core/applicationextension.cpp +0 -29
- data/ext/qml/plugins/core/applicationextension.h +0 -25
- data/ext/qml/plugins/core/componentextension.cpp +0 -41
- data/ext/qml/plugins/core/componentextension.h +0 -28
- data/ext/qml/plugins/core/contextextension.cpp +0 -39
- data/ext/qml/plugins/core/contextextension.h +0 -29
- data/ext/qml/plugins/core/core.pro +0 -29
- data/ext/qml/plugins/core/coreplugin.cpp +0 -87
- data/ext/qml/plugins/core/coreplugin.h +0 -49
- data/ext/qml/plugins/core/engineextension.cpp +0 -43
- data/ext/qml/plugins/core/engineextension.h +0 -31
- data/ext/qml/plugins/core/imageprovider.cpp +0 -38
- data/ext/qml/plugins/core/imageprovider.h +0 -18
- data/ext/qml/plugins/core/imagerequestpromise.cpp +0 -19
- data/ext/qml/plugins/core/imagerequestpromise.h +0 -21
- data/ext/qml/plugins/core/qmlexception.cpp +0 -11
- data/ext/qml/plugins/core/qmlexception.h +0 -17
- data/ext/qml/plugins/testutil/imageprovidertest.cpp +0 -40
- data/ext/qml/plugins/testutil/imageprovidertest.h +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.cpp +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.h +0 -24
- data/ext/qml/plugins/testutil/ownershiptest.cpp +0 -26
- data/ext/qml/plugins/testutil/ownershiptest.h +0 -30
- data/ext/qml/plugins/testutil/testobject.cpp +0 -6
- data/ext/qml/plugins/testutil/testobject.h +0 -108
- data/ext/qml/plugins/testutil/testobjectsubclass.cpp +0 -10
- data/ext/qml/plugins/testutil/testobjectsubclass.h +0 -19
- data/ext/qml/plugins/testutil/testutil.pro +0 -22
- data/ext/qml/plugins/testutil/testutilplugin.cpp +0 -55
- data/ext/qml/plugins/testutil/testutilplugin.h +0 -36
- data/ext/qml/qmltyperegisterer.cpp +0 -74
- data/ext/qml/qmltyperegisterer.h +0 -30
- data/ext/qml/rubyclass.cpp +0 -82
- data/ext/qml/rubyclass.h +0 -230
- data/ext/qml/rubyvalue.cpp +0 -656
- data/ext/qml/rubyvalue.h +0 -224
- data/ext/qml/signalforwarder.cpp +0 -64
- data/ext/qml/signalforwarder.h +0 -29
- data/ext/qml/util.cpp +0 -112
- data/ext/qml/util.h +0 -82
- data/ext/qml/valuereference.cpp +0 -50
- data/ext/qml/valuereference.h +0 -22
- data/ext/qml/weakvaluereference.cpp +0 -51
- data/ext/qml/weakvaluereference.h +0 -21
- data/lib/qml/context.rb +0 -71
- data/lib/qml/data/error.rb +0 -5
- data/lib/qml/dispatchable.rb +0 -34
- data/lib/qml/error_converter.rb +0 -16
- data/lib/qml/geometry.rb +0 -3
- data/lib/qml/geometry/point.rb +0 -5
- data/lib/qml/geometry/rectangle.rb +0 -5
- data/lib/qml/geometry/size.rb +0 -5
- data/lib/qml/image_provider.rb +0 -87
- data/lib/qml/init.rb +0 -29
- data/lib/qml/meta_object.rb +0 -20
- data/lib/qml/models.rb +0 -1
- data/lib/qml/qt_classes.rb +0 -9
- data/lib/qml/qt_object_base.rb +0 -233
- data/lib/qml/reactive/bindable.rb +0 -79
- data/lib/qml/reactive/chained_signal.rb +0 -25
- data/lib/qml/reactive/error.rb +0 -5
- data/lib/qml/reactive/object.rb +0 -293
- data/lib/qml/reactive/property.rb +0 -19
- data/lib/qml/reactive/signal.rb +0 -115
- data/lib/qml/reactive/signal_spy.rb +0 -27
- data/lib/qml/reactive/signals/map_signal.rb +0 -21
- data/lib/qml/reactive/signals/merge_signal.rb +0 -21
- data/lib/qml/reactive/signals/select_signal.rb +0 -21
- data/lib/qml/reactive/simple_property.rb +0 -17
- data/lib/qml/reactive/unbound_property.rb +0 -42
- data/lib/qml/reactive/unbound_signal.rb +0 -51
- data/lib/qml/test_util.rb +0 -1
- data/lib/qml/test_util/object_life_checker.rb +0 -17
- data/lib/qml/wrappable.rb +0 -9
- data/spec/qml/context_spec.rb +0 -43
- data/spec/qml/conversion_spec.rb +0 -60
- data/spec/qml/dispatchable_spec.rb +0 -26
- data/spec/qml/dispatcher_spec.rb +0 -71
- data/spec/qml/geometry/point_spec.rb +0 -4
- data/spec/qml/geometry/rectangle_spec.rb +0 -4
- data/spec/qml/geometry/size_spec.rb +0 -4
- data/spec/qml/image_provider_spec.rb +0 -33
- data/spec/qml/qt_object_base_spec.rb +0 -119
- data/spec/qml/reactive/object_spec.rb +0 -249
- data/spec/qml/reactive/property_spec.rb +0 -70
- data/spec/qml/reactive/signal_spec.rb +0 -191
- data/spec/qml/reactive/signal_spy_spec.rb +0 -26
- data/spec/qml/reactive/unbound_property_spec.rb +0 -40
- data/spec/qml/reactive/unbound_signal_spec.rb +0 -70
- data/spec/qml/test_object_spec.rb +0 -186
- data/spec/qml/wrappable_spec.rb +0 -10
- data/spec/shared/qml/reactive/object.rb +0 -39
@@ -3,35 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe QML::Application do
|
4
4
|
let(:application) { QML.application }
|
5
5
|
|
6
|
-
describe '.new' do
|
7
|
-
it 'fails with QML::ApplicationError' do
|
8
|
-
expect { QML::Application.new }.to raise_error(QML::ApplicationError)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
describe '.notify_error' do
|
12
|
-
let(:error) do
|
13
|
-
begin
|
14
|
-
fail "hoge"
|
15
|
-
rescue => e
|
16
|
-
e
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'prints an error to stderr' do
|
21
|
-
expect { QML::Application.notify_error(error) }
|
22
|
-
.to output(/#{error.message}/).to_stderr
|
23
|
-
end
|
24
|
-
end
|
25
6
|
describe '#engine' do
|
26
7
|
it 'returns the default engine of the application' do
|
27
8
|
expect(application.engine).to be_a(QML::Engine)
|
28
9
|
end
|
29
10
|
end
|
30
|
-
describe '#context' do
|
31
|
-
it 'returns engine.context' do
|
32
|
-
expect(application.context).to be(application.engine.context)
|
33
|
-
end
|
34
|
-
end
|
35
11
|
describe '#load_data' do
|
36
12
|
let(:data) do
|
37
13
|
<<-EOS
|
@@ -63,4 +39,15 @@ describe QML do
|
|
63
39
|
expect(QML.application).to be_a(QML::Application)
|
64
40
|
end
|
65
41
|
end
|
42
|
+
|
43
|
+
describe '.next_tick' do
|
44
|
+
it 'do a task later in event loop' do
|
45
|
+
finished = false
|
46
|
+
QML.next_tick do
|
47
|
+
finished = true
|
48
|
+
end
|
49
|
+
QML.application.process_events
|
50
|
+
expect(finished).to eq true
|
51
|
+
end
|
52
|
+
end
|
66
53
|
end
|
data/spec/qml/component_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe QML::Component do
|
|
13
13
|
}
|
14
14
|
EOS
|
15
15
|
end
|
16
|
-
let(:component) { QML::Component.new
|
16
|
+
let(:component) { QML::Component.new(data: data) }
|
17
17
|
|
18
18
|
it 'instantiates a object' do
|
19
19
|
expect(component.create.name).to eq 'foo'
|
@@ -28,7 +28,7 @@ describe QML::Component do
|
|
28
28
|
|
29
29
|
context 'with file path' do
|
30
30
|
let(:path) { QML::ROOT_PATH + 'spec/assets/testobj.qml' }
|
31
|
-
let(:component) { QML::Component.new
|
31
|
+
let(:component) { QML::Component.new(path: path) }
|
32
32
|
|
33
33
|
it 'instantiates a object' do
|
34
34
|
expect(component.create.name).to eq 'foo'
|
@@ -44,8 +44,8 @@ describe QML::Component do
|
|
44
44
|
|
45
45
|
describe '#initialize' do
|
46
46
|
context 'when neither string nor path specified' do
|
47
|
-
it 'fails with
|
48
|
-
expect { QML::Component.new
|
47
|
+
it 'fails with TypeError' do
|
48
|
+
expect { QML::Component.new }.to raise_error(TypeError)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe QML::
|
3
|
+
describe QML::QueryModel do
|
4
4
|
|
5
5
|
let(:klass) do
|
6
|
-
Class.new(QML::
|
6
|
+
Class.new(QML::QueryModel) do
|
7
7
|
attr_accessor :data
|
8
8
|
|
9
9
|
def initialize(count)
|
@@ -45,13 +45,13 @@ describe QML::Data::QueryModel do
|
|
45
45
|
|
46
46
|
describe '#query_count' do
|
47
47
|
it 'fails with NotImplementedError by default' do
|
48
|
-
expect { QML::
|
48
|
+
expect { QML::QueryModel.allocate.query_count }.to raise_error(NotImplementedError)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#query' do
|
53
53
|
it 'fails with NotImplementedError by default' do
|
54
|
-
expect { QML::
|
54
|
+
expect { QML::QueryModel.allocate.query(0, 100) }.to raise_error(NotImplementedError)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/spec/qml/engine_spec.rb
CHANGED
@@ -1,26 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QML::Engine do
|
4
|
-
describe '.new' do
|
5
|
-
it 'fails with QML::EngineError' do
|
6
|
-
expect { QML::Engine.new }.to raise_error(QML::EngineError)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#import_paths' do
|
11
|
-
it 'returns array' do
|
12
|
-
expect(QML.engine.import_paths()).to be_a(Array)
|
13
|
-
end
|
14
|
-
end
|
15
4
|
|
16
5
|
describe '#add_import_path' do
|
17
6
|
context 'with test module' do
|
18
|
-
let(:path) {
|
7
|
+
let(:path) { QML::ROOT_PATH + 'spec/assets' }
|
19
8
|
|
20
|
-
|
9
|
+
before do
|
21
10
|
QML.engine.add_import_path(path)
|
22
|
-
paths = QML.engine.import_paths()
|
23
|
-
expect(paths[0]).to eq path
|
24
11
|
end
|
25
12
|
|
26
13
|
let(:data) do
|
@@ -30,19 +17,34 @@ describe QML::Engine do
|
|
30
17
|
Test {}
|
31
18
|
EOS
|
32
19
|
end
|
33
|
-
let(:component) { QML::Component.new
|
20
|
+
let(:component) { QML::Component.new(data: data) }
|
34
21
|
|
35
22
|
it 'loads a module' do
|
36
23
|
expect(component.create.name).to eq 'poyo'
|
37
24
|
end
|
38
25
|
end
|
39
26
|
end
|
40
|
-
end
|
41
27
|
|
42
|
-
describe
|
43
|
-
|
44
|
-
|
45
|
-
|
28
|
+
describe '#evaluate' do
|
29
|
+
it 'evaluates JS scripts' do
|
30
|
+
result = QML.engine.evaluate <<-JS
|
31
|
+
(function() {
|
32
|
+
return "foo";
|
33
|
+
})();
|
34
|
+
JS
|
35
|
+
expect(result).to eq('foo')
|
36
|
+
end
|
37
|
+
context 'with error' do
|
38
|
+
it 'fails with QMLError' do
|
39
|
+
block = proc do
|
40
|
+
QML.engine.evaluate <<-JS
|
41
|
+
(function() {
|
42
|
+
throw new Error("hoge");
|
43
|
+
})();
|
44
|
+
JS
|
45
|
+
end
|
46
|
+
expect(&block).to raise_error(/hoge/)
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QML::Interface do
|
4
|
+
|
5
|
+
describe '.notify_error' do
|
6
|
+
let(:error) do
|
7
|
+
begin
|
8
|
+
fail "hoge"
|
9
|
+
rescue => e
|
10
|
+
e
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'prints an error to stderr' do
|
15
|
+
expect { QML::Interface.notify_error(error) }
|
16
|
+
.to output(/#{error.message}/).to_stderr
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QML::JSArray do
|
4
|
+
|
5
|
+
let(:array_script) do
|
6
|
+
<<-JS
|
7
|
+
[1, 2, 3]
|
8
|
+
JS
|
9
|
+
end
|
10
|
+
let(:array) { QML.engine.evaluate(array_script) }
|
11
|
+
|
12
|
+
describe '#each' do
|
13
|
+
it 'enumerates each values' do
|
14
|
+
expect(array.each.to_a).to eq [1,2,3]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#to_a' do
|
19
|
+
it 'converts it to an array' do
|
20
|
+
expect(array.to_a).to eq [1,2,3]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#length' do
|
25
|
+
it 'returns length' do
|
26
|
+
expect(array.length).to eq 3
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QML::JSFunction do
|
4
|
+
|
5
|
+
let(:function) do
|
6
|
+
QML.engine.evaluate <<-JS
|
7
|
+
(function(a, b) {
|
8
|
+
return a + b;
|
9
|
+
});
|
10
|
+
JS
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:constructor) do
|
14
|
+
QML.engine.evaluate <<-JS
|
15
|
+
(function(a, b) {
|
16
|
+
this.value = a + b;
|
17
|
+
});
|
18
|
+
JS
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#call' do
|
22
|
+
it 'calls function' do
|
23
|
+
expect(function.call(1,2)).to eq 3
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#new' do
|
28
|
+
it 'calls function as a constructor' do
|
29
|
+
expect(constructor.new(1, 2).value).to eq 3
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QML::JSObject do
|
4
|
+
|
5
|
+
let(:obj_script) do
|
6
|
+
<<-JS
|
7
|
+
({one: 1, two: 2})
|
8
|
+
JS
|
9
|
+
end
|
10
|
+
let(:obj) { QML.engine.evaluate(obj_script) }
|
11
|
+
|
12
|
+
describe '#[]' do
|
13
|
+
it 'get property' do
|
14
|
+
expect(obj['one']).to eq(1)
|
15
|
+
expect(obj['two']).to eq(2)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#each' do
|
20
|
+
it 'enumerates each item' do
|
21
|
+
expect(obj.each.to_a).to eq [["one", 1], ["two", 2]]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#each_pair' do
|
26
|
+
it 'enumerates each item' do
|
27
|
+
expect(obj.each_pair.to_a).to eq [["one", 1], ["two", 2]]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#to_hash' do
|
32
|
+
it 'converts it to a Hash' do
|
33
|
+
expect(obj.to_hash).to eq({"one" => 1, "two" => 2})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#keys' do
|
38
|
+
it 'returns all keys' do
|
39
|
+
expect(obj.keys).to eq %w{one two}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#values' do
|
44
|
+
it 'returns all values' do
|
45
|
+
expect(obj.values).to eq [1, 2]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#has_key?' do
|
50
|
+
it 'returns whether it has the key' do
|
51
|
+
expect(obj.has_key?(:one)).to eq true
|
52
|
+
expect(obj.has_key?(:hoge)).to eq false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#respond_to?' do
|
57
|
+
it 'returns whether it has the key method' do
|
58
|
+
expect(obj.respond_to?(:one)).to eq true
|
59
|
+
expect(obj.respond_to?(:hoge)).to eq false
|
60
|
+
expect(obj.respond_to?(:respond_to?)).to eq true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#==' do
|
65
|
+
let(:obj_script) do
|
66
|
+
<<-JS
|
67
|
+
({
|
68
|
+
obj: {}
|
69
|
+
})
|
70
|
+
JS
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns identity' do
|
74
|
+
expect(obj.obj).to eq(obj.obj)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'method call' do
|
79
|
+
|
80
|
+
let(:obj_script) do
|
81
|
+
<<-JS
|
82
|
+
({
|
83
|
+
one: 1,
|
84
|
+
addOne: function(x) {
|
85
|
+
return x + this.one;
|
86
|
+
}
|
87
|
+
})
|
88
|
+
JS
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'for non-function property' do
|
92
|
+
it 'get it' do
|
93
|
+
expect(obj.one).to eq 1
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context 'for function' do
|
97
|
+
it 'call it as method' do
|
98
|
+
expect(obj.addOne(2)).to eq 3
|
99
|
+
end
|
100
|
+
end
|
101
|
+
context 'for non-existing key' do
|
102
|
+
it 'fails with NoMethodError' do
|
103
|
+
expect { obj.hoge }.to raise_error(NoMethodError)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
context 'as setter' do
|
107
|
+
it 'assigns value' do
|
108
|
+
obj.one = 2
|
109
|
+
expect(obj.one).to eq 2
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -2,31 +2,29 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe QML::PluginLoader do
|
4
4
|
|
5
|
-
let(:loader) { QML::PluginLoader.new path, 'rubyqml-
|
5
|
+
let(:loader) { QML::PluginLoader.new path, 'rubyqml-plugin' }
|
6
6
|
|
7
|
-
describe '
|
7
|
+
describe '#instance' do
|
8
8
|
|
9
9
|
context 'with signle path' do
|
10
|
-
let(:path) { QML::ROOT_PATH + 'ext/qml/
|
10
|
+
let(:path) { QML::ROOT_PATH + 'ext/qml/rubyqml-plugin' + QML::PluginLoader.lib_filename('rubyqml-plugin') }
|
11
11
|
let(:loader) { QML::PluginLoader.new path }
|
12
|
-
it '
|
13
|
-
loader.
|
14
|
-
expect(loader.instance).to be_a QML::QtObjectBase
|
12
|
+
it 'returns an object instance' do
|
13
|
+
expect(loader.instance).to respond_to('createListModel')
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
17
|
context 'with correct file path' do
|
19
|
-
let(:path) { QML::ROOT_PATH + 'ext/qml/
|
20
|
-
it '
|
21
|
-
loader.
|
22
|
-
expect(loader.instance).to be_a QML::QtObjectBase
|
18
|
+
let(:path) { QML::ROOT_PATH + 'ext/qml/rubyqml-plugin' }
|
19
|
+
it 'returns an object instance' do
|
20
|
+
expect(loader.instance).to respond_to('createListModel')
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
24
|
context 'with wrong file path' do
|
27
25
|
let(:path) { QML::ROOT_PATH + 'ext/qml/plugins/wrong' }
|
28
26
|
it 'fails with QML::PluginError' do
|
29
|
-
expect { loader.
|
27
|
+
expect { loader.instance }.to raise_error(QML::PluginError)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|