testability-driver 0.9.2
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.
- data/README +1 -0
- data/bin/start_app_perf +199 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +39 -0
- data/ext/extconf.rb +67 -0
- data/ext/native_extensions.c +70 -0
- data/lib/matti.rb +30 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -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 +1924 -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/behaviour/xml_generator/example/flick-example.rb +245 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -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 +892 -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 +1861 -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/flick-example.rb +233 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -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 +26 -0
- data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
- data/lib/tdriver/base/behaviour/factory.rb +380 -0
- data/lib/tdriver/base/behaviour/loader.rb +28 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +25 -0
- data/lib/tdriver/base/errors.rb +131 -0
- data/lib/tdriver/base/loader.rb +38 -0
- data/lib/tdriver/base/state_object.rb +270 -0
- data/lib/tdriver/base/sut/adapter.rb +28 -0
- data/lib/tdriver/base/sut/controller.rb +119 -0
- data/lib/tdriver/base/sut/factory.rb +287 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +67 -0
- data/lib/tdriver/base/test_object/abstract.rb +179 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
- data/lib/tdriver/base/test_object/factory.rb +618 -0
- data/lib/tdriver/base/test_object/identificator.rb +511 -0
- data/lib/tdriver/base/test_object/loader.rb +37 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +36 -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 +158 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
- data/lib/tdriver/report/report.rb +47 -0
- data/lib/tdriver/report/report_api.rb +207 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
- data/lib/tdriver/report/report_creator.rb +571 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
- data/lib/tdriver/report/report_data_presentation.rb +152 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +284 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_grouping.rb +539 -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 +621 -0
- data/lib/tdriver/report/report_test_run.rb +1286 -0
- data/lib/tdriver/report/report_test_unit.rb +175 -0
- data/lib/tdriver/report/report_writer.rb +1405 -0
- data/lib/tdriver/tdriver.rb +158 -0
- data/lib/tdriver/util/common.rb +24 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/crc16.rb +100 -0
- data/lib/tdriver/util/common/environment.rb +153 -0
- data/lib/tdriver/util/common/error.rb +39 -0
- data/lib/tdriver/util/common/file.rb +315 -0
- data/lib/tdriver/util/common/gem.rb +108 -0
- data/lib/tdriver/util/common/kernel.rb +189 -0
- data/lib/tdriver/util/common/loader.rb +39 -0
- data/lib/tdriver/util/common/retryable.rb +98 -0
- data/lib/tdriver/util/common/string.rb +77 -0
- data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
- data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
- data/lib/tdriver/util/dbaccess/error.rb +35 -0
- data/lib/tdriver/util/dbaccess/loader.rb +29 -0
- data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
- data/lib/tdriver/util/hooking.rb +434 -0
- data/lib/tdriver/util/loader.rb +65 -0
- data/lib/tdriver/util/localisation.rb +24 -0
- data/lib/tdriver/util/localisation/error.rb +32 -0
- data/lib/tdriver/util/localisation/loader.rb +28 -0
- data/lib/tdriver/util/localisation/localisation.rb +479 -0
- data/lib/tdriver/util/logger.rb +377 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +26 -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.rb +24 -0
- data/lib/tdriver/util/parameter/error.rb +45 -0
- data/lib/tdriver/util/parameter/loader.rb +37 -0
- data/lib/tdriver/util/parameter/parameter.rb +285 -0
- data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
- data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
- data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
- data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
- data/lib/tdriver/util/plugin/abstract.rb +60 -0
- data/lib/tdriver/util/plugin/error.rb +25 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +200 -0
- data/lib/tdriver/util/recorder.rb +292 -0
- data/lib/tdriver/util/stats.rb +90 -0
- data/lib/tdriver/util/user_data/error.rb +29 -0
- data/lib/tdriver/util/user_data/loader.rb +26 -0
- data/lib/tdriver/util/user_data/user_data.rb +103 -0
- data/lib/tdriver/util/video_rec.rb +264 -0
- data/lib/tdriver/util/xml/abstraction.rb +47 -0
- data/lib/tdriver/util/xml/builder.rb +54 -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 +46 -0
- data/lib/tdriver/util/xml/nil_element.rb +89 -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 +22 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
- data/lib/tdriver/util/xml/xml.rb +170 -0
- data/lib/tdriver/verify/verify.rb +687 -0
- data/lib/tdriver/verify/verify.rb_org +630 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +495 -0
- data/xml/defaults/generic.xml +97 -0
- data/xml/defaults/sut_generic.xml +36 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +227 -0
- metadata +327 -0
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
class ParameterHash < Hash
|
|
23
|
+
|
|
24
|
+
def initialize( hash = {} )
|
|
25
|
+
|
|
26
|
+
Kernel::raise ArgumentError.new( "Unexpected argument type %s, expecting Hash or ParameterHash" % [ hash.class ] ) unless [ Hash, ParameterHash ].include?( hash.class )
|
|
27
|
+
|
|
28
|
+
merge!(
|
|
29
|
+
|
|
30
|
+
hash.empty? ? hash : convert_hash( hash )
|
|
31
|
+
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def convert_hash( hash )
|
|
37
|
+
|
|
38
|
+
hash.kind_of?( ParameterHash ) ? hash : ParameterHash[ hash.collect{ | key, value | [ key, value.kind_of?( Hash ) ? convert_hash( value ) : value ] } ]
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def []( key, *default, &block )
|
|
43
|
+
|
|
44
|
+
$last_parameter = fetch( key ){
|
|
45
|
+
|
|
46
|
+
if default.empty?
|
|
47
|
+
|
|
48
|
+
Kernel::raise ParameterNotFoundError.new( "Parameter %s not found." % [ key ] ) unless block_given?
|
|
49
|
+
|
|
50
|
+
# yield with key if block given
|
|
51
|
+
result = yield( key )
|
|
52
|
+
|
|
53
|
+
else
|
|
54
|
+
Kernel::raise ArgumentError.new( "Only one default value allowed for parameter (%s)" % [ default.join(", ") ] ) unless default.size == 1
|
|
55
|
+
|
|
56
|
+
result = default[ 0 ]
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
result.kind_of?( Hash ) ? convert_hash( result ) : result
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def []=( key, value )
|
|
67
|
+
|
|
68
|
+
Kernel::raise ParameterNotFoundError.new( "Parameter key nil is not valid." ) unless key
|
|
69
|
+
|
|
70
|
+
store( key, ( value.kind_of?( Hash ) ? convert_hash( value ) : value ) )
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Merge this Hash with another, primary Hash. Any values found in the other hash will overwrite local values and any Hash values will be recursively merged.
|
|
75
|
+
def merge_with_hash!( primary_hash )
|
|
76
|
+
|
|
77
|
+
raise ArgumentError.new( "Unable to merge, the other Hash was not a Hash, it was of type \"" + primary_hash.class.to_s + "\"." ) unless primary_hash.kind_of?( Hash )
|
|
78
|
+
|
|
79
|
+
primary_hash.each_pair do | key, value |
|
|
80
|
+
|
|
81
|
+
if ( self.has_key?( key ) && self[ key ].kind_of?( Hash ) ) and primary_hash[ key ].kind_of?( Hash )
|
|
82
|
+
|
|
83
|
+
self[ key ].merge_with_hash!( value )
|
|
84
|
+
|
|
85
|
+
else
|
|
86
|
+
|
|
87
|
+
self[ key ] = value
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
self
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
98
|
+
|
|
99
|
+
end # ParameterHash
|
|
100
|
+
|
|
101
|
+
end # MobyUtil
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
class ParameterTemplates
|
|
23
|
+
|
|
24
|
+
include Singleton
|
|
25
|
+
|
|
26
|
+
def initialize
|
|
27
|
+
|
|
28
|
+
@@templates = nil
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def load_templates()
|
|
33
|
+
|
|
34
|
+
content = MobyUtil::ParameterXml.instance.merge_files( 'templates/', 'templates', '/templates/*' )
|
|
35
|
+
|
|
36
|
+
@@templates = MobyUtil::XML::parse_string( content )
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Helper method for 'get_template_from_xml' to retrieve all requested inherited parameters.
|
|
41
|
+
# === params
|
|
42
|
+
# list_of_inherited_templates:: String representation of template names, separated with ";"
|
|
43
|
+
# === returns
|
|
44
|
+
# Hash:: Hash containing parameters
|
|
45
|
+
# === raises
|
|
46
|
+
# === example
|
|
47
|
+
# result_hash = get_inherited_parameters( "template1;template2;template3" )
|
|
48
|
+
def get_inherited_parameters( list_of_inherited_templates )
|
|
49
|
+
|
|
50
|
+
result = ParameterHash.new
|
|
51
|
+
|
|
52
|
+
if list_of_inherited_templates.kind_of?( String )
|
|
53
|
+
|
|
54
|
+
list_of_inherited_templates.split( ";" ).each{ | inherits_from |
|
|
55
|
+
|
|
56
|
+
result.merge_with_hash!(
|
|
57
|
+
|
|
58
|
+
get_template_from_xml( inherits_from )
|
|
59
|
+
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
result
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def get_template_from_xml( template_name )
|
|
71
|
+
|
|
72
|
+
result = ParameterHash.new
|
|
73
|
+
|
|
74
|
+
# return empty template hash if no templates loaded
|
|
75
|
+
return result unless @@templates
|
|
76
|
+
|
|
77
|
+
begin
|
|
78
|
+
|
|
79
|
+
template_nodeset = @@templates.xpath( "/templates/template[@name='%s']" % [ template_name ] )
|
|
80
|
+
|
|
81
|
+
if template_nodeset.size > 0
|
|
82
|
+
|
|
83
|
+
template_nodeset.each{ | template_node |
|
|
84
|
+
|
|
85
|
+
# merge and overwrite inherited template parameters
|
|
86
|
+
result.merge!(
|
|
87
|
+
|
|
88
|
+
get_inherited_parameters(
|
|
89
|
+
|
|
90
|
+
template_node.attribute( 'inherits' ).to_s
|
|
91
|
+
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
).merge!(
|
|
95
|
+
|
|
96
|
+
# merge template to hash
|
|
97
|
+
MobyUtil::ParameterXml.instance.parse( template_node.to_s )
|
|
98
|
+
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
rescue Exception => exception
|
|
105
|
+
|
|
106
|
+
Kernel::raise RuntimeError.new(
|
|
107
|
+
"Error retrieving template %s from xml. Reason: %s (%s)" % [ template_name, exception.message, exception.class ]
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
result
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
117
|
+
|
|
118
|
+
end # ParameterTemplates
|
|
119
|
+
|
|
120
|
+
end # MobyUtil
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
class ParameterUserAPI
|
|
23
|
+
|
|
24
|
+
include Singleton
|
|
25
|
+
|
|
26
|
+
def []=( key, value )
|
|
27
|
+
|
|
28
|
+
MobyUtil::Parameter[ key ] = value
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def []( *args )
|
|
33
|
+
|
|
34
|
+
MobyUtil::Parameter[ *args ]
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def fetch( *args, &block )
|
|
39
|
+
|
|
40
|
+
MobyUtil::Parameter.fetch( *args, &block )
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def files
|
|
45
|
+
|
|
46
|
+
MobyUtil::Parameter.files
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def clear
|
|
51
|
+
|
|
52
|
+
MobyUtil::Parameter.instance.clear
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def load_xml( filename )
|
|
57
|
+
|
|
58
|
+
MobyUtil::Parameter.instance.load_parameters_xml( filename )
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def reset( *keys )
|
|
63
|
+
|
|
64
|
+
MobyUtil::Parameter.instance.reset_parameters
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def inspect
|
|
69
|
+
|
|
70
|
+
MobyUtil::Parameter.inspect
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def to_s
|
|
75
|
+
|
|
76
|
+
MobyUtil::Parameter.to_s
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
81
|
+
|
|
82
|
+
end # ParameterUserAPI
|
|
83
|
+
|
|
84
|
+
end # MobyUtil
|
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
class ParameterXml
|
|
23
|
+
|
|
24
|
+
include Singleton
|
|
25
|
+
|
|
26
|
+
@@initialized = false
|
|
27
|
+
|
|
28
|
+
# initialize class with default values
|
|
29
|
+
def initialize
|
|
30
|
+
|
|
31
|
+
reset
|
|
32
|
+
|
|
33
|
+
@@initialized = true
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def reset
|
|
38
|
+
|
|
39
|
+
@@sut_list = []
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# return list of configured suts
|
|
44
|
+
def sut_list
|
|
45
|
+
|
|
46
|
+
@@sut_list
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Recursive function to process xml. Requires input to be either a valid xml fragment (as string) or a xml fragment as object.
|
|
51
|
+
# Note: validity of the xml-fragment is not checked: please use appropriate methods for that
|
|
52
|
+
# === params
|
|
53
|
+
# root_element:: document or string containing xml
|
|
54
|
+
# === returns
|
|
55
|
+
# Hash:: Hash containing any attributes, parameters and id:s
|
|
56
|
+
# === raises
|
|
57
|
+
# SyntaxError:: if parameter-element does not have a name
|
|
58
|
+
# ParameterError:: if loading subfile fails, see get_xmldocument_from_file function
|
|
59
|
+
def parse( xml )
|
|
60
|
+
|
|
61
|
+
# default results
|
|
62
|
+
results = ParameterHash.new()
|
|
63
|
+
|
|
64
|
+
begin
|
|
65
|
+
# create new xml document
|
|
66
|
+
document = MobyUtil::XML::parse_string( xml )
|
|
67
|
+
|
|
68
|
+
rescue Exception => exception
|
|
69
|
+
|
|
70
|
+
Kernel::raise ParameterFileParseError.new( "Error occured while parsing XML. Reason %s (%s)" % [ exception.message, exception.class ] )
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# go through each element in xml
|
|
75
|
+
document.xpath( "/#{ document.root.name }/*" ).each{ | element |
|
|
76
|
+
|
|
77
|
+
attribute = element.attributes.to_hash
|
|
78
|
+
|
|
79
|
+
name = attribute[ "name" ].to_s
|
|
80
|
+
value = attribute[ "value" ].to_s
|
|
81
|
+
|
|
82
|
+
case element.name
|
|
83
|
+
|
|
84
|
+
when 'fixture'
|
|
85
|
+
|
|
86
|
+
plugin = attribute[ "plugin" ].to_s
|
|
87
|
+
|
|
88
|
+
Kernel::raise SyntaxError.new( "No name defined for fixture with value %s" % name ) if name.empty?
|
|
89
|
+
Kernel::raise SyntaxError.new( "No plugin defined for fixture with name %s" % name ) if plugin.empty?
|
|
90
|
+
|
|
91
|
+
value = plugin
|
|
92
|
+
|
|
93
|
+
when 'parameter'
|
|
94
|
+
|
|
95
|
+
Kernel::raise SyntaxError.new(
|
|
96
|
+
|
|
97
|
+
"No name defined for parameter with value %s" % attribute[ 'value' ]
|
|
98
|
+
|
|
99
|
+
) unless attribute[ "name" ]
|
|
100
|
+
|
|
101
|
+
else
|
|
102
|
+
|
|
103
|
+
if element.name == 'sut'
|
|
104
|
+
|
|
105
|
+
id = attribute[ 'id' ].to_s
|
|
106
|
+
|
|
107
|
+
# store sut id to array if element is type of sut
|
|
108
|
+
@@sut_list << id unless @@sut_list.include?( id )
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# get template name(s) if given
|
|
113
|
+
templates = attribute[ "template" ].to_s
|
|
114
|
+
|
|
115
|
+
# empty value by default - content will be retrieved above
|
|
116
|
+
value = ParameterHash.new()
|
|
117
|
+
|
|
118
|
+
# use template if defined
|
|
119
|
+
value = MobyUtil::ParameterTemplates.instance.get_template_from_xml( templates.to_s ) unless templates.empty?
|
|
120
|
+
|
|
121
|
+
# read xml file from given location if defined - otherwise pass content as is
|
|
122
|
+
if element.attribute( "xml_file" )
|
|
123
|
+
|
|
124
|
+
content = parse( MobyUtil::FileHelper.get_file( element.attribute( "xml_file" ).to_s ) )
|
|
125
|
+
|
|
126
|
+
else
|
|
127
|
+
|
|
128
|
+
content = parse( "<xml>#{ element.inner_xml }</xml>" )
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
value.merge_with_hash!( content )
|
|
133
|
+
|
|
134
|
+
name = ( element.attribute( "id" ) || element.name ).to_s
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# store values to parameters
|
|
139
|
+
results[ name.to_sym ] = value
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# dispose xml document
|
|
144
|
+
document = nil
|
|
145
|
+
|
|
146
|
+
# return results hash
|
|
147
|
+
results
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def load_file( filename )
|
|
152
|
+
|
|
153
|
+
filename = MobyUtil::FileHelper.expand_path( filename )
|
|
154
|
+
|
|
155
|
+
begin
|
|
156
|
+
|
|
157
|
+
file_content = MobyUtil::FileHelper.get_file( filename )
|
|
158
|
+
|
|
159
|
+
rescue EmptyFilenameError
|
|
160
|
+
|
|
161
|
+
Kernel::raise EmptyFilenameError.new( "Unable to load parameters xml file due to filename is empty or nil" )
|
|
162
|
+
|
|
163
|
+
rescue FileNotFoundError => exception
|
|
164
|
+
|
|
165
|
+
Kernel::raise exception
|
|
166
|
+
|
|
167
|
+
rescue IOError => exception
|
|
168
|
+
|
|
169
|
+
Kernel::raise IOError.new( "Error occured while loading xml file. Reason: %s (%s)" % [ exception.message, exception.class ] )
|
|
170
|
+
|
|
171
|
+
rescue => exception
|
|
172
|
+
|
|
173
|
+
Kernel::raise ParameterFileParseError.new("Error occured while parsing parameters xml file %s\nDescription: %s" % [ filename, exception.message ] )
|
|
174
|
+
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def parse_file( filename )
|
|
180
|
+
|
|
181
|
+
begin
|
|
182
|
+
|
|
183
|
+
parse(
|
|
184
|
+
|
|
185
|
+
load_file( filename )
|
|
186
|
+
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
rescue Exception => exception
|
|
190
|
+
|
|
191
|
+
Kernel::raise ParameterFileParseError.new(
|
|
192
|
+
|
|
193
|
+
"Error occured while parsing parameters xml file %s. Reason: %s (%s)" % [ filename, exception.message, exception.class ]
|
|
194
|
+
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def merge_files( path, root_element_name, xpath_to_element = '/*', &block )
|
|
202
|
+
|
|
203
|
+
@filename = ""
|
|
204
|
+
|
|
205
|
+
xml = ""
|
|
206
|
+
|
|
207
|
+
begin
|
|
208
|
+
|
|
209
|
+
# merge all xml files
|
|
210
|
+
Dir.glob( File.join( MobyUtil::FileHelper.expand_path( path ), '/*.xml' ) ).each { | filename |
|
|
211
|
+
|
|
212
|
+
@file_name = filename
|
|
213
|
+
|
|
214
|
+
content = MobyUtil::FileHelper.get_file( filename )
|
|
215
|
+
|
|
216
|
+
xml << MobyUtil::XML::parse_string( content ).root.xpath( xpath_to_element ).to_s
|
|
217
|
+
|
|
218
|
+
# pass the filename to block if one given
|
|
219
|
+
yield( filename ) if block_given?
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
xml = "<%s>%s</%s>" % [ root_element_name, xml.to_s, root_element_name ]
|
|
224
|
+
|
|
225
|
+
rescue MobyUtil::EmptyFilenameError
|
|
226
|
+
|
|
227
|
+
Kernel::raise EmptyFilenameError.new( "Unable to load xml file due to filename is empty or nil" )
|
|
228
|
+
|
|
229
|
+
rescue MobyUtil::FileNotFoundError => exception
|
|
230
|
+
|
|
231
|
+
Kernel::raise exception
|
|
232
|
+
|
|
233
|
+
rescue Exception => exception
|
|
234
|
+
|
|
235
|
+
Kernel::raise RuntimeError.new( "Error occured while parsing xml file %s. Reason: %s (%s)" % [ @filename, exception.message, exception.class ] )
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
xml
|
|
240
|
+
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
244
|
+
|
|
245
|
+
end # ParameterXml
|
|
246
|
+
|
|
247
|
+
end # MobyUtil
|