cutedriver-driver 2.0.0.20210120164037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/bin/start_app_perf +200 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +52 -0
- data/config/sut_setup.rb +32 -0
- data/config/sut_teardown.rb +32 -0
- data/config/tdriver_custom_error_recovery.rb +83 -0
- data/ext/extconf.rb +70 -0
- data/ext/native_extensions.c +315 -0
- data/lib/matti.rb +25 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
- data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
- data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
- data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1945 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/generate.rb +917 -0
- data/lib/tdriver-devtools/doc/update +1 -0
- data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +2170 -0
- data/lib/tdriver-devtools/doc/xslt/update +3 -0
- data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
- data/lib/tdriver.rb +23 -0
- data/lib/tdriver/base/behaviour/abstract.rb +29 -0
- data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
- data/lib/tdriver/base/behaviour/factory.rb +495 -0
- data/lib/tdriver/base/behaviour/loader.rb +46 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +29 -0
- data/lib/tdriver/base/controller/abstraction.rb +56 -0
- data/lib/tdriver/base/controller/loader.rb +21 -0
- data/lib/tdriver/base/errors.rb +134 -0
- data/lib/tdriver/base/loader.rb +47 -0
- data/lib/tdriver/base/state_object.rb +373 -0
- data/lib/tdriver/base/sut/adapter.rb +54 -0
- data/lib/tdriver/base/sut/controller.rb +151 -0
- data/lib/tdriver/base/sut/factory.rb +339 -0
- data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
- data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +98 -0
- data/lib/tdriver/base/test_object/abstract.rb +208 -0
- data/lib/tdriver/base/test_object/adapter.rb +740 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
- data/lib/tdriver/base/test_object/cache.rb +134 -0
- data/lib/tdriver/base/test_object/factory.rb +684 -0
- data/lib/tdriver/base/test_object/loader.rb +51 -0
- data/lib/tdriver/base/test_object/verification.rb +178 -0
- data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
- data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +57 -0
- data/lib/tdriver/matti.rb +35 -0
- data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +168 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
- data/lib/tdriver/report/report.rb +61 -0
- data/lib/tdriver/report/report_api.rb +348 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
- data/lib/tdriver/report/report_creator.rb +665 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
- data/lib/tdriver/report/report_data_presentation.rb +156 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +400 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_graph_generator.rb +59 -0
- data/lib/tdriver/report/report_grouping.rb +541 -0
- data/lib/tdriver/report/report_javascript.rb +199 -0
- data/lib/tdriver/report/report_junit_xml.rb +147 -0
- data/lib/tdriver/report/report_rspec.rb +108 -0
- data/lib/tdriver/report/report_test_case_run.rb +725 -0
- data/lib/tdriver/report/report_test_run.rb +1476 -0
- data/lib/tdriver/report/report_test_unit.rb +223 -0
- data/lib/tdriver/report/report_writer.rb +1621 -0
- data/lib/tdriver/tdriver.rb +209 -0
- data/lib/tdriver/util/agent/loader.rb +22 -0
- data/lib/tdriver/util/agent/service.rb +107 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/boolean.rb +48 -0
- data/lib/tdriver/util/common/crc16.rb +149 -0
- data/lib/tdriver/util/common/environment.rb +154 -0
- data/lib/tdriver/util/common/error.rb +40 -0
- data/lib/tdriver/util/common/exception.rb +53 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +328 -0
- data/lib/tdriver/util/common/gem.rb +109 -0
- data/lib/tdriver/util/common/hash.rb +288 -0
- data/lib/tdriver/util/common/kernel.rb +253 -0
- data/lib/tdriver/util/common/loader.rb +47 -0
- data/lib/tdriver/util/common/numeric.rb +159 -0
- data/lib/tdriver/util/common/object.rb +159 -0
- data/lib/tdriver/util/common/retryable.rb +179 -0
- data/lib/tdriver/util/common/stackable.rb +185 -0
- data/lib/tdriver/util/common/string.rb +174 -0
- data/lib/tdriver/util/database/access.rb +240 -0
- data/lib/tdriver/util/database/connection.rb +44 -0
- data/lib/tdriver/util/database/error.rb +34 -0
- data/lib/tdriver/util/database/loader.rb +28 -0
- data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
- data/lib/tdriver/util/filters/loader.rb +29 -0
- data/lib/tdriver/util/fixture/loader.rb +22 -0
- data/lib/tdriver/util/fixture/service.rb +211 -0
- data/lib/tdriver/util/hooking/hooking.rb +477 -0
- data/lib/tdriver/util/keymap/keymap.rb +81 -0
- data/lib/tdriver/util/loader.rb +80 -0
- data/lib/tdriver/util/localisation/error.rb +31 -0
- data/lib/tdriver/util/localisation/loader.rb +25 -0
- data/lib/tdriver/util/localisation/localisation.rb +762 -0
- data/lib/tdriver/util/logger/loader.rb +22 -0
- data/lib/tdriver/util/logger/logger.rb +591 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +27 -0
- data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
- data/lib/tdriver/util/other/config.rb +221 -0
- data/lib/tdriver/util/parameter/error.rb +48 -0
- data/lib/tdriver/util/parameter/loader.rb +25 -0
- data/lib/tdriver/util/parameter/parameter.rb +1161 -0
- data/lib/tdriver/util/plugin/abstract.rb +61 -0
- data/lib/tdriver/util/plugin/error.rb +0 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +319 -0
- data/lib/tdriver/util/recorder/loader.rb +25 -0
- data/lib/tdriver/util/recorder/recorder.rb +72 -0
- data/lib/tdriver/util/recorder/scripter.rb +294 -0
- data/lib/tdriver/util/statistics/statistics.rb +89 -0
- data/lib/tdriver/util/user_data/error.rb +28 -0
- data/lib/tdriver/util/user_data/loader.rb +25 -0
- data/lib/tdriver/util/user_data/user_data.rb +104 -0
- data/lib/tdriver/util/video/camera.rb +67 -0
- data/lib/tdriver/util/video/camera_linux.rb +153 -0
- data/lib/tdriver/util/video/camera_windows.rb +174 -0
- data/lib/tdriver/util/video/loader.rb +31 -0
- data/lib/tdriver/util/video/video_utils.rb +139 -0
- data/lib/tdriver/util/xml/abstraction.rb +117 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/builder.rb +53 -0
- data/lib/tdriver/util/xml/comment.rb +32 -0
- data/lib/tdriver/util/xml/document.rb +32 -0
- data/lib/tdriver/util/xml/element.rb +32 -0
- data/lib/tdriver/util/xml/error.rb +46 -0
- data/lib/tdriver/util/xml/loader.rb +62 -0
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/nodeset.rb +32 -0
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
- data/lib/tdriver/util/xml/parsers/loader.rb +21 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +332 -0
- data/lib/tdriver/verify/verify.rb +2398 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +530 -0
- data/xml/defaults/generic.xml +11 -0
- data/xml/defaults/sut_generic.xml +8 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +292 -0
- metadata +324 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyUtil
|
21
|
+
|
22
|
+
module XML
|
23
|
+
|
24
|
+
class Nodeset
|
25
|
+
|
26
|
+
include Abstraction
|
27
|
+
|
28
|
+
end # Nodeset
|
29
|
+
|
30
|
+
end # XML
|
31
|
+
|
32
|
+
end # MobyUtil
|
@@ -0,0 +1,140 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
require 'libxml'
|
21
|
+
|
22
|
+
module MobyUtil
|
23
|
+
|
24
|
+
module XML
|
25
|
+
|
26
|
+
module LibXML
|
27
|
+
|
28
|
+
module Abstraction
|
29
|
+
|
30
|
+
def nil?
|
31
|
+
@xml.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
@xml.name
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
@xml.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def size
|
43
|
+
@xml.size
|
44
|
+
end
|
45
|
+
|
46
|
+
def empty?
|
47
|
+
@xml.empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def method_missing( method, *args, &block )
|
53
|
+
raise RuntimeError.new("Method '#{ method.to_s }' is not supported by #{ self.class.to_s } (#{ @parser.to_s })" )
|
54
|
+
end
|
55
|
+
|
56
|
+
# method to create MobyUtil::XML::Element object
|
57
|
+
def element_object( xml_data )
|
58
|
+
MobyUtil::XML::Element.new().extend( Element ).tap { | element | element.xml = xml_data; element.parser = @parser; }
|
59
|
+
end
|
60
|
+
|
61
|
+
# method to create MobyUtil::XML::Nodeset object
|
62
|
+
def nodeset_object( xml_data )
|
63
|
+
MobyUtil::XML::Nodeset.new().extend( Nodeset ).tap { | node | node.xml = xml_data; node.parser = @parser; }
|
64
|
+
end
|
65
|
+
|
66
|
+
end # Abstraction
|
67
|
+
|
68
|
+
module Document # behaviour
|
69
|
+
include MobyUtil::XML::LibXML::Abstraction
|
70
|
+
|
71
|
+
def parse( xml_string )
|
72
|
+
::LibXML::XML::Parser.string( xml_string ).parse
|
73
|
+
end
|
74
|
+
|
75
|
+
def xpath( xpath_query )
|
76
|
+
nodeset_object( @xml.find( xpath_query ) )
|
77
|
+
end
|
78
|
+
|
79
|
+
def root
|
80
|
+
element_object( @xml.root )
|
81
|
+
end
|
82
|
+
|
83
|
+
end # Document
|
84
|
+
|
85
|
+
module Element # behaviour
|
86
|
+
include MobyUtil::XML::LibXML::Abstraction
|
87
|
+
|
88
|
+
def inner_xml
|
89
|
+
@xml.inner_xml
|
90
|
+
end
|
91
|
+
|
92
|
+
def xpath( xpath_query )
|
93
|
+
element_object( @xml.find( xpath_query ) )
|
94
|
+
end
|
95
|
+
|
96
|
+
def first
|
97
|
+
self[0]
|
98
|
+
end
|
99
|
+
|
100
|
+
def []( value )
|
101
|
+
element_object( @xml[value] )
|
102
|
+
end
|
103
|
+
|
104
|
+
def each( &block )
|
105
|
+
@xml.each{ | element | yield( element_object( element ) ) }
|
106
|
+
end
|
107
|
+
|
108
|
+
def attribute( attr_name )
|
109
|
+
@xml.attributes[ attr_name ].nil? ? nil : @xml.attributes[ attr_name ].to_s
|
110
|
+
end
|
111
|
+
|
112
|
+
def attributes
|
113
|
+
{}.tap{ | hash | @xml.attributes.each{ | attr | hash[attr.name.to_s] = attr.value.to_s } }
|
114
|
+
end
|
115
|
+
|
116
|
+
def content
|
117
|
+
@xml.content.to_s
|
118
|
+
end
|
119
|
+
|
120
|
+
end # Element
|
121
|
+
|
122
|
+
module Nodeset # behaviour
|
123
|
+
include MobyUtil::XML::LibXML::Abstraction
|
124
|
+
|
125
|
+
def each( &block )
|
126
|
+
@xml.each{ | element | yield( element_object( element ) ) }
|
127
|
+
end
|
128
|
+
|
129
|
+
def []( node )
|
130
|
+
element_object( @xml[ node ] )
|
131
|
+
end
|
132
|
+
|
133
|
+
end # Nodeset
|
134
|
+
|
135
|
+
|
136
|
+
end # Nokogiri
|
137
|
+
|
138
|
+
end # XML
|
139
|
+
|
140
|
+
end # MobyUtil
|
@@ -0,0 +1,21 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
# nokogiri parser wrapper
|
21
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'nokogiri/loader.rb' ) )
|
@@ -0,0 +1,167 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyUtil
|
21
|
+
|
22
|
+
module XML
|
23
|
+
|
24
|
+
module Nokogiri
|
25
|
+
|
26
|
+
module Cache
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# TODO: document me
|
31
|
+
def initialize_cache
|
32
|
+
|
33
|
+
@cache = Hash.new{ | hash, key | hash[ key ] = {} }
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO: document me
|
38
|
+
def clear_cache
|
39
|
+
|
40
|
+
@cache.clear
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO: document me
|
45
|
+
def cache( key, value )
|
46
|
+
|
47
|
+
if @options[ :cache_enabled ] == true
|
48
|
+
|
49
|
+
@cache[ key ].fetch( value ){
|
50
|
+
|
51
|
+
@cache[ key ][ value ] = yield
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
else
|
56
|
+
|
57
|
+
yield
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
# TODO: document me
|
64
|
+
def no_cache( *args )
|
65
|
+
|
66
|
+
yield
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
module Abstraction
|
73
|
+
|
74
|
+
include Cache
|
75
|
+
|
76
|
+
# TODO: Documentation
|
77
|
+
def name
|
78
|
+
|
79
|
+
cache( :name, :value ){ @xml.name }
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# TODO: Documentation
|
84
|
+
def nil?
|
85
|
+
|
86
|
+
cache( :nil?, :value ){ @xml.nil? }
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
alias :empty? :nil?
|
91
|
+
|
92
|
+
# TODO: Documentation
|
93
|
+
def size
|
94
|
+
|
95
|
+
cache( :size, :value ){ @xml.size }
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
# TODO: Documentation
|
100
|
+
def to_s
|
101
|
+
|
102
|
+
cache( :to_s, :value ){ @xml.to_s }
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
# TODO: document me
|
109
|
+
def node_object( object )
|
110
|
+
|
111
|
+
case object
|
112
|
+
|
113
|
+
when ::Nokogiri::XML::Element
|
114
|
+
|
115
|
+
XML::Element.new( object, @options )
|
116
|
+
|
117
|
+
when ::Nokogiri::XML::NodeSet
|
118
|
+
|
119
|
+
XML::Nodeset.new( object, @options )
|
120
|
+
|
121
|
+
when ::Nokogiri::XML::Text
|
122
|
+
|
123
|
+
XML::Text.new( object, @options )
|
124
|
+
|
125
|
+
when ::Nokogiri::XML::Attr
|
126
|
+
|
127
|
+
XML::Attribute.new( object, @options )
|
128
|
+
|
129
|
+
when ::Nokogiri::XML::Comment
|
130
|
+
|
131
|
+
XML::Comment.new( object, @options )
|
132
|
+
|
133
|
+
when ::NilClass
|
134
|
+
|
135
|
+
#nil_node
|
136
|
+
MobyUtil::XML::NilNode.new( nil )
|
137
|
+
|
138
|
+
# do not create wrapper object if already wrapped
|
139
|
+
when ::MobyUtil::XML::Element, ::MobyUtil::XML::Nodeset, ::MobyUtil::XML::Text, ::MobyUtil::XML::Attribute, ::MobyUtil::XML::NilNode, ::MobyUtil::XML::Comment
|
140
|
+
|
141
|
+
object
|
142
|
+
|
143
|
+
else
|
144
|
+
|
145
|
+
raise NotImplementedError, "Object wrapper for #{ object.class } not implemented - Please contact TDriver support"
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
# TODO: Documentation
|
152
|
+
def method_missing( method, *args, &block )
|
153
|
+
|
154
|
+
raise RuntimeError, "Method #{ method.to_s.inspect } is not supported by #{ self.class } object (#{ MobyUtil::XML.current_parser })"
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
# enable hooking for performance measurement & debug logging
|
159
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
160
|
+
|
161
|
+
end # Abstraction
|
162
|
+
|
163
|
+
end # Nokogiri
|
164
|
+
|
165
|
+
end # XML
|
166
|
+
|
167
|
+
end # MobyUtil
|
@@ -0,0 +1,66 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyUtil
|
21
|
+
|
22
|
+
module XML
|
23
|
+
|
24
|
+
module Nokogiri
|
25
|
+
|
26
|
+
module Attribute
|
27
|
+
|
28
|
+
include Abstraction
|
29
|
+
|
30
|
+
# TODO: document me
|
31
|
+
def value
|
32
|
+
|
33
|
+
cache( :value, :value ){
|
34
|
+
|
35
|
+
@xml.value
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: document me
|
42
|
+
def value=( content )
|
43
|
+
|
44
|
+
clear_cache
|
45
|
+
|
46
|
+
@xml.value = content
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# alias for value=
|
51
|
+
alias_method :content=, :value=
|
52
|
+
|
53
|
+
# alias for value
|
54
|
+
alias_method :content, :value
|
55
|
+
|
56
|
+
# enable hooking for performance measurement & debug logging
|
57
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Nokogiri
|
62
|
+
|
63
|
+
end # XML
|
64
|
+
|
65
|
+
end # MobyUtil
|
66
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyUtil
|
21
|
+
|
22
|
+
module XML
|
23
|
+
|
24
|
+
module Nokogiri
|
25
|
+
|
26
|
+
module Builder # behaviour
|
27
|
+
|
28
|
+
def build( &block )
|
29
|
+
|
30
|
+
@xml = ::Nokogiri::XML::Builder.new( &block )
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_xml
|
35
|
+
|
36
|
+
@xml.to_xml
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# support all Nokogiri::XML::Builder class instance methods
|
41
|
+
def method_missing( method, *args )
|
42
|
+
|
43
|
+
if @xml.respond_to?( method )
|
44
|
+
|
45
|
+
@xml.send( method.to_sym, *args )
|
46
|
+
|
47
|
+
else
|
48
|
+
|
49
|
+
raise NoMethodError, "Method #{ method.to_s.inspect } is not supported by #{ self.class }"
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# enable hooking for performance measurement & debug logging
|
56
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
57
|
+
|
58
|
+
end # Document
|
59
|
+
|
60
|
+
end # Nokogiri
|
61
|
+
|
62
|
+
end # XML
|
63
|
+
|
64
|
+
end # MobyUtil
|