testability-driver 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +2 -2
- data/lib/tdriver-devtools/tdriver-devtools.rb +1 -1
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +3 -3
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +6 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +5 -3
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/factory.rb +225 -225
- data/lib/tdriver/base/errors.rb +1 -1
- data/lib/tdriver/base/state_object.rb +227 -179
- data/lib/tdriver/base/sut/controller.rb +2 -2
- data/lib/tdriver/base/sut/factory.rb +190 -182
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +69 -25
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +1 -1
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +4 -4
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +3 -3
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +350 -165
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +9 -9
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +191 -103
- data/lib/tdriver/base/sut/generic/commands/application.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +1 -1
- data/lib/tdriver/base/sut/generic/plugin.rb +1 -1
- data/lib/tdriver/base/sut/sut.rb +5 -1
- data/lib/tdriver/base/test_object/abstract.rb +136 -151
- data/lib/tdriver/base/test_object/adapter.rb +293 -82
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +20 -17
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +159 -532
- data/lib/tdriver/base/test_object/cache.rb +1 -1
- data/lib/tdriver/base/test_object/factory.rb +254 -605
- data/lib/tdriver/base/test_object/identificator.rb +1 -1
- data/lib/tdriver/base/test_object/loader.rb +1 -1
- data/lib/tdriver/base/test_object/verification.rb +17 -17
- data/lib/tdriver/loader.rb +20 -9
- data/lib/tdriver/report/report.rb +5 -0
- data/lib/tdriver/report/report_creator.rb +2 -2
- data/lib/tdriver/report/report_cucumber_listener.rb +4 -4
- data/lib/tdriver/report/report_cucumber_reporter.rb +4 -4
- data/lib/tdriver/report/report_execution_statistics.rb +22 -22
- data/lib/tdriver/report/report_grouping.rb +2 -2
- data/lib/tdriver/report/report_javascript.rb +11 -4
- data/lib/tdriver/report/report_test_case_run.rb +2 -2
- data/lib/tdriver/report/report_test_run.rb +5 -5
- data/lib/tdriver/report/report_test_unit.rb +74 -26
- data/lib/tdriver/report/report_writer.rb +70 -13
- data/lib/tdriver/tdriver.rb +17 -8
- data/lib/tdriver/util/common/array.rb +1 -1
- data/lib/tdriver/util/common/crc16.rb +1 -1
- data/lib/tdriver/util/common/environment.rb +1 -1
- data/lib/tdriver/util/common/file.rb +18 -9
- data/lib/tdriver/util/common/gem.rb +1 -1
- data/lib/tdriver/util/common/hash.rb +21 -0
- data/lib/tdriver/util/common/kernel.rb +1 -1
- data/lib/tdriver/util/common/loader.rb +5 -2
- data/lib/tdriver/util/common/numeric.rb +54 -3
- data/lib/tdriver/util/common/retryable.rb +30 -12
- data/lib/tdriver/util/common/stackable.rb +185 -0
- data/lib/tdriver/util/common/string.rb +21 -5
- data/lib/tdriver/util/{dbaccess/dbaccess.rb → database/access.rb} +4 -1
- data/lib/tdriver/util/{dbaccess/dbconnection.rb → database/connection.rb} +3 -0
- data/lib/tdriver/util/{dbaccess → database}/error.rb +0 -1
- data/lib/tdriver/util/{dbaccess → database}/loader.rb +5 -6
- data/lib/tdriver/util/{dynamic_attribute_filter.rb → filters/dynamic_attributes.rb} +1 -1
- data/lib/tdriver/util/hooking/hooking.rb +477 -0
- data/lib/tdriver/util/loader.rb +35 -29
- data/lib/tdriver/util/localisation/error.rb +0 -1
- data/lib/tdriver/util/localisation/loader.rb +1 -4
- data/lib/tdriver/util/localisation/localisation.rb +30 -27
- data/lib/tdriver/util/{common.rb → logger/loader.rb} +2 -4
- data/lib/tdriver/util/logger/logger.rb +574 -0
- data/lib/tdriver/util/operator_data/loader.rb +4 -3
- data/lib/tdriver/util/operator_data/operator_data.rb +5 -5
- data/lib/tdriver/util/parameter/parameter.rb +7 -1
- data/lib/tdriver/util/parameter/parameter_hash.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_template.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_user_api.rb +28 -20
- data/lib/tdriver/util/parameter/parameter_xml.rb +1 -1
- data/lib/tdriver/util/plugin/abstract.rb +1 -1
- data/lib/tdriver/util/plugin/service.rb +1 -1
- data/lib/tdriver/util/{localisation.rb → recorder/loader.rb} +4 -3
- data/lib/tdriver/util/recorder/recorder.rb +66 -0
- data/lib/tdriver/util/recorder/scripter.rb +258 -0
- data/lib/tdriver/util/{stats.rb → statistics/statistics.rb} +7 -8
- data/lib/tdriver/util/user_data/error.rb +0 -1
- data/lib/tdriver/util/user_data/loader.rb +1 -2
- data/lib/tdriver/util/user_data/user_data.rb +6 -6
- data/lib/tdriver/util/video/camera.rb +67 -0
- data/lib/tdriver/util/video/camera_linux.rb +139 -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 +56 -5
- data/lib/tdriver/util/xml/builder.rb +2 -5
- data/lib/tdriver/util/{parameter.rb → xml/comment.rb} +10 -2
- data/lib/tdriver/util/xml/loader.rb +32 -22
- data/lib/tdriver/util/xml/nil_node.rb +2 -2
- data/lib/tdriver/util/xml/parsers/loader.rb +0 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +18 -44
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +9 -13
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +9 -3
- data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +6 -11
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +2 -122
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +26 -16
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +203 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +1 -2
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +2 -20
- data/lib/tdriver/util/xml/xml.rb +52 -20
- data/lib/tdriver/verify/verify.rb +238 -81
- data/xml/behaviours/generic.xml +12 -10
- metadata +156 -180
- data/lib/tdriver/base/test_object/factory_new.rb +0 -202
- data/lib/tdriver/util/hooking.rb +0 -434
- data/lib/tdriver/util/logger.rb +0 -506
- data/lib/tdriver/util/recorder.rb +0 -297
- data/lib/tdriver/util/video_utils.rb +0 -384
- data/lib/tdriver/util/xml/nil_element.rb +0 -89
@@ -162,56 +162,66 @@ module MobyBehaviour
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Disable logging
|
165
|
-
|
165
|
+
$logger.enabled = false if ( original_logger_state = $logger.enabled )
|
166
166
|
|
167
167
|
# verify close results
|
168
168
|
begin
|
169
169
|
|
170
|
+
application_identification_hash = { :type => 'application', :id => @id }
|
171
|
+
|
170
172
|
MobyUtil::Retryable.until(
|
171
|
-
:timeout =>
|
172
|
-
:interval =>
|
173
|
+
:timeout => $parameters[ self.sut.id ][ :application_synchronization_timeout, '60' ].to_f,
|
174
|
+
:interval => $parameters[ self.sut.id ][ :application_synchronization_retry_interval, '0.25' ].to_f,
|
173
175
|
:exception => MobyBase::VerificationError,
|
174
176
|
:unless => [MobyBase::TestObjectNotFoundError, MobyBase::ApplicationNotAvailableError] ) {
|
175
177
|
|
178
|
+
# raises MobyBase::ApplicationNotAvailableError if application was not found
|
179
|
+
@sut.refresh( application_identification_hash, [{:className=>"application", :tasId => @id }] )
|
180
|
+
|
181
|
+
# retrieve application object from sut.xml_data
|
182
|
+
matches, unused_rule = TDriver::TestObjectAdapter.get_objects( @sut.xml_data, application_identification_hash, true )
|
183
|
+
|
176
184
|
# check if the application is still found or not
|
177
|
-
if ( close_options[ :check_process ] == true
|
185
|
+
if ( close_options[ :check_process ] == true )
|
178
186
|
|
179
187
|
# the application did not close
|
180
|
-
raise MobyBase::VerificationError.new
|
181
|
-
|
188
|
+
raise MobyBase::VerificationError.new, "Verification of close failed. The application that was to be closed is still running." if matches.count > 0
|
189
|
+
|
182
190
|
elsif ( close_options[ :check_process ] == false )
|
183
191
|
|
184
|
-
|
185
|
-
|
186
|
-
|
192
|
+
if matches.count > 0
|
193
|
+
|
194
|
+
if TDriver::TestObjectAdapter.test_object_element_attribute( matches.first, 'id' ) == @id
|
187
195
|
|
188
|
-
|
196
|
+
# the application was still in the foreground
|
197
|
+
raise MobyBase::VerificationError, "Verification of close failed. The application that was to be closed was still in the foreground."
|
189
198
|
|
190
|
-
|
191
|
-
raise MobyBase::TestObjectNotFoundError.new( "The foreground application was not the one being closed (id: #{self.uid})." )
|
199
|
+
else
|
192
200
|
|
193
|
-
|
201
|
+
# The foreground application was not the one being closed.
|
202
|
+
raise MobyBase::TestObjectNotFoundError, "The foreground application was not the one being closed (id: #{ @id })."
|
194
203
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
break;
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
199
207
|
|
200
208
|
end
|
201
209
|
|
202
|
-
|
210
|
+
# The application could not be found, break
|
211
|
+
break
|
203
212
|
|
213
|
+
}
|
214
|
+
|
204
215
|
rescue MobyBase::TestObjectNotFoundError
|
205
216
|
|
206
217
|
# everything ok: application not running anymore
|
207
218
|
|
208
|
-
|
219
|
+
rescue MobyBase::ApplicationNotAvailableError
|
209
220
|
|
210
221
|
# everything ok: application not running anymore
|
211
222
|
|
212
223
|
rescue RuntimeError => e
|
213
224
|
|
214
|
-
|
215
225
|
unless ( e.message =~ /The application with Id \d+ is no longer available/ )
|
216
226
|
|
217
227
|
# something unexpected happened during the close, let exception through
|
@@ -222,20 +232,21 @@ module MobyBehaviour
|
|
222
232
|
ensure
|
223
233
|
|
224
234
|
# restore original state
|
225
|
-
|
235
|
+
$logger.enabled = original_logger_state
|
226
236
|
|
227
237
|
end
|
228
238
|
|
229
239
|
rescue Exception => exception
|
230
240
|
|
231
|
-
|
241
|
+
$logger.log "behaviour", "FAIL;Failed when closing.;#{ identity };close;"
|
232
242
|
Kernel::raise exception
|
233
243
|
|
234
244
|
end
|
235
245
|
|
236
|
-
|
246
|
+
$logger.log "behaviour", "PASS;Closed successfully.;#{ identity };close;"
|
237
247
|
|
238
|
-
|
248
|
+
#@sut.application
|
249
|
+
|
239
250
|
nil
|
240
251
|
|
241
252
|
end
|
@@ -317,8 +328,41 @@ module MobyBehaviour
|
|
317
328
|
|
318
329
|
end
|
319
330
|
|
331
|
+
|
332
|
+
# == description
|
333
|
+
# Bring the application to foreground.\n
|
334
|
+
# \n
|
335
|
+
# [b]NOTE:[/b] Currently this works only for Symbian OS target!
|
336
|
+
#
|
337
|
+
# == returns
|
338
|
+
# NilClass
|
339
|
+
# description: -
|
340
|
+
# example: -
|
341
|
+
#
|
342
|
+
#
|
343
|
+
def bring_to_foreground
|
344
|
+
@sut.execute_command(MobyCommand::Application.new(:BringToForeground, nil, self.uid, self.sut))
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
# == description
|
349
|
+
# Kills the application process
|
350
|
+
#
|
351
|
+
# == returns
|
352
|
+
# NilClass
|
353
|
+
# description: -
|
354
|
+
# example: -
|
355
|
+
#
|
356
|
+
def kill
|
357
|
+
|
358
|
+
@sut.execute_command( MobyCommand::Application.new( :Kill, self.executable_name, self.uid, self.sut, nil ) )
|
359
|
+
|
360
|
+
end
|
361
|
+
|
362
|
+
|
363
|
+
|
320
364
|
# enable hooking for performance measurement & debug logging
|
321
|
-
|
365
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
322
366
|
|
323
367
|
end # ApplicationBehaviour
|
324
368
|
|
@@ -60,7 +60,7 @@ module MobyBehaviour
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# enable hooking for performance measurement & debug logging
|
63
|
-
|
63
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
64
64
|
|
65
65
|
end # SutController
|
66
66
|
|
@@ -69,7 +69,7 @@ module MobyBehaviour
|
|
69
69
|
#
|
70
70
|
# == info
|
71
71
|
# Same as calling child method.
|
72
|
-
def find
|
72
|
+
def find( attributes = {} )
|
73
73
|
|
74
74
|
begin
|
75
75
|
|
@@ -83,19 +83,19 @@ module MobyBehaviour
|
|
83
83
|
|
84
84
|
rescue Exception => e
|
85
85
|
|
86
|
-
|
86
|
+
$logger.log "behaviour", "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << ( attributes.kind_of?( Hash ) ? attributes.inspect : attributes.class.to_s )
|
87
87
|
|
88
88
|
Kernel::raise e
|
89
89
|
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
$logger.log "behaviour", "PASS;Test object found.;#{id.to_s};sut;{};application;" << attributes.inspect
|
93
93
|
|
94
94
|
search_result
|
95
95
|
end
|
96
96
|
|
97
97
|
# enable hooking for performance measurement & debug logging
|
98
|
-
|
98
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
99
99
|
|
100
100
|
end # Find
|
101
101
|
|
@@ -214,7 +214,7 @@ module MobyBehaviour
|
|
214
214
|
result = start_flashing( flash_command )
|
215
215
|
|
216
216
|
Kernel::raise MobyBase::BehaviourError.new("flash_images", "Flashing failed") if result.to_s == 'false'
|
217
|
-
|
217
|
+
sleep parameter[:sleep_time_after_flash_command].to_i
|
218
218
|
end
|
219
219
|
|
220
220
|
private
|
@@ -270,7 +270,7 @@ module MobyBehaviour
|
|
270
270
|
end
|
271
271
|
flash_result=system(flash_command)
|
272
272
|
if flash_result.to_s=='true'
|
273
|
-
current_flash_attempt
|
273
|
+
current_flash_attempt=flash_attempts.to_i
|
274
274
|
else
|
275
275
|
flash_error_recovery
|
276
276
|
end
|
@@ -329,7 +329,7 @@ module MobyBehaviour
|
|
329
329
|
end
|
330
330
|
|
331
331
|
# enable hooking for performance measurement & debug logging
|
332
|
-
|
332
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
333
333
|
|
334
334
|
end
|
335
335
|
|
@@ -137,8 +137,21 @@ module MobyBehaviour
|
|
137
137
|
# example: -
|
138
138
|
def freeze
|
139
139
|
|
140
|
+
=begin
|
141
|
+
if $parameters[ @id ][ :use_find_object, 'false' ] == 'true' && self.respond_to?( 'find_object' )
|
142
|
+
|
143
|
+
warn("warning: SUT##{ __method__ } is not supported when use_find_objects optimization is enabled")
|
144
|
+
|
145
|
+
else
|
146
|
+
|
147
|
+
@frozen = true
|
148
|
+
|
149
|
+
end
|
150
|
+
=end
|
151
|
+
|
140
152
|
@frozen = true
|
141
153
|
|
154
|
+
|
142
155
|
nil
|
143
156
|
|
144
157
|
end
|
@@ -152,24 +165,25 @@ module MobyBehaviour
|
|
152
165
|
# example: -
|
153
166
|
def unfreeze
|
154
167
|
|
155
|
-
|
168
|
+
=begin
|
169
|
+
if $parameters[ @id ][ :use_find_object, 'false' ] == 'true' && self.respond_to?( 'find_object' )
|
156
170
|
|
157
|
-
|
171
|
+
warn("warning: SUT##{ __method__ } is not supported when use_find_objects optimization is enabled")
|
158
172
|
|
159
|
-
|
173
|
+
else
|
174
|
+
|
175
|
+
@frozen = false
|
160
176
|
|
161
|
-
|
162
|
-
|
163
|
-
# TODO: Still under construction. Should be able to create single descendant of the SUT
|
164
|
-
# Then is Should create path (parent-child-child-child...) until reaching the particular TestObject
|
165
|
-
# TODO: Document me when I'm ready
|
166
|
-
def get_object( object_id )
|
177
|
+
end
|
178
|
+
=end
|
167
179
|
|
168
|
-
|
180
|
+
@frozen = false
|
181
|
+
|
182
|
+
nil
|
169
183
|
|
170
184
|
end
|
171
185
|
|
172
|
-
# == nodoc
|
186
|
+
# == nodoc
|
173
187
|
# == description
|
174
188
|
# Force to use user defined ui state (e.g. for debugging purposes). Freezes the SUT xml_data, until unfreezed or set to nil.
|
175
189
|
#
|
@@ -201,16 +215,19 @@ module MobyBehaviour
|
|
201
215
|
|
202
216
|
@xml_data = xml
|
203
217
|
@frozen = true
|
218
|
+
@forced_xml = true
|
204
219
|
|
205
220
|
elsif xml.kind_of?( String )
|
206
221
|
|
207
222
|
@xml_data = MobyUtil::XML.parse_string( xml ).root
|
208
223
|
@frozen = true
|
224
|
+
@forced_xml = true
|
209
225
|
|
210
226
|
elsif xml.kind_of?( NilClass )
|
211
227
|
|
212
228
|
@xml_data = nil
|
213
229
|
@frozen = false
|
230
|
+
@forced_xml = false
|
214
231
|
|
215
232
|
end
|
216
233
|
|
@@ -218,69 +235,6 @@ module MobyBehaviour
|
|
218
235
|
|
219
236
|
end
|
220
237
|
|
221
|
-
# == nodoc
|
222
|
-
# Function asks for fresh xml ui data from the device and stores the result
|
223
|
-
# == returns
|
224
|
-
# MobyUtil::XML::Element:: xml document containing valid xml fragment describing the current state of the device
|
225
|
-
def refresh_ui_dump( refresh_args = {}, creation_attributes = [] )
|
226
|
-
|
227
|
-
current_time = Time.now
|
228
|
-
|
229
|
-
if !@frozen #&& ( @_previous_refresh.nil? || ( current_time - @_previous_refresh ).to_f > @refresh_interval )
|
230
|
-
|
231
|
-
MobyUtil::Retryable.while(
|
232
|
-
:tries => @refresh_tries,
|
233
|
-
:interval => @refresh_interval,
|
234
|
-
:unless => [ MobyBase::ControllerNotFoundError, MobyBase::CommandNotFoundError, MobyBase::ApplicationNotAvailableError ]
|
235
|
-
) {
|
236
|
-
|
237
|
-
#use find_object if set on and the method exists
|
238
|
-
if MobyUtil::Parameter[ @id ][ :use_find_object, 'false' ] == 'true' and self.respond_to?('find_object') # self.methods.include?('find_object')
|
239
|
-
|
240
|
-
new_xml_data, crc = find_object( refresh_args.clone, creation_attributes )
|
241
|
-
|
242
|
-
else
|
243
|
-
|
244
|
-
app_command = MobyCommand::Application.new(
|
245
|
-
:State,
|
246
|
-
refresh_args[ :FullName ] || refresh_args[ :name ],
|
247
|
-
refresh_args[ :id ],
|
248
|
-
self
|
249
|
-
)
|
250
|
-
|
251
|
-
#store in case needed
|
252
|
-
app_command.refresh_args( refresh_args )
|
253
|
-
|
254
|
-
new_xml_data, crc = execute_command( app_command )
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
# remove timestamp from the beginning of tasMessage, parse if not same as previous ui state
|
259
|
-
#if ( xml_data_no_timestamp = new_xml_data.split( ">", 2 ).last ) != @last_xml_data
|
260
|
-
|
261
|
-
@xml_data, @childs_updated = MobyUtil::XML.parse_string( new_xml_data ).root, false
|
262
|
-
|
263
|
-
#@last_xml_data = xml_data_no_timestamp
|
264
|
-
|
265
|
-
#end
|
266
|
-
|
267
|
-
#if ( @xml_data_crc == 0 || crc != @xml_data_crc || crc.nil? )
|
268
|
-
# @xml_data, @xml_data_crc, @childs_updated = MobyUtil::XML.parse_string( new_xml_data ).root, crc, false
|
269
|
-
#end
|
270
|
-
|
271
|
-
@dump_count += 1
|
272
|
-
|
273
|
-
@_previous_refresh = current_time
|
274
|
-
|
275
|
-
}
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
@xml_data = fetch_references( @xml_data )
|
280
|
-
|
281
|
-
@xml_data
|
282
|
-
|
283
|
-
end
|
284
238
|
|
285
239
|
# TODO: merge TestObject#child and SUT#child
|
286
240
|
# == description
|
@@ -307,7 +261,7 @@ module MobyBehaviour
|
|
307
261
|
#
|
308
262
|
# NOTICE: Please do not add anything unnessecery to this method, it might cause a major performance impact
|
309
263
|
#
|
310
|
-
|
264
|
+
|
311
265
|
# verify attributes argument format
|
312
266
|
attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
|
313
267
|
|
@@ -326,7 +280,7 @@ module MobyBehaviour
|
|
326
280
|
) if identification_directives.has_key?( :__logging )
|
327
281
|
|
328
282
|
# disable logging if requested, remove pair from creation_hash
|
329
|
-
|
283
|
+
$logger.push_enabled( identification_directives[ :__logging ] || TDriver.logger.enabled )
|
330
284
|
|
331
285
|
begin
|
332
286
|
|
@@ -335,7 +289,7 @@ module MobyBehaviour
|
|
335
289
|
|
336
290
|
# current object as parent, can be either TestObject or SUT
|
337
291
|
:parent => self,
|
338
|
-
|
292
|
+
|
339
293
|
# test object identification hash
|
340
294
|
:object_attributes_hash => creation_hash,
|
341
295
|
|
@@ -345,26 +299,26 @@ module MobyBehaviour
|
|
345
299
|
|
346
300
|
rescue MobyBase::MultipleTestObjectsIdentifiedError => exception
|
347
301
|
|
348
|
-
|
302
|
+
TDriver.logger.behaviour "FAIL;Multiple child objects matched criteria.;#{ id };sut;{};child;#{ attributes.inspect }"
|
349
303
|
|
350
304
|
Kernel::raise exception
|
351
305
|
|
352
306
|
rescue MobyBase::TestObjectNotFoundError => exception
|
353
307
|
|
354
|
-
|
308
|
+
TDriver.logger.behaviour "FAIL;The child object could not be found.;#{ id };sut;{};child;#{ attributes.inspect }"
|
355
309
|
|
356
310
|
Kernel::raise exception
|
357
311
|
|
358
312
|
rescue Exception => exception
|
359
313
|
|
360
|
-
|
314
|
+
TDriver.logger.behaviour "FAIL;Failed when trying to find child object.;#{ id };sut;{};child;#{ attributes.inspect }"
|
361
315
|
|
362
316
|
Kernel::raise exception
|
363
317
|
|
364
318
|
ensure
|
365
319
|
|
366
320
|
# restore original logger state
|
367
|
-
|
321
|
+
$logger.pop_enabled
|
368
322
|
|
369
323
|
end
|
370
324
|
|
@@ -386,16 +340,11 @@ module MobyBehaviour
|
|
386
340
|
def state
|
387
341
|
|
388
342
|
# refresh if xml data is empty
|
389
|
-
self.refresh
|
343
|
+
self.refresh if @xml_data.empty?
|
390
344
|
|
391
|
-
Kernel::raise RuntimeError
|
345
|
+
Kernel::raise RuntimeError, "Can not create state object of SUT with id #{ @id.inspect }, no XML content or SUT not initialized properly." if @xml_data.empty?
|
392
346
|
|
393
|
-
MobyBase::StateObject.new(
|
394
|
-
MobyUtil::XML.parse_string(
|
395
|
-
"<sut name='sut' type='sut' id='%s'><objects>%s</objects></sut>" % [ @id, xml_data.xpath("tasInfo/object").collect{ | element | element.to_s }.join ]
|
396
|
-
).root,
|
397
|
-
self
|
398
|
-
)
|
347
|
+
MobyBase::StateObject.new( TDriver::TestObjectAdapter.state_object_xml( @xml_data, @id ), self )
|
399
348
|
|
400
349
|
end
|
401
350
|
|
@@ -420,27 +369,37 @@ module MobyBehaviour
|
|
420
369
|
def application( attributes = {} )
|
421
370
|
|
422
371
|
begin
|
423
|
-
|
372
|
+
|
424
373
|
attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
|
425
374
|
|
426
|
-
get_default_app = attributes.empty?
|
427
|
-
|
428
375
|
attributes[ :type ] = 'application'
|
429
376
|
|
430
|
-
|
377
|
+
attributes[ :__parent_application ] = nil
|
431
378
|
|
432
|
-
|
379
|
+
@current_application_id = nil if attributes[ :id ].nil?
|
433
380
|
|
434
|
-
|
381
|
+
# create test object and return it as result
|
382
|
+
test_object = child( attributes )
|
435
383
|
|
436
|
-
|
437
|
-
|
384
|
+
# store parent application to test object
|
385
|
+
test_object.instance_variable_set( :@parent_application, test_object )
|
438
386
|
|
439
|
-
|
387
|
+
test_object
|
388
|
+
|
389
|
+
rescue
|
390
|
+
|
391
|
+
TDriver.logger.behaviour(
|
392
|
+
"FAIL;Failed to find application.;#{ id.to_s };sut;{};application;#{ attributes.kind_of?( Hash ) ? attributes.inspect : attributes.class.to_s }"
|
393
|
+
)
|
440
394
|
|
441
|
-
|
395
|
+
# raise same exception
|
396
|
+
Kernel::raise $!
|
442
397
|
|
443
|
-
|
398
|
+
ensure
|
399
|
+
|
400
|
+
TDriver.logger.behaviour "PASS;Application found.;#{ id.to_s };sut;{};application;#{ attributes.inspect }" if $!.nil?
|
401
|
+
|
402
|
+
end
|
444
403
|
|
445
404
|
end
|
446
405
|
|
@@ -509,15 +468,15 @@ module MobyBehaviour
|
|
509
468
|
|
510
469
|
}
|
511
470
|
|
512
|
-
rescue
|
471
|
+
rescue
|
513
472
|
|
514
|
-
|
473
|
+
TDriver.logger.behaviour "FAIL;Failed to capture screen.;#{ id.to_s };sut;{};capture_screen;#{ arguments.kind_of?( Hash ) ? arguments.inspect : arguments.class.to_s }"
|
515
474
|
|
516
|
-
Kernel::raise
|
475
|
+
Kernel::raise $!
|
517
476
|
|
518
477
|
end
|
519
478
|
|
520
|
-
|
479
|
+
TDriver.logger.behaviour "PASS;Screen was captured successfully.;#{ id.to_s };sut;{};capture_screen;#{ arguments.inspect }"
|
521
480
|
|
522
481
|
nil
|
523
482
|
|
@@ -540,7 +499,13 @@ module MobyBehaviour
|
|
540
499
|
# |Key|Type|Description|Example|
|
541
500
|
# |:uid|String or Integer|Unique ID of the application|{ :uid => 268458181 }|
|
542
501
|
# |:name|String|Executable name of the application|{ :name => 'calculator' }|
|
543
|
-
# |:arguments|String|Comma separated list of arguments passed to application when
|
502
|
+
# |:arguments|String|Comma separated list of arguments passed to the application when it is started|{ :arguments => '--nogui,-v' }|
|
503
|
+
# |:sleep_time|Integer|Number of seconds to sleep immediately after launching the process|{ :sleep_time => 10 }|
|
504
|
+
# |:start_command|String|When set, the run method will execute this command and expect the application provided by the :name key to be launched eventually. Note that applications launched this way can't be sent a Kill message and its start up events and signals may not be recorded.|{ :start_command => 'start_app.bat',:name => 'calculator' }|
|
505
|
+
# |:try_attach|Boolean|If set to true, run will attempt to attach to an existing application with the given name or id. If not found the application will be launched as normal. If more than 1 are found then an exception is thrown|{:try_attach => true,:name => 'calculator'}|
|
506
|
+
# |:environment|String|Environment variables you want to pass to started process, passed as key value pairs separated by '=' and pairs separated by spaces |{ :environment => 'LC_ALL=en SPECIAL_VAR=value' }|
|
507
|
+
# |:events_to_listen|String|List of events you want to start listening to when application starts, passed as comma separated string. You can retrieve a list of events fired by a test object by first enabling event listening and then using the get_events method. See methods enable_events, get_events and disable_events |{ :events_to_listen => 'Paint,Show' }|
|
508
|
+
# |:signals_to_listen|String|List of signals you want to start listening to when application starts, passed as comma separated string. Check your application class what signals it can emit, or you can use the 'signal' fixture's 'list_signal' method to retrieve an xml string listing all the signals the object can emit. E.g. xml = @object.fixture('signal', 'list_signals')|{ :signals_to_listen => 'applicationReady()' }|
|
544
509
|
#
|
545
510
|
# == returns
|
546
511
|
# TestObject
|
@@ -562,8 +527,8 @@ module MobyBehaviour
|
|
562
527
|
begin
|
563
528
|
|
564
529
|
# set the refresh interval to zero while the application is launched
|
565
|
-
#orig_interval =
|
566
|
-
|
530
|
+
#orig_interval = $parameters[ @id ][ :refresh_interval ]
|
531
|
+
#$parameters[ @id ][ :refresh_interval ] = '0'
|
567
532
|
|
568
533
|
# raise exception if argument type other than hash
|
569
534
|
target.check_type( Hash, "Wrong argument type $1 for run method (expected $2)" )
|
@@ -576,7 +541,7 @@ module MobyBehaviour
|
|
576
541
|
|
577
542
|
sleep_time = target[ :sleep_after_launch ].to_i
|
578
543
|
|
579
|
-
Kernel::raise ArgumentError
|
544
|
+
Kernel::raise ArgumentError, "Sleep time need to be >= 0" unless sleep_time >= 0
|
580
545
|
|
581
546
|
# try to find an existing app with the current arguments
|
582
547
|
if target[ :try_attach ]
|
@@ -589,6 +554,7 @@ module MobyBehaviour
|
|
589
554
|
|
590
555
|
app_info = find_app(app_list, {:id => target[ :uid ]}) if target[ :uid ] != nil
|
591
556
|
app_info = find_app(app_list, {:name => target[ :name ]}) unless app_info
|
557
|
+
|
592
558
|
app = self.application(:id => app_info.id) if app_info
|
593
559
|
|
594
560
|
if app
|
@@ -599,7 +565,7 @@ module MobyBehaviour
|
|
599
565
|
|
600
566
|
rescue Exception => e
|
601
567
|
|
602
|
-
|
568
|
+
TDriver.logger.warning "Could not bring app to foreground"
|
603
569
|
|
604
570
|
end
|
605
571
|
|
@@ -678,32 +644,65 @@ module MobyBehaviour
|
|
678
644
|
|
679
645
|
begin
|
680
646
|
|
647
|
+
# verify that application is launched and application test object is found from xml
|
681
648
|
self.wait_child(
|
649
|
+
|
650
|
+
# attributes to identify application object
|
682
651
|
expected_attributes,
|
683
|
-
|
684
|
-
|
652
|
+
|
653
|
+
# timeout to for application synchronization
|
654
|
+
$parameters[ @id ][ :application_synchronization_timeout, '5' ].to_f,
|
655
|
+
|
656
|
+
# wait retry interval and try again if application was not found
|
657
|
+
$parameters[ @id ][ :application_synchronization_retry_interval, '0.5' ].to_f
|
658
|
+
|
685
659
|
)
|
686
660
|
|
687
|
-
|
661
|
+
# retrieve application object element from sut.xml_data
|
662
|
+
matches, unused_rule = TDriver::TestObjectAdapter.get_objects( xml_data, expected_attributes, true )
|
688
663
|
|
689
|
-
|
664
|
+
# raise exception if application element was not found; this shouldn't ever happen?
|
665
|
+
#raise MobyBase::TestObjectNotFoundError if matches.count == 0
|
690
666
|
|
691
|
-
|
667
|
+
# create application test object
|
668
|
+
foreground_app = @test_object_factory.make_test_object(
|
669
|
+
|
670
|
+
:parent => self,
|
671
|
+
|
672
|
+
:parent_application => nil,
|
673
|
+
|
674
|
+
:object_attributes_hash => expected_attributes,
|
675
|
+
|
676
|
+
:xml_object => matches.first
|
692
677
|
|
693
|
-
|
694
|
-
|
678
|
+
)
|
679
|
+
|
680
|
+
# store application reference to test application; this will be passed to it's child test object(s)
|
681
|
+
foreground_app.instance_variable_set( :@parent_application, foreground_app )
|
695
682
|
|
696
|
-
|
683
|
+
# application was not found; this scenario shouldn't ever happen?
|
684
|
+
#raise MobyBase::TestObjectNotFoundError unless foreground_app.kind_of?( MobyBehaviour::Application )
|
697
685
|
|
698
|
-
|
686
|
+
rescue MobyBase::TestObjectNotFoundError
|
699
687
|
|
700
|
-
|
688
|
+
Kernel::raise MobyBase::VerificationError, "No application type test object was found on the device after starting the application."
|
689
|
+
|
690
|
+
rescue MobyBase::SyncTimeoutError
|
691
|
+
|
692
|
+
Kernel::raise MobyBase::VerificationError, "The application (#{ error_details }) was not found on the sut after being launched."
|
693
|
+
|
694
|
+
end
|
695
|
+
|
696
|
+
# raise behaviour error if any exception is raised
|
697
|
+
rescue # Exception => e
|
698
|
+
|
699
|
+
TDriver.logger.behaviour "FAIL;Failed to launch application.;#{ id.to_s };sut;{};run;#{ target.kind_of?( Hash ) ? target.inspect : target.class.to_s }"
|
701
700
|
|
702
701
|
Kernel::raise MobyBase::BehaviourError.new("Run", "Failed to launch application")
|
703
702
|
|
704
703
|
end
|
705
704
|
|
706
|
-
|
705
|
+
TDriver.logger.behaviour "PASS;The application was launched successfully.;#{ id.to_s };sut;{};run;#{ target.inspect }"
|
707
706
|
|
708
707
|
foreground_app
|
709
708
|
|
@@ -763,14 +762,15 @@ module MobyBehaviour
|
|
763
762
|
|
764
763
|
execute_command( sequence )
|
765
764
|
|
766
|
-
rescue
|
765
|
+
rescue
|
766
|
+
|
767
|
+
TDriver.logger.behaviour "FAIL;Failed to press key(s).;#{id.to_s};sut;{};press_key;#{ value }"
|
767
768
|
|
768
|
-
|
769
|
-
Kernel::raise e
|
769
|
+
Kernel::raise $!
|
770
770
|
|
771
771
|
end
|
772
772
|
|
773
|
-
|
773
|
+
TDriver.logger.behaviour "PASS;Successfully pressed key(s).;#{ id.to_s };sut;{};press_key;#{ value }"
|
774
774
|
|
775
775
|
nil
|
776
776
|
|
@@ -782,7 +782,7 @@ module MobyBehaviour
|
|
782
782
|
#
|
783
783
|
# == arguments
|
784
784
|
# *arguments
|
785
|
-
#
|
785
|
+
# String
|
786
786
|
# description: Optional argument which is the name of parameter.
|
787
787
|
# example: 'new_parameter'
|
788
788
|
# Symbol
|
@@ -812,13 +812,13 @@ module MobyBehaviour
|
|
812
812
|
|
813
813
|
if ( arguments.count == 0 )
|
814
814
|
|
815
|
-
MobyUtil::ParameterUserAPI
|
815
|
+
MobyUtil::ParameterUserAPI[ @id ]
|
816
816
|
|
817
817
|
else
|
818
818
|
|
819
819
|
#$stderr.puts "%s:%s warning: deprecated method usage convention, please use sut#parameter[] instead of sut#parameter()" % ( caller.first || "%s:%s" % [ __FILE__, __LINE__ ] ).split(":")[ 0..1 ]
|
820
820
|
|
821
|
-
MobyUtil::ParameterUserAPI
|
821
|
+
MobyUtil::ParameterUserAPI[ @id ][ *arguments ]
|
822
822
|
|
823
823
|
end
|
824
824
|
|
@@ -885,62 +885,144 @@ module MobyBehaviour
|
|
885
885
|
# description: In case there are problems with the database connectivity
|
886
886
|
#
|
887
887
|
def translate( logical_name, file_name = nil, plurality = nil, numerus = nil, lengthvariant = nil )
|
888
|
-
|
888
|
+
|
889
|
+
Kernel::raise LogicalNameNotFoundError, "Logical name is nil" if logical_name.nil?
|
890
|
+
|
889
891
|
translation_type = "localisation"
|
890
892
|
|
891
893
|
# Check for User Information prefix( "uif_...")
|
892
|
-
|
894
|
+
$parameters[ :user_data_logical_string_identifier, 'uif_' ].split('|').each do |identifier|
|
895
|
+
|
893
896
|
if logical_name.to_s.index(identifier)==0
|
897
|
+
|
894
898
|
translation_type="user_data"
|
899
|
+
|
895
900
|
end
|
901
|
+
|
896
902
|
end
|
897
903
|
|
898
904
|
# Check for Operator Data prefix( "operator_...")
|
899
|
-
|
905
|
+
$parameters[ :operator_data_logical_string_identifier, 'operator_' ].split('|').each do |identifier|
|
906
|
+
|
900
907
|
if logical_name.to_s.index(identifier)==0
|
908
|
+
|
901
909
|
translation_type="operator_data"
|
910
|
+
|
902
911
|
end
|
912
|
+
|
903
913
|
end
|
904
914
|
|
905
915
|
case translation_type
|
916
|
+
|
906
917
|
when "user_data"
|
918
|
+
|
907
919
|
get_user_information( logical_name )
|
908
920
|
|
909
921
|
when "operator_data"
|
922
|
+
|
910
923
|
get_operator_data( logical_name )
|
911
924
|
|
912
925
|
when "localisation"
|
926
|
+
|
913
927
|
language=nil
|
914
|
-
|
928
|
+
|
929
|
+
if ( $parameters[ self.id ][:read_lang_from_app]=='true')
|
930
|
+
|
915
931
|
#read localeName app
|
916
932
|
language=self.application.attribute("localeName")
|
933
|
+
|
917
934
|
#determine the language from the locale
|
918
935
|
language=language.split('_')[0].to_s if (language!=nil && !language.empty?)
|
936
|
+
|
919
937
|
else
|
920
|
-
|
938
|
+
|
939
|
+
language=$parameters[ self.id ][ :language ]
|
940
|
+
|
921
941
|
end
|
922
|
-
|
923
|
-
translation
|
924
|
-
|
942
|
+
|
943
|
+
Kernel::raise LanguageNotFoundError, "Language cannot be determind to perform translation" if ( language.nil? || language.empty? )
|
944
|
+
|
945
|
+
translation = MobyUtil::Localisation.translation(
|
946
|
+
logical_name,
|
947
|
+
language,
|
948
|
+
$parameters[ self.id ][ :localisation_server_database_tablename ],
|
949
|
+
file_name,
|
950
|
+
plurality,
|
951
|
+
lengthvariant
|
952
|
+
)
|
953
|
+
|
925
954
|
if translation.kind_of? String and !numerus.nil?
|
955
|
+
|
926
956
|
if numerus.kind_of? Array
|
957
|
+
|
927
958
|
translation.gsub!(/%[L]?(\d)/){|s| numerus[($1.to_i) -1] }
|
959
|
+
|
928
960
|
elsif numerus.kind_of? String or numerus.kind_of? Integer
|
961
|
+
|
929
962
|
translation.gsub!(/%(Ln|1)/){|s| numerus.to_s}
|
963
|
+
|
930
964
|
end
|
965
|
+
|
931
966
|
elsif translation.kind_of? Array and !numerus.nil?
|
967
|
+
|
932
968
|
translation.each do |trans|
|
969
|
+
|
933
970
|
if numerus.kind_of? Array
|
971
|
+
|
934
972
|
trans.gsub!(/%[L]?(\d)/){|s| numerus[($1.to_i) -1] }
|
973
|
+
|
935
974
|
elsif numerus.kind_of? String or numerus.kind_of? Integer
|
975
|
+
|
936
976
|
trans.gsub!(/%(Ln|1)/){|s| numerus.to_s}
|
977
|
+
|
937
978
|
end
|
979
|
+
|
938
980
|
end
|
981
|
+
|
939
982
|
end
|
983
|
+
|
940
984
|
translation
|
985
|
+
|
941
986
|
end
|
987
|
+
|
942
988
|
end
|
943
989
|
|
990
|
+
# == nodoc
|
991
|
+
# == description
|
992
|
+
# Translates all symbol values in hash using SUT's translate method.
|
993
|
+
#
|
994
|
+
# == arguments
|
995
|
+
# hash
|
996
|
+
# Hash
|
997
|
+
# description: containing key and value pairs. The hash will get modified if symbols are found from values
|
998
|
+
# example: {:text=>:translate_me}
|
999
|
+
#
|
1000
|
+
# == returns
|
1001
|
+
# Hash
|
1002
|
+
# description: Translated hash
|
1003
|
+
# example: {:text=>'translated_text'}
|
1004
|
+
# == exceptions
|
1005
|
+
# LanguageNotFoundError
|
1006
|
+
# description: In case of language is not found
|
1007
|
+
#
|
1008
|
+
# LogicalNameNotFoundError
|
1009
|
+
# description: In case of logical name is not found for current language
|
1010
|
+
#
|
1011
|
+
# MySqlConnectError
|
1012
|
+
# description: In case problems with the db connectivity
|
1013
|
+
#
|
1014
|
+
def translate_values!( hash, file_name = nil, plurality = nil, numerus = nil, lengthvariant = nil )
|
1015
|
+
|
1016
|
+
hash.each_pair do | _key, _value |
|
1017
|
+
|
1018
|
+
next if [ :name, :type, :id ].include?( _key )
|
1019
|
+
|
1020
|
+
hash[ _key ] = translate( _value, file_name, plurality, numerus, lengthvariant ) if _value.kind_of?( Symbol )
|
1021
|
+
|
1022
|
+
end unless hash.nil?
|
1023
|
+
|
1024
|
+
end
|
1025
|
+
|
944
1026
|
# == description
|
945
1027
|
# Wrapper function to retrieve user information for this SUT from the user information database.
|
946
1028
|
#
|
@@ -972,9 +1054,19 @@ module MobyBehaviour
|
|
972
1054
|
# description: In case there are problems with the database connectivity
|
973
1055
|
#
|
974
1056
|
def get_user_information( user_data_lname )
|
975
|
-
|
976
|
-
|
977
|
-
|
1057
|
+
|
1058
|
+
MobyUtil::UserData.retrieve(
|
1059
|
+
|
1060
|
+
user_data_lname,
|
1061
|
+
|
1062
|
+
# language
|
1063
|
+
$parameters[ self.id ][ :language ],
|
1064
|
+
|
1065
|
+
# table name
|
1066
|
+
$parameters[ self.id ][ :user_data_server_database_tablename ]
|
1067
|
+
|
1068
|
+
)
|
1069
|
+
|
978
1070
|
end
|
979
1071
|
|
980
1072
|
# == description
|
@@ -1005,9 +1097,19 @@ module MobyBehaviour
|
|
1005
1097
|
# description: In case there are problems with the database connectivity
|
1006
1098
|
#
|
1007
1099
|
def get_operator_data( operator_data_lname )
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1100
|
+
|
1101
|
+
MobyUtil::OperatorData.retrieve(
|
1102
|
+
|
1103
|
+
operator_data_lname,
|
1104
|
+
|
1105
|
+
# operator
|
1106
|
+
$parameters[ self.id ][ :operator_selected ],
|
1107
|
+
|
1108
|
+
# table name
|
1109
|
+
$parameters[ self.id ][ :operator_data_server_database_tablename ]
|
1110
|
+
|
1111
|
+
)
|
1112
|
+
|
1011
1113
|
end
|
1012
1114
|
|
1013
1115
|
# == nodoc
|
@@ -1025,7 +1127,9 @@ module MobyBehaviour
|
|
1025
1127
|
|
1026
1128
|
@child_object_cache.each_object{ | test_object |
|
1027
1129
|
|
1028
|
-
test_object.
|
1130
|
+
test_object.send( :update, @xml_data )
|
1131
|
+
|
1132
|
+
#test_object.update( @xml_data )
|
1029
1133
|
|
1030
1134
|
}
|
1031
1135
|
|
@@ -1036,12 +1140,12 @@ module MobyBehaviour
|
|
1036
1140
|
end
|
1037
1141
|
|
1038
1142
|
# == nodoc
|
1039
|
-
def refresh( refresh_args = {}, creation_attributes = {})
|
1040
|
-
|
1041
|
-
refresh_ui_dump refresh_args, creation_attributes
|
1143
|
+
def refresh( refresh_args = {}, creation_attributes = {} )
|
1144
|
+
|
1145
|
+
refresh_ui_dump( refresh_args, creation_attributes )
|
1042
1146
|
|
1043
1147
|
# update childs only if ui state is new
|
1044
|
-
|
1148
|
+
update_childs
|
1045
1149
|
|
1046
1150
|
end
|
1047
1151
|
|
@@ -1103,33 +1207,102 @@ module MobyBehaviour
|
|
1103
1207
|
|
1104
1208
|
# == nodoc
|
1105
1209
|
def get_application_id
|
1210
|
+
|
1211
|
+
# retrieve application object from sut.xml_data
|
1212
|
+
matches, unused_rule = TDriver::TestObjectAdapter.get_objects( xml_data, { :type => 'application' }, true )
|
1213
|
+
|
1214
|
+
# retrieve id attribute if application test object found
|
1215
|
+
if matches.count > 0
|
1216
|
+
|
1217
|
+
# return id attribute value
|
1218
|
+
TDriver::TestObjectAdapter.test_object_element_attribute( matches.first, 'id' )
|
1219
|
+
|
1220
|
+
else
|
1106
1221
|
|
1107
|
-
|
1222
|
+
# application not found
|
1223
|
+
'-1'
|
1224
|
+
|
1225
|
+
end
|
1108
1226
|
|
1109
|
-
|
1227
|
+
end
|
1110
1228
|
|
1111
|
-
|
1229
|
+
private
|
1112
1230
|
|
1113
|
-
|
1231
|
+
# TODO: document me
|
1232
|
+
def update_childs
|
1233
|
+
|
1234
|
+
# update childs only if ui state is new
|
1235
|
+
update if !@childs_updated
|
1236
|
+
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
# == nodoc
|
1240
|
+
# Function asks for fresh xml ui data from the device and stores the result
|
1241
|
+
# == returns
|
1242
|
+
# MobyUtil::XML::Element:: xml document containing valid xml fragment describing the current state of the device
|
1243
|
+
def refresh_ui_dump( refresh_args = {}, creation_attributes = [] )
|
1114
1244
|
|
1115
|
-
|
1245
|
+
current_time = Time.now
|
1246
|
+
|
1247
|
+
if !@frozen #&& ( @_previous_refresh.nil? || ( current_time - @_previous_refresh ).to_f >= @refresh_interval )
|
1248
|
+
|
1249
|
+
use_find_objects = $parameters[ @id ][ :use_find_object, 'false' ] == 'true' and self.respond_to?( 'find_object' )
|
1116
1250
|
|
1117
|
-
|
1251
|
+
refresh_arguments = refresh_args.clone
|
1118
1252
|
|
1119
|
-
|
1253
|
+
MobyUtil::Retryable.while(
|
1254
|
+
:tries => @refresh_tries,
|
1255
|
+
:interval => @refresh_interval,
|
1256
|
+
:unless => [ MobyBase::ControllerNotFoundError, MobyBase::CommandNotFoundError, MobyBase::ApplicationNotAvailableError ]
|
1257
|
+
) {
|
1120
1258
|
|
1121
|
-
|
1259
|
+
#use find_object if set on and the method exists
|
1260
|
+
if use_find_objects
|
1122
1261
|
|
1123
|
-
|
1262
|
+
new_xml_data, crc = find_object( refresh_arguments, creation_attributes )
|
1263
|
+
|
1264
|
+
else
|
1265
|
+
|
1266
|
+
app_command = MobyCommand::Application.new(
|
1267
|
+
:State,
|
1268
|
+
refresh_args[ :FullName ] || refresh_args[ :name ],
|
1269
|
+
refresh_args[ :id ],
|
1270
|
+
self
|
1271
|
+
)
|
1272
|
+
|
1273
|
+
# store in case needed
|
1274
|
+
app_command.refresh_args( refresh_args )
|
1275
|
+
|
1276
|
+
new_xml_data, crc = execute_command( app_command )
|
1277
|
+
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
@dump_count += 1
|
1281
|
+
|
1282
|
+
@childs_updated = false
|
1283
|
+
|
1284
|
+
@xml_data = MobyUtil::XML.parse_string( new_xml_data ).root
|
1285
|
+
|
1286
|
+
@_previous_refresh = Time.now
|
1287
|
+
|
1288
|
+
# remove timestamp from the beginning of tasMessage, parse if not same as previous ui state
|
1289
|
+
#if ( xml_data_no_timestamp = new_xml_data.split( ">", 2 ).last ) != @last_xml_data
|
1290
|
+
# @xml_data = MobyUtil::XML.parse_string( new_xml_data ).root
|
1291
|
+
# @last_xml_data = xml_data_no_timestamp
|
1292
|
+
#end
|
1293
|
+
|
1294
|
+
#if ( @xml_data_crc == 0 || crc != @xml_data_crc || crc.nil? )
|
1295
|
+
# @xml_data, @xml_data_crc, @childs_updated = MobyUtil::XML.parse_string( new_xml_data ).root, crc, false
|
1296
|
+
#end
|
1297
|
+
|
1298
|
+
}
|
1124
1299
|
|
1125
1300
|
end
|
1126
|
-
|
1127
|
-
'-1'
|
1128
1301
|
|
1302
|
+
fetch_references( @xml_data )
|
1303
|
+
|
1129
1304
|
end
|
1130
1305
|
|
1131
|
-
private
|
1132
|
-
|
1133
1306
|
# TODO: document me
|
1134
1307
|
def fetch_references( xml )
|
1135
1308
|
|
@@ -1289,19 +1462,19 @@ module MobyBehaviour
|
|
1289
1462
|
@childs_updated = false
|
1290
1463
|
|
1291
1464
|
# id not found from parameters
|
1292
|
-
if
|
1465
|
+
if $parameters[ @id, nil ] != nil
|
1293
1466
|
|
1294
|
-
@input =
|
1467
|
+
@input = $parameters[ @id ][ :input_type, "key" ].to_sym
|
1295
1468
|
|
1296
|
-
@refresh_tries =
|
1469
|
+
@refresh_tries = $parameters[ @id ][ :ui_state_refresh_tries, @refresh_tries ].to_f
|
1297
1470
|
|
1298
|
-
@refresh_interval =
|
1471
|
+
@refresh_interval = $parameters[ @id ][ :refresh_interval, @refresh_interval ].to_f
|
1299
1472
|
|
1300
1473
|
end
|
1301
1474
|
|
1302
1475
|
@last_xml_data = nil
|
1303
1476
|
|
1304
|
-
ruby_file =
|
1477
|
+
ruby_file = $parameters[ @id ][ :verify_blocks ]
|
1305
1478
|
|
1306
1479
|
@verify_blocks = []
|
1307
1480
|
|
@@ -1322,6 +1495,18 @@ module MobyBehaviour
|
|
1322
1495
|
|
1323
1496
|
public # deprecated
|
1324
1497
|
|
1498
|
+
# == nodoc
|
1499
|
+
# function to get TestObject
|
1500
|
+
# TODO: Still under construction. Should be able to create single descendant of the SUT
|
1501
|
+
# Then is Should create path (parent-child-child-child...) until reaching the particular TestObject
|
1502
|
+
# TODO: Document me when I'm ready
|
1503
|
+
def get_object( object_id )
|
1504
|
+
|
1505
|
+
warn("deprecated: use SUT#child instead of SUT#get_object in order to retrieve child test objects")
|
1506
|
+
|
1507
|
+
child( object_id )
|
1508
|
+
|
1509
|
+
end
|
1325
1510
|
|
1326
1511
|
# == nodoc
|
1327
1512
|
#TODO: Update documentation
|
@@ -1341,7 +1526,7 @@ module MobyBehaviour
|
|
1341
1526
|
end
|
1342
1527
|
|
1343
1528
|
# enable hooking for performance measurement & debug logging
|
1344
|
-
|
1529
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
1345
1530
|
|
1346
1531
|
end # SUT
|
1347
1532
|
|