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,144 @@
|
|
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 MobyBehaviour
|
21
|
+
|
22
|
+
# == description
|
23
|
+
# TDriver synchronization functionality. These methods make it possible to wait until the SUT is in some user defined state
|
24
|
+
#
|
25
|
+
# == behaviour
|
26
|
+
# GenericTestObjectSynchronization
|
27
|
+
#
|
28
|
+
# == requires
|
29
|
+
# *
|
30
|
+
#
|
31
|
+
# == input_type
|
32
|
+
# *
|
33
|
+
#
|
34
|
+
# == sut_type
|
35
|
+
# *
|
36
|
+
#
|
37
|
+
# == sut_version
|
38
|
+
# *
|
39
|
+
#
|
40
|
+
# == objects
|
41
|
+
# *;sut
|
42
|
+
#
|
43
|
+
module TestObjectSynchronization
|
44
|
+
|
45
|
+
include MobyBehaviour::Behaviour
|
46
|
+
|
47
|
+
# == description
|
48
|
+
# Wait until this test object has a child test object matching the given attributes or timeout exceeds. An exception will be raised if test object was not found in the specified timeout.
|
49
|
+
#
|
50
|
+
# == arguments
|
51
|
+
# attributes
|
52
|
+
# Hash
|
53
|
+
# description: Hash defining the set of attributes that the child test object must possess.
|
54
|
+
# example: {:text=>'1'}
|
55
|
+
#
|
56
|
+
# timeout
|
57
|
+
# Fixnum
|
58
|
+
# description: Overriding the default synchronization timeout
|
59
|
+
# example: 30
|
60
|
+
#
|
61
|
+
# retry_interval
|
62
|
+
# Fixnum
|
63
|
+
# description: Time used before retrying to find test object
|
64
|
+
# example: 1
|
65
|
+
#
|
66
|
+
# == returns
|
67
|
+
# MobyBase::TestObject
|
68
|
+
# description: Returns receiver object of this method, not the found object
|
69
|
+
# example: -
|
70
|
+
#
|
71
|
+
# == exceptions
|
72
|
+
# TypeError
|
73
|
+
# description: Wrong argument type <class> for attributes (expected Hash)
|
74
|
+
#
|
75
|
+
# TypeError
|
76
|
+
# description: Wrong argument type <class> for attribute :type (expected String)
|
77
|
+
#
|
78
|
+
# TypeError
|
79
|
+
# description: Wrong argument type <class> for timeout (expected Integer, Fixnum or Float)
|
80
|
+
#
|
81
|
+
# ArgumentError
|
82
|
+
# description: Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float
|
83
|
+
#
|
84
|
+
# MobyBase::SyncTimeoutError
|
85
|
+
# description: Synchronization timed out (%i) before the defined child object could be found
|
86
|
+
#
|
87
|
+
def wait_child( attributes = {}, timeout = 10, retry_interval = 0.5 )
|
88
|
+
|
89
|
+
# verify that attributes is type of Hash
|
90
|
+
attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
|
91
|
+
|
92
|
+
# verify that :type is type of String
|
93
|
+
attributes[ :type ].check_type( String, "Wrong argument type $1 for attribute :type (expected $2)" )
|
94
|
+
|
95
|
+
# verify that :type is not empty string
|
96
|
+
attributes[ :type ].not_empty( "Attribute :type must not be empty" )
|
97
|
+
|
98
|
+
# verify timeout type is numeric
|
99
|
+
timeout.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for timeout (expected $2)" )
|
100
|
+
|
101
|
+
# verify timeout type is numeric
|
102
|
+
retry_interval.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for retry interval (expected $2)" )
|
103
|
+
|
104
|
+
begin
|
105
|
+
|
106
|
+
dynamic_attributes = attributes.strip_dynamic_attributes!
|
107
|
+
|
108
|
+
# try to identify desired child test object
|
109
|
+
@test_object_factory.identify_object(
|
110
|
+
:object_attributes_hash => attributes,
|
111
|
+
:identification_directives => dynamic_attributes.default_values(
|
112
|
+
:__timeout => timeout,
|
113
|
+
:__retry_interval => retry_interval,
|
114
|
+
:__refresh_arguments => kind_of?( MobyBase::SUT ) ? attributes : { :id => get_application_id },
|
115
|
+
:__parent_application => sut? == true ? nil : @parent_application
|
116
|
+
),
|
117
|
+
:parent => self
|
118
|
+
)
|
119
|
+
|
120
|
+
rescue MobyBase::TestObjectNotFoundError
|
121
|
+
|
122
|
+
# the child object was not found in the specified timeout
|
123
|
+
raise MobyBase::SyncTimeoutError, "Synchronization timed out (#{ timeout }) before the defined child object could be found."
|
124
|
+
|
125
|
+
rescue MobyBase::ApplicationNotAvailableError
|
126
|
+
|
127
|
+
raise
|
128
|
+
|
129
|
+
rescue # unexpected errors
|
130
|
+
|
131
|
+
raise RuntimeError, "Synchronization failed due to #{ $!.message } (#{ $!.class })"
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
self
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
# enable hooking for performance measurement & debug logging
|
140
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
141
|
+
|
142
|
+
end # TDriverSyncronization
|
143
|
+
|
144
|
+
end # MobyBehaviour
|
@@ -0,0 +1,1047 @@
|
|
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 MobyBehaviour
|
21
|
+
|
22
|
+
# == description
|
23
|
+
# Describes the generic behaviour of TestObject, common methods that can be used to control TestObject
|
24
|
+
#
|
25
|
+
# == behaviour
|
26
|
+
# GenericTestObject
|
27
|
+
#
|
28
|
+
# == requires
|
29
|
+
# *
|
30
|
+
#
|
31
|
+
# == input_type
|
32
|
+
# *
|
33
|
+
#
|
34
|
+
# == sut_type
|
35
|
+
# *
|
36
|
+
#
|
37
|
+
# == sut_version
|
38
|
+
# *
|
39
|
+
#
|
40
|
+
# == objects
|
41
|
+
# *
|
42
|
+
#
|
43
|
+
module TestObject
|
44
|
+
|
45
|
+
# == nodoc
|
46
|
+
# == description
|
47
|
+
# attr_accessor
|
48
|
+
# == returns
|
49
|
+
# Hash
|
50
|
+
# description: Hash containing the identification attributes that were used when the test object was created.
|
51
|
+
# example: { :name => 'Triangle1', :type => :Triangle }
|
52
|
+
attr_accessor :creation_attributes
|
53
|
+
|
54
|
+
=begin
|
55
|
+
# == description
|
56
|
+
# Returns the actual test object that was used as the parent when this object instance was created
|
57
|
+
#
|
58
|
+
# == returns
|
59
|
+
# TestObject
|
60
|
+
# description: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
|
61
|
+
# example: -
|
62
|
+
attr_reader :parent
|
63
|
+
=end
|
64
|
+
|
65
|
+
=begin
|
66
|
+
# == nodoc
|
67
|
+
# == description
|
68
|
+
# attr_reader
|
69
|
+
# == returns
|
70
|
+
# Hash
|
71
|
+
# description: Parent application test object
|
72
|
+
# example: <MobyBase::TestObject>
|
73
|
+
attr_reader :parent_application
|
74
|
+
=end
|
75
|
+
|
76
|
+
# == nodoc
|
77
|
+
# == description
|
78
|
+
# Changes the status of the test object to active
|
79
|
+
# == returns
|
80
|
+
# TrueClass::
|
81
|
+
# == example
|
82
|
+
# @app = @sut.run(:name => 'testapp') # launches testapp
|
83
|
+
# @app.Node( :name => 'Node1' ).activate() # activate given object
|
84
|
+
def activate
|
85
|
+
|
86
|
+
@_active = true
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
=begin
|
91
|
+
# == description
|
92
|
+
# Determines if the current test object is of type 'application'
|
93
|
+
# == returns
|
94
|
+
# Boolean
|
95
|
+
# description: Determines is test object type of application
|
96
|
+
# example: false
|
97
|
+
def application?
|
98
|
+
|
99
|
+
@type == 'application'
|
100
|
+
|
101
|
+
end
|
102
|
+
=end
|
103
|
+
|
104
|
+
# == description
|
105
|
+
# Return all test object attributes. Please see [link="#GenericTestObject:[]"][][/link] method for alternative approach.
|
106
|
+
# == returns
|
107
|
+
# Hash
|
108
|
+
# description: Test object attributes
|
109
|
+
# example: {"localeLanguage"=>"English", "startDragDistance"=>"4", "windowIcon"=>"", "memUsage"=>"25669"}
|
110
|
+
# == example
|
111
|
+
# @test_app = @sut.run(:name => 'testapp') # launches testapp
|
112
|
+
# attributes_hash = @test_app.Triangle( :name => 'Triangle1' ).attributes # retrieve all attribute for triangle object
|
113
|
+
def attributes
|
114
|
+
|
115
|
+
# retrieve sut attribute filter type
|
116
|
+
filter_type = sut_parameters[ :filter_type, 'none' ]
|
117
|
+
|
118
|
+
# temporarly disable attribute filter to retrieve all test object attributes
|
119
|
+
sut_parameters[ :filter_type ] = 'none'
|
120
|
+
|
121
|
+
begin
|
122
|
+
|
123
|
+
# raise exception to refresh test object ui state if filter_type was something else than 'none'
|
124
|
+
raise MobyBase::TestObjectNotFoundError unless filter_type == 'none'
|
125
|
+
|
126
|
+
# retrieve xml data, performs xpath to sut xml_data
|
127
|
+
_xml_data = xml_data
|
128
|
+
|
129
|
+
rescue MobyBase::TestObjectNotFoundError
|
130
|
+
|
131
|
+
# attributes used to refresh parent application
|
132
|
+
if @creation_attributes[ :type ] == 'application'
|
133
|
+
|
134
|
+
# use application name and id attributes
|
135
|
+
refresh_args = { :name => @creation_attributes[ :name ], :id => @creation_attributes[ :id ] }
|
136
|
+
|
137
|
+
else
|
138
|
+
|
139
|
+
# test object if not type of application
|
140
|
+
refresh_args = { :id => get_application_id }
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
#lets refresh if attribute not found on first attempt
|
145
|
+
refresh( refresh_args )
|
146
|
+
|
147
|
+
# retrieve updated xml data
|
148
|
+
_xml_data = xml_data
|
149
|
+
|
150
|
+
ensure
|
151
|
+
|
152
|
+
# restore attributes filter type
|
153
|
+
sut_parameters[ :filter_type ] = filter_type
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
# return hash of test object attributes
|
158
|
+
@test_object_adapter.test_object_attributes( _xml_data )
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
# == description
|
163
|
+
# Function returns a attribute of test object. Please see [link="#GenericTestObject:[]"][][/link] method for alternative approach.
|
164
|
+
#
|
165
|
+
# == arguments
|
166
|
+
# name
|
167
|
+
# String
|
168
|
+
# description: String defining the name of the attribute to get
|
169
|
+
# example: "name"
|
170
|
+
#
|
171
|
+
# == returns
|
172
|
+
# String
|
173
|
+
# description: Value of the attribute as a string
|
174
|
+
# example: "value"
|
175
|
+
#
|
176
|
+
# == exceptions
|
177
|
+
# TestObjectNotInitializedError
|
178
|
+
# description: if the test object xml data has not been initialized
|
179
|
+
#
|
180
|
+
# AttributeNotFoundError
|
181
|
+
# description: if the requested attribute can not be found in the xml data of the object
|
182
|
+
#
|
183
|
+
# == example
|
184
|
+
# @test_app = @sut.run(:name => 'testapp') # launches testapp
|
185
|
+
# puts @test_app.Triangle( :name => 'Triangle1' ).attribute('color') # prints color of triangle object
|
186
|
+
def attribute( name )
|
187
|
+
|
188
|
+
# TODO: add behaviour logging?
|
189
|
+
|
190
|
+
# raise exception if attribute name variable type is other than string
|
191
|
+
name.check_type( [ String, Symbol ], "wrong argument type $1 for attribute (expected $2)" )
|
192
|
+
|
193
|
+
# convert name to string if variable type is symbol
|
194
|
+
name = name.to_s if name.kind_of?( Symbol )
|
195
|
+
|
196
|
+
# retrieve attribute value
|
197
|
+
find_attribute( name )
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
# == description
|
202
|
+
# Wrapper method to returns one or all test object attributes. This method calls [link="#GenericTestObject:attribute"]attribute[/link] or [link="#GenericTestObject:attributes"]attributes[/link] depending on the given argument.
|
203
|
+
#
|
204
|
+
# == arguments
|
205
|
+
# name
|
206
|
+
# String
|
207
|
+
# description: Attribute name
|
208
|
+
# example: "attribute_name"
|
209
|
+
# NilClass
|
210
|
+
# description: Return all attributes
|
211
|
+
# example: nil
|
212
|
+
#
|
213
|
+
# == returns
|
214
|
+
# String
|
215
|
+
# description: Value of the attribute
|
216
|
+
# example: "value"
|
217
|
+
#
|
218
|
+
# Hash
|
219
|
+
# description: Hash of all attributes
|
220
|
+
# example: {:x=>"0", :y=>"0"}
|
221
|
+
#
|
222
|
+
def []( name = nil )
|
223
|
+
|
224
|
+
if name.nil?
|
225
|
+
|
226
|
+
attributes
|
227
|
+
|
228
|
+
else
|
229
|
+
|
230
|
+
attribute( name )
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
# == description
|
237
|
+
# Returns the parent test object for the current object in question, according to the UI object hierarchy. For getting the test object that was actually used
|
238
|
+
# as the parent when the test object instance was created, see [link="#GenericTestObject:parent"]parent[/link] method.
|
239
|
+
# == returns
|
240
|
+
# TestObject
|
241
|
+
# description: test object that is parent of this test object, self if no parent (ie. application objects)
|
242
|
+
# example: -
|
243
|
+
# == example
|
244
|
+
# @app = @sut.run(:name => 'testapp') # launches testapp
|
245
|
+
# parent_test_object = @app.Node( :name => 'Node1' ).get_parent() #get parent for some test object
|
246
|
+
def get_parent
|
247
|
+
|
248
|
+
# return current test object if it's type of application
|
249
|
+
return self if application?
|
250
|
+
|
251
|
+
@sut.refresh if disable_optimizer
|
252
|
+
|
253
|
+
# retrieve parent of current xml element; objects/object/objects/object/../..
|
254
|
+
parent_element = @test_object_adapter.parent_test_object_element( self )
|
255
|
+
|
256
|
+
# retrieve parent element attributes
|
257
|
+
parent_attributes = @test_object_adapter.test_object_element_attributes( parent_element )
|
258
|
+
|
259
|
+
if get_application_id && parent_attributes[ 'type' ] != 'application'
|
260
|
+
|
261
|
+
parent = @sut.child(
|
262
|
+
|
263
|
+
:id => get_application_id,
|
264
|
+
:type => 'application'
|
265
|
+
|
266
|
+
).child(
|
267
|
+
|
268
|
+
:id => parent_attributes[ 'id' ],
|
269
|
+
:name => parent_attributes[ 'name' ],
|
270
|
+
:type => parent_attributes[ 'type' ],
|
271
|
+
|
272
|
+
# there was a case when the same parent was included twice in the ui dump
|
273
|
+
:__index => 0
|
274
|
+
)
|
275
|
+
|
276
|
+
else
|
277
|
+
|
278
|
+
parent = @sut.child(
|
279
|
+
:id => parent_attributes[ 'id' ],
|
280
|
+
:name => parent_attributes[ 'name' ],
|
281
|
+
:type => parent_attributes[ 'type' ]
|
282
|
+
)
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
enable_optimizer
|
287
|
+
|
288
|
+
parent
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
# == nodoc
|
293
|
+
# Function refreshes test objects to correspond with the current state of the device.
|
294
|
+
#
|
295
|
+
# NOTE:
|
296
|
+
#
|
297
|
+
# @sut#refresh will call update method for this TestObject, if state has changed. Thus, calling
|
298
|
+
# @sut.refresh might have a side effect that changes the @_active instance variable.
|
299
|
+
# === raises
|
300
|
+
# TestObjectNotFoundError:: if TestObject is not identified within synch timeout.
|
301
|
+
def refresh( refresh_args = {} )
|
302
|
+
|
303
|
+
refresh_args.check_type Hash, "wrong argument type $1 for #{ application? ? 'application' : 'test object' } refresh attributes (expected $2)"
|
304
|
+
|
305
|
+
if refresh_args.blank?
|
306
|
+
|
307
|
+
if application?
|
308
|
+
|
309
|
+
refresh_args = { :name => @name, :id => @id }
|
310
|
+
|
311
|
+
else
|
312
|
+
|
313
|
+
refresh_args = { :name => @parent_application.name, :id => @parent_application.id }
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
@sut.refresh(
|
320
|
+
|
321
|
+
refresh_args, @test_object_factory.make_object_search_params( parent, @creation_attributes )
|
322
|
+
|
323
|
+
)
|
324
|
+
|
325
|
+
# update childs if required, returns true or false
|
326
|
+
update( xml_data ) unless @sut.use_find_objects
|
327
|
+
|
328
|
+
nil
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
# == nodoc
|
333
|
+
# Function refreshes test objects to correspond with the current state of the device, forcing
|
334
|
+
# the sut to request a new XML dump from the device.
|
335
|
+
#
|
336
|
+
# NOTE:
|
337
|
+
#
|
338
|
+
# @sut#force_refresh will call update method for this TestObject, if state has changed. Thus, calling
|
339
|
+
# @sut.force_refresh might have a side effect that changes the @_active instance variable.
|
340
|
+
# === raises
|
341
|
+
# TestObjectNotFoundError:: if TestObject is not identified within synch timeout.
|
342
|
+
def force_refresh( refresh_args = nil )
|
343
|
+
|
344
|
+
refresh_args = @creation_attributes if refresh_args.nil?
|
345
|
+
|
346
|
+
refresh( refresh_args )
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
# == description
|
351
|
+
# Function for finding out the application this test ojbect
|
352
|
+
# == returns
|
353
|
+
# MobyBase::TestObject
|
354
|
+
# description: Application test object that the test object belongs to, or nil, if no parent of type application can be found.
|
355
|
+
# example: -
|
356
|
+
# == example
|
357
|
+
# parent_app = @app.Node( :name => 'Node1' ).get_application() #get application for some test object, this should return @app.
|
358
|
+
def get_application
|
359
|
+
|
360
|
+
# test object should have @parent_application always
|
361
|
+
return @parent_application if @parent_application
|
362
|
+
|
363
|
+
# workaround: fetch application from sut, this part of code should not be executed ever
|
364
|
+
return self if application?
|
365
|
+
|
366
|
+
test_object = @parent
|
367
|
+
|
368
|
+
while test_object
|
369
|
+
|
370
|
+
return test_object if ( test_object.type == 'application' )
|
371
|
+
|
372
|
+
test_object = test_object.parent
|
373
|
+
|
374
|
+
end
|
375
|
+
|
376
|
+
# return application object or nil if no parent found
|
377
|
+
# Does is make sense to return nil - should n't all test objects belong to an application? Maybe throw exception if application not found
|
378
|
+
begin
|
379
|
+
|
380
|
+
@sut.child( :type => 'application' )
|
381
|
+
|
382
|
+
rescue
|
383
|
+
|
384
|
+
nil
|
385
|
+
|
386
|
+
end
|
387
|
+
|
388
|
+
end
|
389
|
+
|
390
|
+
# == nodoc
|
391
|
+
# == description
|
392
|
+
# Function for finding out the application id for this test object
|
393
|
+
# == returns
|
394
|
+
# String:: representing the id of the application test object that this test object belongs to.
|
395
|
+
# == example
|
396
|
+
# puts @app.Node( :name => 'Node1' ).get_application_id() #print the application id, this should print @app.id
|
397
|
+
def get_application_id
|
398
|
+
|
399
|
+
if @parent_application
|
400
|
+
|
401
|
+
@parent_application.id
|
402
|
+
|
403
|
+
else
|
404
|
+
|
405
|
+
# workaround
|
406
|
+
# What about the case when get_application returns nil? This line will throw an exception in that case.
|
407
|
+
get_application.id
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
# == nodoc
|
414
|
+
def set_application_id( application_id )
|
415
|
+
|
416
|
+
@_application_id = application_id
|
417
|
+
|
418
|
+
end
|
419
|
+
|
420
|
+
# == description
|
421
|
+
# Returns a StateObject containing the current state of this test object as XML. The state object is static and thus is not refreshed or synchronized etc.
|
422
|
+
#
|
423
|
+
# == returns
|
424
|
+
# StateObject
|
425
|
+
# description: State of this test object
|
426
|
+
# example: -
|
427
|
+
#
|
428
|
+
# == exceptions
|
429
|
+
# ArgumentError
|
430
|
+
# description: If the xml source for the object cannot be read
|
431
|
+
def state_object
|
432
|
+
|
433
|
+
# == example
|
434
|
+
# app_state = @sut.application( :name => "calculator" ).state #get the state object for the app
|
435
|
+
# button_state = app_state.Button( :text => "Backspace" ) #get the state for test object button
|
436
|
+
# button_text = button_state.attribute( "text" ) #get attribute text from the button state object
|
437
|
+
|
438
|
+
MobyBase::StateObject.new(
|
439
|
+
|
440
|
+
:source_data => xml_data,
|
441
|
+
:parent => self,
|
442
|
+
:test_object_adapter => @test_object_adapter
|
443
|
+
|
444
|
+
)
|
445
|
+
|
446
|
+
end
|
447
|
+
|
448
|
+
# == description
|
449
|
+
# Creates a child test object of this test object. Caller object will be associated as child test objects parent.\n
|
450
|
+
# \n
|
451
|
+
# [b]NOTE:[/b] Subsequent calls to TestObject#child( rule ) always returns reference to same Testobject:\n
|
452
|
+
# [code]a = to.child( :type => 'Button', :text => '1' )
|
453
|
+
# b = to.child( :type => 'Button', :text => '1' )
|
454
|
+
# a.eql?( b ) # => true[/code]
|
455
|
+
# \n
|
456
|
+
# [b]NOTE:[/b] If the parameter 'use_find_object' in tdriver_parameters.xml is true (default), objects with visibleOnScreen value 'false' might be
|
457
|
+
# optimized out and not appear in the results.
|
458
|
+
# \n
|
459
|
+
# == arguments
|
460
|
+
# attributes
|
461
|
+
# Hash
|
462
|
+
# description: Hash object holding information for identifying which child to create
|
463
|
+
# example: { :type => :slider }
|
464
|
+
#
|
465
|
+
# == returns
|
466
|
+
# MobyBase::TestObject
|
467
|
+
# description: new child test object or reference to existing child
|
468
|
+
# example: -
|
469
|
+
#
|
470
|
+
# == exceptions
|
471
|
+
# TypeError
|
472
|
+
# description: Wrong argument type <class> for attributes (expected Hash)
|
473
|
+
#
|
474
|
+
# MultipleTestObjectsIdentifiedError
|
475
|
+
# description: raised if multiple objects found that match the given attributes
|
476
|
+
#
|
477
|
+
# TestObjectNotFoundError
|
478
|
+
# description: raised if the child object could not be found
|
479
|
+
#
|
480
|
+
# TestObjectNotVisibleError
|
481
|
+
# description: rasied if the parent test object is no longer visible
|
482
|
+
def child( attributes )
|
483
|
+
|
484
|
+
# verify attributes argument format
|
485
|
+
attributes.check_type [ Hash, String, Symbol, Regexp, Array ], "wrong argument type $1 for attributes (expected $2)"
|
486
|
+
|
487
|
+
# set rules hash to empty Hash if rules hash is not type of Hash
|
488
|
+
unless attributes.kind_of?( Hash )
|
489
|
+
|
490
|
+
# pass empty rules hash if no argument given, otherwise assume value to be object name
|
491
|
+
if attributes.blank?
|
492
|
+
|
493
|
+
attributes = {}
|
494
|
+
|
495
|
+
else
|
496
|
+
|
497
|
+
attributes = { :name => attributes }
|
498
|
+
|
499
|
+
end
|
500
|
+
|
501
|
+
end
|
502
|
+
|
503
|
+
get_child_objects( attributes )
|
504
|
+
|
505
|
+
end
|
506
|
+
|
507
|
+
# == description
|
508
|
+
# Function similar to child, but returns an array of children test objects that meet the given criteria.
|
509
|
+
# \n\n
|
510
|
+
# [b]NOTE:[/b] If the parameter 'use_find_object' in tdriver_parameters.xml is true (default), objects with visibleOnScreen value 'false' might be
|
511
|
+
# optimized out and not appear in the results.
|
512
|
+
#
|
513
|
+
# == arguments
|
514
|
+
# attributes
|
515
|
+
# Hash
|
516
|
+
# description: object holding information for identifying which child to create
|
517
|
+
# example: { :type => :slider }
|
518
|
+
#
|
519
|
+
# find_all_children
|
520
|
+
# TrueClass
|
521
|
+
# description: Boolean specifying whether all children under the test node or just immediate children should be retreived
|
522
|
+
# example: true
|
523
|
+
# FalseClass
|
524
|
+
# description: Boolean specifying whether all children under the test node or just immediate children should be retreived
|
525
|
+
# example: false
|
526
|
+
#
|
527
|
+
# == returns
|
528
|
+
# Array
|
529
|
+
# description: An array of test objects
|
530
|
+
# example: [ MobyBase::TestObject, MobyBase::TestObject, MobyBase::TestObject, ... ]
|
531
|
+
#
|
532
|
+
# == exceptions
|
533
|
+
# TypeError
|
534
|
+
# description: raised if agument is not a Hash
|
535
|
+
#
|
536
|
+
# TestObjectNotFoundError
|
537
|
+
# description: raised if the child object could not be found
|
538
|
+
#
|
539
|
+
# TestObjectNotVisibleError
|
540
|
+
# description: rasied if the parent test object is no longer visible
|
541
|
+
def children( attributes, find_all_children = true )
|
542
|
+
|
543
|
+
# verify attributes argument format
|
544
|
+
attributes.check_type( Hash, "wrong argument type $1 for attributes (expected $2)" )
|
545
|
+
|
546
|
+
# verify find_all_children argument format
|
547
|
+
find_all_children.check_type( [ TrueClass, FalseClass ], "wrong argument type $1 for find_all_children (expected $2)" )
|
548
|
+
|
549
|
+
# If empty or only special attributes then add :type => '*' to search all
|
550
|
+
attributes[ :type ] = '*' if attributes.select{ | key, value | key.to_s !~ /^__/ ? true : false }.empty?
|
551
|
+
|
552
|
+
# children method specific settings
|
553
|
+
attributes.merge!( :__multiple_objects => true, :__find_all_children => find_all_children, :__no_caching => true )
|
554
|
+
|
555
|
+
# disable optimizer state if enabled
|
556
|
+
#disable_optimizer -> leave it on, tuukka if breaks take it back...
|
557
|
+
|
558
|
+
# retrieve child objects
|
559
|
+
result = get_child_objects( attributes )
|
560
|
+
|
561
|
+
# restore optimizer state if it was enabled
|
562
|
+
#enable_optimizer
|
563
|
+
|
564
|
+
# return results
|
565
|
+
result
|
566
|
+
|
567
|
+
end
|
568
|
+
|
569
|
+
private
|
570
|
+
|
571
|
+
# == nodoc
|
572
|
+
# Updates this test object to match the data in the provided xml document
|
573
|
+
# Propagates updating to all child TestObjects
|
574
|
+
# If TestObject is not identified, then current TO is deactivated, as is all the Child objects, as defined in TestObject#deactivate.
|
575
|
+
# === params
|
576
|
+
# xml_document:: MobyUtil::XML::Node describing the new state of this test object
|
577
|
+
# === returns
|
578
|
+
# ?
|
579
|
+
# === raises
|
580
|
+
# nothing
|
581
|
+
def update( xml_document )
|
582
|
+
|
583
|
+
begin
|
584
|
+
|
585
|
+
# find object from new xml data
|
586
|
+
_xml_data, unused_rule = @test_object_adapter.get_objects( xml_document, { :type => @type, :id => @id, :name => @name }, true )
|
587
|
+
|
588
|
+
# deactivate if test object not found or multiple matches found
|
589
|
+
raise unless _xml_data.count == 1
|
590
|
+
|
591
|
+
# get first matching element
|
592
|
+
_xml_data = _xml_data.first
|
593
|
+
|
594
|
+
#unless _xml_data.eql?( xml_data )
|
595
|
+
|
596
|
+
# store previous object environment value
|
597
|
+
previous_environment = @env
|
598
|
+
|
599
|
+
# update current test objects xml_data
|
600
|
+
__send__( :xml_data=, _xml_data )
|
601
|
+
|
602
|
+
# compare new environment value with previous
|
603
|
+
if @env != previous_environment
|
604
|
+
|
605
|
+
# remove cached behaviour module
|
606
|
+
TDriver::BehaviourFactory.reset_cache
|
607
|
+
|
608
|
+
# apply only application behaviours if test object is type of 'application'
|
609
|
+
object_type = ( @type == "application" ? [ @type ] : [ '*', @type ] )
|
610
|
+
|
611
|
+
# reapply behaviours to test object if environment value has changed
|
612
|
+
TDriver::BehaviourFactory.apply_behaviour(
|
613
|
+
|
614
|
+
:object => self,
|
615
|
+
:object_type => object_type,
|
616
|
+
:input_type => [ '*', @sut.input.to_s ],
|
617
|
+
:env => [ '*', *@env.to_s.split(";") ],
|
618
|
+
:version => [ '*', @sut.ui_version.to_s ]
|
619
|
+
|
620
|
+
)
|
621
|
+
|
622
|
+
end
|
623
|
+
|
624
|
+
# update child objects
|
625
|
+
@child_object_cache.each_object{ | test_object |
|
626
|
+
|
627
|
+
# update test object with new xml_data
|
628
|
+
#test_object.update( _xml_data )
|
629
|
+
test_object.send( :update, _xml_data )
|
630
|
+
|
631
|
+
} unless @sut.use_find_objects
|
632
|
+
|
633
|
+
#end
|
634
|
+
|
635
|
+
rescue
|
636
|
+
|
637
|
+
# deactivate test object
|
638
|
+
deactivate
|
639
|
+
|
640
|
+
end
|
641
|
+
|
642
|
+
end
|
643
|
+
|
644
|
+
# TODO: document me
|
645
|
+
def disable_optimizer
|
646
|
+
|
647
|
+
# disable optimizer for this call since it will not work
|
648
|
+
@_enable_optimizer = false
|
649
|
+
|
650
|
+
if @sut.use_find_objects == true
|
651
|
+
|
652
|
+
@sut.use_find_objects = false
|
653
|
+
|
654
|
+
@_enable_optimizer = true
|
655
|
+
|
656
|
+
end
|
657
|
+
|
658
|
+
@_enable_optimizer
|
659
|
+
|
660
|
+
end
|
661
|
+
|
662
|
+
# TODO: document me
|
663
|
+
def enable_optimizer
|
664
|
+
|
665
|
+
@sut.use_find_objects = true if @_enable_optimizer
|
666
|
+
|
667
|
+
@_enable_optimizer = false
|
668
|
+
|
669
|
+
end
|
670
|
+
|
671
|
+
# TODO: document me
|
672
|
+
# Tries to use the missing method id as a child object type and find an object based on it
|
673
|
+
def method_missing( method_id, *method_arguments )
|
674
|
+
|
675
|
+
# create rules hash
|
676
|
+
rules_hash = method_arguments.first
|
677
|
+
|
678
|
+
# set rules hash to empty Hash if rules hash is not type of Hash
|
679
|
+
unless rules_hash.kind_of?( Hash )
|
680
|
+
|
681
|
+
# pass empty rules hash if no argument given, otherwise assume value to be object name
|
682
|
+
if rules_hash.blank?
|
683
|
+
|
684
|
+
rules_hash = {}
|
685
|
+
|
686
|
+
else
|
687
|
+
|
688
|
+
rules_hash = { :name => rules_hash }
|
689
|
+
|
690
|
+
end
|
691
|
+
|
692
|
+
end
|
693
|
+
|
694
|
+
# set test object type
|
695
|
+
rules_hash[ :type ] = method_id.to_s
|
696
|
+
|
697
|
+
begin
|
698
|
+
|
699
|
+
# return created child object
|
700
|
+
child( rules_hash )
|
701
|
+
|
702
|
+
rescue MobyBase::TestObjectNotFoundError, MobyBase::TestObjectNotVisibleError
|
703
|
+
|
704
|
+
rules_hash_clone = rules_hash.clone
|
705
|
+
|
706
|
+
# remove type attribute from hash
|
707
|
+
rules_hash_clone.delete(:type)
|
708
|
+
|
709
|
+
# string representation of used rule hash, remove curly braces
|
710
|
+
attributes_string = rules_hash_clone.inspect[ 1 .. -2 ]
|
711
|
+
|
712
|
+
if attributes_string.empty?
|
713
|
+
|
714
|
+
# do not show any attribute details if none given
|
715
|
+
attributes_string = ""
|
716
|
+
|
717
|
+
else
|
718
|
+
|
719
|
+
# show used attributes
|
720
|
+
attributes_string = " (attributes #{ attributes_string })"
|
721
|
+
|
722
|
+
end
|
723
|
+
|
724
|
+
# raise slightly different exception message when receiver test object is type of application
|
725
|
+
if application?
|
726
|
+
|
727
|
+
message = "The application (id: #{ @id }, name: #{ @name.inspect }) has no child object with type or behaviour method with name #{ method_id.to_s.inspect }#{ attributes_string } on #{ @sut.id.inspect }"
|
728
|
+
|
729
|
+
else
|
730
|
+
|
731
|
+
message = "The test object (id: #{ @id }, type: #{ @type.inspect }, name: #{ @name.inspect }) has no child object with type or behaviour method with name #{ method_id.to_s.inspect }#{ attributes_string } on #{ @sut.id.inspect }"
|
732
|
+
|
733
|
+
end
|
734
|
+
|
735
|
+
# raise exception
|
736
|
+
raise MobyBase::TestObjectNotFoundError, message
|
737
|
+
|
738
|
+
end
|
739
|
+
|
740
|
+
end
|
741
|
+
|
742
|
+
# helper function to retrieve child oblect(s), used by child and children methods
|
743
|
+
def get_child_objects( attributes )
|
744
|
+
|
745
|
+
###############################################################################################################
|
746
|
+
#
|
747
|
+
# NOTICE: Please do not add anything unnessecery to this method, it might cause a major performance impact
|
748
|
+
#
|
749
|
+
|
750
|
+
# for backwards compatibility
|
751
|
+
if attributes.has_key?( :__logging )
|
752
|
+
|
753
|
+
# for backward compatibility
|
754
|
+
if attributes[ :__logging ].kind_of?( String )
|
755
|
+
|
756
|
+
warn "warning: deprecated variable type String for :__logging test object creation directive (expected TrueClass or FalseClass)"
|
757
|
+
|
758
|
+
attributes[ :__logging ] = attributes[ :__logging ].to_boolean
|
759
|
+
|
760
|
+
end
|
761
|
+
|
762
|
+
end
|
763
|
+
|
764
|
+
# store original hash
|
765
|
+
creation_hash = attributes.clone
|
766
|
+
|
767
|
+
dynamic_attributes = creation_hash.strip_dynamic_attributes!
|
768
|
+
|
769
|
+
# raise exception if wrong value type given for ;__logging
|
770
|
+
dynamic_attributes[ :__logging ].check_type(
|
771
|
+
|
772
|
+
[ TrueClass, FalseClass ],
|
773
|
+
|
774
|
+
"wrong value type $1 for :__logging test object creation directive (expected $2)"
|
775
|
+
|
776
|
+
) if dynamic_attributes.has_key?( :__logging )
|
777
|
+
|
778
|
+
# disable logging if requested, remove pair from creation_hash
|
779
|
+
$logger.push_enabled( dynamic_attributes[ :__logging ] || TDriver.logger.enabled )
|
780
|
+
|
781
|
+
# check if the hash contains symbols as values and translate those into strings
|
782
|
+
@sut.translate_values!( creation_hash, attributes[ :__fname ], attributes[ :__plurality ], attributes[ :__numerus ], attributes[ :__lengthvariant ] )
|
783
|
+
|
784
|
+
begin
|
785
|
+
|
786
|
+
# TODO: refactor me
|
787
|
+
child_test_object = @test_object_factory.get_test_objects(
|
788
|
+
|
789
|
+
# current object as parent, can be either TestObject or SUT
|
790
|
+
:parent => self,
|
791
|
+
|
792
|
+
# pass parent application
|
793
|
+
:parent_application => @parent_application,
|
794
|
+
|
795
|
+
# test object identification hash
|
796
|
+
:object_attributes_hash => creation_hash,
|
797
|
+
|
798
|
+
# pass test object identification directives, e.g. :__index
|
799
|
+
:identification_directives => dynamic_attributes
|
800
|
+
|
801
|
+
)
|
802
|
+
|
803
|
+
rescue Exception => exception
|
804
|
+
|
805
|
+
if exception.kind_of?( MobyBase::MultipleTestObjectsIdentifiedError )
|
806
|
+
|
807
|
+
description = "Multiple child objects matched criteria."
|
808
|
+
|
809
|
+
elsif exception.kind_of?( MobyBase::TestObjectNotFoundError )
|
810
|
+
|
811
|
+
description = "The child object(s) could not be found."
|
812
|
+
|
813
|
+
elsif exception.kind_of?( MobyBase::TestObjectNotVisibleError )
|
814
|
+
|
815
|
+
description = "Parent test object no longer visible."
|
816
|
+
|
817
|
+
else
|
818
|
+
|
819
|
+
description = "Failed when trying to find child object(s)."
|
820
|
+
|
821
|
+
end
|
822
|
+
|
823
|
+
$logger.behaviour "FAIL;#{ description };#{ identity };#{ dynamic_attributes[ :__multiple_objects ] ? "children" : "child" };#{ attributes.inspect }"
|
824
|
+
|
825
|
+
raise exception
|
826
|
+
|
827
|
+
ensure
|
828
|
+
|
829
|
+
# restore original logger state
|
830
|
+
$logger.pop_enabled
|
831
|
+
|
832
|
+
end
|
833
|
+
|
834
|
+
# return child test object
|
835
|
+
child_test_object
|
836
|
+
|
837
|
+
end
|
838
|
+
|
839
|
+
# == nodoc
|
840
|
+
# Changes the status of the test object to inactive, also deactivating all children
|
841
|
+
# Removes reference from @parent TestObject or SUT to this TestObject so that
|
842
|
+
# @parent.refresh does not refresh currrent TestObject
|
843
|
+
#
|
844
|
+
# Does nothing if TestObject is already deactivated
|
845
|
+
# == returns
|
846
|
+
# ?
|
847
|
+
def deactivate
|
848
|
+
|
849
|
+
if @_active
|
850
|
+
|
851
|
+
@_active = false
|
852
|
+
|
853
|
+
# iterate through all test objects child test objects
|
854
|
+
@child_object_cache.each_object{ | test_object |
|
855
|
+
|
856
|
+
# deactivate test object
|
857
|
+
test_object.__send__( :deactivate )
|
858
|
+
|
859
|
+
}
|
860
|
+
|
861
|
+
# remove test objects from cache
|
862
|
+
@child_object_cache.remove_objects
|
863
|
+
|
864
|
+
# remove from parent objects children objects cache
|
865
|
+
@parent.instance_variable_get( :@child_object_cache ).remove_object( self )
|
866
|
+
|
867
|
+
nil
|
868
|
+
|
869
|
+
end
|
870
|
+
|
871
|
+
end
|
872
|
+
|
873
|
+
# TODO: refactor logging_enabled
|
874
|
+
# try to reactivate test object if currently not active
|
875
|
+
def reactivate_test_object( attributes )
|
876
|
+
|
877
|
+
refresh_args = ( attributes[ :type ] == 'application' ? { :name => attributes[ :name ], :id => attributes[ :id ] } : { :id => get_application_id } )
|
878
|
+
|
879
|
+
refresh( refresh_args )
|
880
|
+
|
881
|
+
begin
|
882
|
+
|
883
|
+
@parent.child( :type => @type, :id => @id )
|
884
|
+
|
885
|
+
rescue MobyBase::TestObjectNotFoundError
|
886
|
+
|
887
|
+
raise MobyBase::TestObjectNotVisibleError
|
888
|
+
|
889
|
+
end
|
890
|
+
|
891
|
+
end
|
892
|
+
|
893
|
+
# Creates a string identifying this test object: sut, type, attributes used when created
|
894
|
+
#
|
895
|
+
# === returns
|
896
|
+
# String:: String identifying this test object
|
897
|
+
def identity
|
898
|
+
|
899
|
+
"#{ @sut.id };#{ @type };#{ @creation_attributes.inspect }"
|
900
|
+
|
901
|
+
end
|
902
|
+
|
903
|
+
# TODO: document me
|
904
|
+
# NOTE: this method should be called only internally, TestObject#attribute is end-user method that shouldn't be called inside framework
|
905
|
+
def find_attribute( name )
|
906
|
+
|
907
|
+
# store xml data to variable, due to xml_data is a function that returns result of xpath to sut.xml_data
|
908
|
+
_xml_data = nil
|
909
|
+
|
910
|
+
# note: tries count represents total number of tries
|
911
|
+
MobyUtil::Retryable.while( :tries => 2, :interval => 0 ) { | attempt |
|
912
|
+
|
913
|
+
begin
|
914
|
+
|
915
|
+
begin
|
916
|
+
|
917
|
+
# retrieve xml data, performs xpath to sut xml_data
|
918
|
+
_xml_data = xml_data
|
919
|
+
|
920
|
+
rescue MobyBase::TestObjectNotFoundError
|
921
|
+
|
922
|
+
# attributes used to refresh parent application
|
923
|
+
if @creation_attributes[ :type ] == 'application'
|
924
|
+
|
925
|
+
# use application name and id attributes
|
926
|
+
refresh_args = { :name => @creation_attributes[ :name ], :id => @creation_attributes[ :id ] }
|
927
|
+
|
928
|
+
else
|
929
|
+
|
930
|
+
# test object if not type of application
|
931
|
+
refresh_args = { :id => get_application_id }
|
932
|
+
|
933
|
+
end
|
934
|
+
|
935
|
+
#refresh( refresh_args )
|
936
|
+
|
937
|
+
# lets refresh if attribute not found on first attempt
|
938
|
+
@sut.refresh(
|
939
|
+
|
940
|
+
refresh_args, @test_object_factory.make_object_search_params( parent, @creation_attributes )
|
941
|
+
|
942
|
+
)
|
943
|
+
|
944
|
+
# retrieve updated xml data
|
945
|
+
_xml_data = xml_data
|
946
|
+
|
947
|
+
end
|
948
|
+
|
949
|
+
# raise eception if xml data is empty or nil
|
950
|
+
raise MobyBase::TestObjectNotInitializedError.new if _xml_data.nil? || _xml_data.to_s.empty?
|
951
|
+
|
952
|
+
begin
|
953
|
+
|
954
|
+
# retrieve attribute(s) from test object; never access ui state xml data directly from behaviour implementation
|
955
|
+
@test_object_adapter.test_object_attribute( _xml_data, name )
|
956
|
+
|
957
|
+
rescue MobyBase::AttributeNotFoundError
|
958
|
+
|
959
|
+
raise MobyBase::AttributeNotFoundError, "Could not find attribute #{ name.inspect } for test object of type #{ @type.to_s }"
|
960
|
+
|
961
|
+
end
|
962
|
+
|
963
|
+
rescue MobyBase::AttributeNotFoundError
|
964
|
+
|
965
|
+
# add attribute to attribute filter whitelist only once
|
966
|
+
if ( attempt == 1 )
|
967
|
+
|
968
|
+
# add to attribute filter
|
969
|
+
TDriver::AttributeFilter.add_attribute( name )
|
970
|
+
|
971
|
+
# refresh test object ui state
|
972
|
+
refresh
|
973
|
+
|
974
|
+
end
|
975
|
+
|
976
|
+
# raise exception and retry if attempts left
|
977
|
+
raise
|
978
|
+
|
979
|
+
end
|
980
|
+
|
981
|
+
}
|
982
|
+
|
983
|
+
end
|
984
|
+
|
985
|
+
# this method will be automatically invoked after module is extended to target object
|
986
|
+
def self.extended( target_object )
|
987
|
+
|
988
|
+
target_object.instance_exec{
|
989
|
+
|
990
|
+
# defaults
|
991
|
+
@_application_id ||= nil
|
992
|
+
|
993
|
+
@creation_attributes ||= nil
|
994
|
+
|
995
|
+
@_active ||= true
|
996
|
+
|
997
|
+
@parent_application ||= nil
|
998
|
+
|
999
|
+
}
|
1000
|
+
|
1001
|
+
end
|
1002
|
+
|
1003
|
+
public
|
1004
|
+
|
1005
|
+
# == deprecated
|
1006
|
+
# 0.8.x
|
1007
|
+
#
|
1008
|
+
# == description
|
1009
|
+
# This method is deprecated, please use TestObject#parent
|
1010
|
+
# This method is deprecated, please use [link="#GenericTestObject:parent"]TestObject#parent[/link] instead.
|
1011
|
+
#
|
1012
|
+
def parent_object
|
1013
|
+
|
1014
|
+
# == description
|
1015
|
+
# Returns the actual test object that was used as the parent when this object instance was created.
|
1016
|
+
# Userd to retrieve the parent object in the UI object hierarchy,
|
1017
|
+
# see get_parent.
|
1018
|
+
#
|
1019
|
+
# == returns
|
1020
|
+
# TestObject:: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
|
1021
|
+
|
1022
|
+
warn_caller '$1:$2 warning: TestObject#parent_object is deprecated, please use TestObject#parent instead.'
|
1023
|
+
|
1024
|
+
@parent
|
1025
|
+
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
# == deprecated
|
1029
|
+
# 1.1.1
|
1030
|
+
#
|
1031
|
+
# == description
|
1032
|
+
# This method is deprecated, please use [link="#GenericTestObject:state_object"]TestObject#state_object[/link] instead.
|
1033
|
+
#
|
1034
|
+
def state
|
1035
|
+
|
1036
|
+
warn_caller '$1:$2 warning: deprecated method TestObject#state; please use TestObject#state_object instead'
|
1037
|
+
|
1038
|
+
state_object
|
1039
|
+
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
# enable hooking for performance measurement & debug logging
|
1043
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
1044
|
+
|
1045
|
+
end # TestObject
|
1046
|
+
|
1047
|
+
end # MobyBehaviour
|