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
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QML::Dispatchable do
|
4
|
-
class DispatchableFoo
|
5
|
-
include QML::Dispatchable
|
6
|
-
attr_accessor :value
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#later' do
|
10
|
-
it 'queues a method call as a task to the dispatcher' do
|
11
|
-
foo = DispatchableFoo.new
|
12
|
-
foo.later.value = 'hoge'
|
13
|
-
QML.application.process_events # wait for event loop hook to be enabled
|
14
|
-
QML.application.process_events
|
15
|
-
expect(foo.value).to eq 'hoge'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
[QML::Access, QML::QtObjectBase, QML::Data::ListModel].each do |mod|
|
21
|
-
describe mod do
|
22
|
-
it 'includes Dispatchable' do
|
23
|
-
expect(mod.include?(QML::Dispatchable)).to eq true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/qml/dispatcher_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QML::Dispatcher do
|
4
|
-
|
5
|
-
let(:dispatcher) { QML::Dispatcher.instance }
|
6
|
-
|
7
|
-
describe '#empty?' do
|
8
|
-
context 'when it has no task' do
|
9
|
-
it 'returns true' do
|
10
|
-
dispatcher.run_tasks until dispatcher.empty?
|
11
|
-
expect(dispatcher.empty?).to eq true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
context 'when it has tasks' do
|
15
|
-
it 'returns false' do
|
16
|
-
dispatcher.add_task {}
|
17
|
-
expect(dispatcher.empty?).to eq false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#add_task' do
|
23
|
-
before do
|
24
|
-
dispatcher.add_task {}
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'adds a task' do
|
28
|
-
expect(dispatcher.empty?).to eq false
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sets the event loop hook enabled later' do
|
32
|
-
QML.application.process_events
|
33
|
-
expect(QML::Kernel.event_loop_hook_timer.active).to eq true
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#run_tasks' do
|
38
|
-
let(:finished) { [] }
|
39
|
-
before do
|
40
|
-
2.times.each do |i|
|
41
|
-
dispatcher.add_task do
|
42
|
-
finished[i] = true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
dispatcher.run_tasks until dispatcher.empty?
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'runs queued tasks' do
|
49
|
-
expect(finished).to eq [true, true]
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'sets the event loop hook disabled when finished later' do
|
53
|
-
QML.application.process_events
|
54
|
-
expect(QML::Kernel.event_loop_hook_timer.active).to eq false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe QML do
|
60
|
-
describe '.later' do
|
61
|
-
it 'adds a task to the dispatcher and do it later in event loop' do
|
62
|
-
finished = false
|
63
|
-
QML.later do
|
64
|
-
finished = true
|
65
|
-
end
|
66
|
-
QML.application.process_events # wait for event loop hook to be enabled
|
67
|
-
QML.application.process_events
|
68
|
-
expect(finished).to eq true
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QML::ImageProvider do
|
4
|
-
|
5
|
-
describe '#request' do
|
6
|
-
it 'is not implemented by default' do
|
7
|
-
expect { QML::ImageProvider.new.request(nil) }.to raise_error(NotImplementedError)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'with test image' do
|
12
|
-
let(:klass) do
|
13
|
-
Class.new QML::ImageProvider do
|
14
|
-
attr_reader :image
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@image = (Pathname(__FILE__) + '../../assets/test.png').binread
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def request(req)
|
22
|
-
req.finish(image)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
let(:image_provider) { klass.new }
|
27
|
-
|
28
|
-
it 'provides image to QML' do
|
29
|
-
test = QML::Plugins.test_util.create_image_provider_test
|
30
|
-
expect(test.request_and_compare(image_provider.qt_image_provider, 'test', image_provider.image)).to eq true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QML::QtObjectBase do
|
4
|
-
|
5
|
-
describe '#qml_eval' do
|
6
|
-
|
7
|
-
let(:component) do
|
8
|
-
QML::Component.new data: <<-EOS
|
9
|
-
import QtQuick 2.0
|
10
|
-
QtObject {
|
11
|
-
property string foo: 'foo'
|
12
|
-
property string bar: 'bar'
|
13
|
-
}
|
14
|
-
EOS
|
15
|
-
end
|
16
|
-
let(:object) { component.create }
|
17
|
-
let(:expression) { 'foo + bar' }
|
18
|
-
let(:result) { object.qml_eval(expression) }
|
19
|
-
|
20
|
-
it 'evaluates a JS expression in its QML scope' do
|
21
|
-
expect(result).to eq 'foobar'
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when expression is wrong' do
|
25
|
-
let(:expression) { 'hoge + piyo' }
|
26
|
-
it 'raises QML::QMLError' do
|
27
|
-
expect { result }.to raise_error(QML::QMLError)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'when object does not belong to context' do
|
32
|
-
let(:object) { QML::Plugins.test_util.createTestObject }
|
33
|
-
it 'raises QML::QMLError' do
|
34
|
-
expect { result }.to raise_error(QML::QMLError)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'ownership' do
|
40
|
-
let(:ownership_test) { QML::Plugins.test_util.create_ownership_test }
|
41
|
-
|
42
|
-
context 'when it is returned from a method' do
|
43
|
-
it 'gets ownership of the object' do
|
44
|
-
checker = -> { QML::TestUtil::ObjectLifeChecker.new(ownership_test.create_object) }.call
|
45
|
-
QML.application.collect_garbage
|
46
|
-
expect(checker.alive?).to eq false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when it is obtained from a property' do
|
51
|
-
it 'does not get ownership of the object' do
|
52
|
-
checker = -> { QML::TestUtil::ObjectLifeChecker.new(ownership_test.property_object) }.call
|
53
|
-
QML.application.collect_garbage
|
54
|
-
expect(checker.alive?).to eq true
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when it has a parent' do
|
59
|
-
it 'does not get ownership of the object' do
|
60
|
-
checker = -> { QML::TestUtil::ObjectLifeChecker.new(ownership_test.sub_object) }.call
|
61
|
-
QML.application.collect_garbage
|
62
|
-
expect(checker.alive?).to eq true
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'when it is created by component' do
|
67
|
-
let(:component) do
|
68
|
-
QML::Component.new data: <<-EOS
|
69
|
-
import QtQuick 2.0
|
70
|
-
Item {}
|
71
|
-
EOS
|
72
|
-
end
|
73
|
-
it 'gets ownership' do
|
74
|
-
checker = -> { QML::TestUtil::ObjectLifeChecker.new(component.create) }.call
|
75
|
-
QML.application.collect_garbage
|
76
|
-
expect(checker.alive?).to eq false
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#managed?' do
|
81
|
-
[true, false].each do |cond|
|
82
|
-
context "when managed = #{cond}" do
|
83
|
-
it "returns #{cond}" do
|
84
|
-
obj = ownership_test.create_object
|
85
|
-
obj.managed = cond
|
86
|
-
expect(obj.managed?).to eq cond
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'on garbage collection' do
|
93
|
-
|
94
|
-
context 'when managed' do
|
95
|
-
it 'gets destroyed' do
|
96
|
-
checker = -> {
|
97
|
-
obj = ownership_test.create_object
|
98
|
-
obj.managed = true
|
99
|
-
QML::TestUtil::ObjectLifeChecker.new(obj)
|
100
|
-
}.call
|
101
|
-
QML.application.collect_garbage
|
102
|
-
expect(checker.alive?).to eq false
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'when not managed' do
|
107
|
-
it 'does not get destroyed' do
|
108
|
-
checker = -> {
|
109
|
-
obj = ownership_test.create_object
|
110
|
-
obj.managed = false
|
111
|
-
QML::TestUtil::ObjectLifeChecker.new(obj)
|
112
|
-
}.call
|
113
|
-
QML.application.collect_garbage
|
114
|
-
expect(checker.alive?).to eq true
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,249 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QML::Reactive::Object do
|
4
|
-
|
5
|
-
include_context 'Reactive test objects'
|
6
|
-
|
7
|
-
describe '.property' do
|
8
|
-
|
9
|
-
it 'defines getter' do
|
10
|
-
expect(button.name).to eq('button')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'defines setter' do
|
14
|
-
button.name = 'hoge'
|
15
|
-
expect(button.name).to eq('hoge')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'can set property binding' do
|
19
|
-
button.name = 'poyo'
|
20
|
-
expect(button.name_double).to eq 'poyopoyo'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'defines notify signal' do
|
24
|
-
spy = QML::Reactive::SignalSpy.new(button.name_changed)
|
25
|
-
button.name = 'hoge'
|
26
|
-
expect(spy.args.last).to eq(['hoge'])
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns the name' do
|
30
|
-
result = nil
|
31
|
-
Class.new do
|
32
|
-
include QML::Reactive::Object
|
33
|
-
result = property :foo
|
34
|
-
end
|
35
|
-
expect(result).to eq :foo
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'in subclass' do
|
39
|
-
|
40
|
-
it 'defines property in subclass' do
|
41
|
-
expect(toggle_button.info).to eq('some info')
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'does not define property in superclass' do
|
45
|
-
expect(button.properties).not_to include(:info)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'overrides superclass property' do
|
49
|
-
expect(toggle_button.name).to eq('toggle button')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.alias_property' do
|
55
|
-
it 'returns the name' do
|
56
|
-
result = nil
|
57
|
-
Class.new do
|
58
|
-
include QML::Reactive::Object
|
59
|
-
property :foo
|
60
|
-
result = alias_property :bar, :foo
|
61
|
-
end
|
62
|
-
expect(result).to eq :bar
|
63
|
-
end
|
64
|
-
it 'aliases a property' do
|
65
|
-
expect(button.property(:title)).to eq button.property(:name)
|
66
|
-
expect(button.signal(:title_changed)).to eq button.signal(:name_changed)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '.signal' do
|
71
|
-
|
72
|
-
it 'defines a signal' do
|
73
|
-
spy = button.pressed.spy
|
74
|
-
button.pressed.emit([10, 22])
|
75
|
-
expect(spy.args.last).to eq([[10, 22]])
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'returns the name' do
|
79
|
-
result = nil
|
80
|
-
Class.new do
|
81
|
-
include QML::Reactive::Object
|
82
|
-
result = signal :sig, []
|
83
|
-
end
|
84
|
-
expect(result).to eq(:sig)
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'when the args parameter is not passed' do
|
88
|
-
it 'defines a variadic signal' do
|
89
|
-
spy = button.message.spy
|
90
|
-
button.message.emit(*%w{emitting some message})
|
91
|
-
expect(spy.args.last).to eq(%w{emitting some message})
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'in subclass' do
|
96
|
-
|
97
|
-
it 'defines signal in subclass' do
|
98
|
-
spy = toggle_button.toggled.spy
|
99
|
-
toggle_button.toggled.emit(true)
|
100
|
-
expect(spy.args.last).to eq([true])
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'does not define signal in superclass' do
|
104
|
-
expect(button.signals).not_to include(:toggled)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'overrides superclass signal' do
|
108
|
-
signal = toggle_button.pressed
|
109
|
-
expect(signal.arity).to eq(2)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'defines overridden signal in subclass' do
|
113
|
-
spy = toggle_button.pressed.spy
|
114
|
-
toggle_button.pressed.emit(10, 20)
|
115
|
-
expect(spy.args.last).to eq([10, 20])
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '.alias_signal' do
|
121
|
-
|
122
|
-
it 'returns the name' do
|
123
|
-
result = nil
|
124
|
-
Class.new do
|
125
|
-
include QML::Reactive::Object
|
126
|
-
signal :foo, []
|
127
|
-
result = alias_signal :bar, :foo
|
128
|
-
end
|
129
|
-
expect(result).to eq :bar
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'aliases a signal' do
|
133
|
-
expect(button.clicked).to eq button.pressed
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '.on' do
|
138
|
-
it 'adds signal handler' do
|
139
|
-
button.pressed.emit "pressed at top"
|
140
|
-
expect(button.name).to eq "pressed at top"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe '.on_changed' do
|
145
|
-
it 'add property changed signal handler' do
|
146
|
-
button.id = 2
|
147
|
-
expect(button.name).to eq "ID: 2"
|
148
|
-
end
|
149
|
-
it 'calls all connections including superclass' do
|
150
|
-
toggle_button.id = 3
|
151
|
-
expect(toggle_button.name).to eq "ID: 3"
|
152
|
-
expect(toggle_button.info).to eq "ID changed"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe '.instance_signals' do
|
157
|
-
context 'when include_super is false' do
|
158
|
-
it 'returns all signal definitions of the class' do
|
159
|
-
signals = toggle_button_class.instance_signals(false)
|
160
|
-
expect(signals).to match_array %w{pressed toggled name_changed info_changed}.map(&:to_sym)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context 'when include_super is not specified' do
|
165
|
-
it 'returns all signal definitions of the class and its superclasses' do
|
166
|
-
signals = toggle_button_class.instance_signals
|
167
|
-
expect(signals).to match_array %w{pressed message toggled name_changed id_changed info_changed name_double_changed clicked title_changed}.map(&:to_sym)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe '.instance_properties' do
|
173
|
-
context 'when include_super is false' do
|
174
|
-
it 'returns all property definitions of the class' do
|
175
|
-
properties = toggle_button_class.instance_properties(false)
|
176
|
-
expect(properties).to match_array %w{name info}.map(&:to_sym)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'when include_super is not specified' do
|
181
|
-
it 'returns all property definitions of the class and its superclasses' do
|
182
|
-
properties = toggle_button_class.instance_properties
|
183
|
-
expect(properties).to match_array %w{name id info name_double title}.map(&:to_sym)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe '.instance_signal' do
|
189
|
-
it 'returns the UnboundSignal for name' do
|
190
|
-
s = toggle_button_class.instance_signal(:pressed)
|
191
|
-
expect(s).to be_a QML::Reactive::UnboundSignal
|
192
|
-
expect(s.name).to eq :pressed
|
193
|
-
expect(s.arity).to eq 2
|
194
|
-
end
|
195
|
-
context 'when signal does not exist' do
|
196
|
-
it 'fails with NameError' do
|
197
|
-
expect { toggle_button_class.instance_signal(:non_existent) }.to raise_error(NameError)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe '.instance_property' do
|
203
|
-
it 'returns the UnboundProperty for name' do
|
204
|
-
p = toggle_button_class.instance_property(:name)
|
205
|
-
expect(p).to be_a QML::Reactive::UnboundProperty
|
206
|
-
expect(p.name).to eq :name
|
207
|
-
expect(p.initial_binding.call).to eq 'toggle button'
|
208
|
-
end
|
209
|
-
context 'when property does not exist' do
|
210
|
-
it 'fails with NameError' do
|
211
|
-
expect { toggle_button_class.instance_property(:non_existent) }.to raise_error(NameError)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
describe '#signals' do
|
217
|
-
it 'returns signal names for object' do
|
218
|
-
expect(toggle_button.signals).to match_array %w{pressed message toggled id_changed name_changed info_changed name_double_changed clicked title_changed}.map(&:to_sym)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe '#properties' do
|
223
|
-
it 'return property names for object' do
|
224
|
-
expect(toggle_button.properties).to match_array %w{name id info name_double title}.map(&:to_sym)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
describe '#signal' do
|
229
|
-
it 'returns Signal for name' do
|
230
|
-
expect(toggle_button.signal(:pressed)).to eq toggle_button.pressed
|
231
|
-
end
|
232
|
-
context 'when signal does not exist' do
|
233
|
-
it 'fails with NameError' do
|
234
|
-
expect { toggle_button.signal(:non_existent) }.to raise_error(NameError)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe '#property' do
|
240
|
-
it 'returns Property for name' do
|
241
|
-
expect(toggle_button.property(:name).value).to eq toggle_button.name
|
242
|
-
end
|
243
|
-
context 'when property does not exist' do
|
244
|
-
it 'fails with NameError' do
|
245
|
-
expect { toggle_button.property(:non_existent) }.to raise_error(NameError)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|