testability-driver 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/ext/native_extensions.c +53 -25
  2. data/lib/matti.rb +0 -5
  3. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +4 -4
  4. data/lib/tdriver/base/behaviour/factory.rb +120 -7
  5. data/lib/tdriver/base/errors.rb +1 -1
  6. data/lib/tdriver/base/state_object.rb +3 -2
  7. data/lib/tdriver/base/sut/controller.rb +2 -2
  8. data/lib/tdriver/base/sut/factory.rb +207 -201
  9. data/lib/tdriver/base/sut/generic/behaviours/application.rb +3 -6
  10. data/lib/tdriver/base/sut/generic/behaviours/find.rb +1 -1
  11. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +14 -14
  12. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +5 -5
  13. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +14 -14
  14. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +3 -18
  15. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +6 -6
  16. data/lib/tdriver/base/sut/generic/plugin.rb +4 -9
  17. data/lib/tdriver/base/sut/sut.rb +2 -6
  18. data/lib/tdriver/base/test_object/abstract.rb +1 -1
  19. data/lib/tdriver/base/test_object/adapter.rb +5 -5
  20. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +7 -6
  21. data/lib/tdriver/base/test_object/behaviours/test_object.rb +18 -18
  22. data/lib/tdriver/base/test_object/factory.rb +147 -96
  23. data/lib/tdriver/base/test_object/verification.rb +6 -9
  24. data/lib/tdriver/base/test_object/xml/adapter.rb +5 -5
  25. data/lib/tdriver/matti.rb +1 -1
  26. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +17 -8
  27. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +7 -7
  28. data/lib/tdriver/report/report_api.rb +172 -79
  29. data/lib/tdriver/report/report_crash_file_capture.rb +4 -7
  30. data/lib/tdriver/report/report_creator.rb +16 -20
  31. data/lib/tdriver/report/report_file_capture.rb +3 -3
  32. data/lib/tdriver/report/report_javascript.rb +3 -3
  33. data/lib/tdriver/report/report_test_case_run.rb +20 -10
  34. data/lib/tdriver/report/report_test_run.rb +11 -10
  35. data/lib/tdriver/report/report_writer.rb +13 -11
  36. data/lib/tdriver/tdriver.rb +6 -6
  37. data/lib/tdriver/util/common/array.rb +2 -2
  38. data/lib/tdriver/util/common/file.rb +9 -11
  39. data/lib/tdriver/util/common/gem.rb +1 -1
  40. data/lib/tdriver/util/common/kernel.rb +4 -4
  41. data/lib/tdriver/util/common/retryable.rb +2 -2
  42. data/lib/tdriver/util/common/string.rb +2 -3
  43. data/lib/tdriver/util/hooking/hooking.rb +2 -2
  44. data/lib/tdriver/util/localisation/localisation.rb +12 -12
  45. data/lib/tdriver/util/logger/logger.rb +7 -25
  46. data/lib/tdriver/util/operator_data/operator_data.rb +5 -5
  47. data/lib/tdriver/util/parameter/parameter.rb +2 -2
  48. data/lib/tdriver/util/plugin/abstract.rb +4 -3
  49. data/lib/tdriver/util/plugin/service.rb +31 -4
  50. data/lib/tdriver/util/recorder/recorder.rb +4 -4
  51. data/lib/tdriver/util/user_data/user_data.rb +5 -5
  52. data/lib/tdriver/util/video/camera_windows.rb +1 -1
  53. data/lib/tdriver/util/xml/builder.rb +3 -1
  54. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +1 -1
  55. data/lib/tdriver/util/xml/xml.rb +5 -5
  56. data/lib/tdriver/verify/verify.rb +26 -26
  57. data/lib/tdriver/version.rb +1 -1
  58. data/xml/behaviours/generic.xml +1 -2
  59. metadata +2 -3
  60. data/lib/tdriver/verify/verify.rb_org +0 -630
@@ -65,18 +65,18 @@ module MobyBehaviour
65
65
  #
66
66
  # == returns
67
67
  # MobyBase::TestObject
68
- # description: Returns self
68
+ # description: Returns receiver object of this method, not the found object
69
69
  # example: -
70
70
  #
71
71
  # == exceptions
72
72
  # TypeError
73
- # description: Wrong argument type %s for attributes (expected Hash)
73
+ # description: Wrong argument type <class> for attributes (expected Hash)
74
74
  #
75
75
  # TypeError
76
- # description: Wrong argument type %s for attribute :type (expected String)
76
+ # description: Wrong argument type <class> for attribute :type (expected String)
77
77
  #
78
78
  # TypeError
79
- # description: Wrong argument type %s for timeout (expected Integer, Fixnum or Float)
79
+ # description: Wrong argument type <class> for timeout (expected Integer, Fixnum or Float)
80
80
  #
81
81
  # ArgumentError
82
82
  # description: Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float
@@ -111,11 +111,12 @@ module MobyBehaviour
111
111
  :identification_directives => dynamic_attributes.default_values(
112
112
  :__timeout => timeout,
113
113
  :__retry_interval => retry_interval,
114
- :__refresh_arguments => self.kind_of?( MobyBase::SUT ) ? attributes : { :id => self.get_application_id }
114
+ :__refresh_arguments => self.kind_of?( MobyBase::SUT ) ? attributes : { :id => self.get_application_id },
115
+ :__parent_application => self.sut? == true ? nil : @parent_application
115
116
  ),
116
117
  :parent => self
117
118
  )
118
-
119
+
119
120
  rescue MobyBase::TestObjectNotFoundError
120
121
 
121
122
  # the child object was not found in the specified timeout
@@ -51,6 +51,17 @@ module MobyBehaviour
51
51
  # example: { :name => 'Triangle1', :type => :Triangle }
52
52
  attr_accessor :creation_attributes
53
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
+
54
65
  =begin
55
66
  # == nodoc
56
67
  # == description
@@ -189,7 +200,7 @@ module MobyBehaviour
189
200
 
190
201
  # == description
191
202
  # 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
192
- # as the parent when the test object instance was created, see parent_object.
203
+ # as the parent when the test object instance was created, see [link="#GenericTestObject:parent"]parent[/link] method.
193
204
  # == returns
194
205
  # TestObject
195
206
  # description: test object that is parent of this test object, self if no parent (ie. application objects)
@@ -419,7 +430,7 @@ module MobyBehaviour
419
430
  #
420
431
  # == exceptions
421
432
  # TypeError
422
- # description: Wrong argument type %s for attributes (expected Hash)
433
+ # description: Wrong argument type <class> for attributes (expected Hash)
423
434
  #
424
435
  # MultipleTestObjectsIdentifiedError
425
436
  # description: raised if multiple objects found that match the given attributes
@@ -767,19 +778,9 @@ module MobyBehaviour
767
778
 
768
779
  end
769
780
 
770
- $logger.behaviour(
781
+ $logger.behaviour "FAIL;#{ description };#{ identity };#{ dynamic_attributes[ :__multiple_objects ] ? "children" : "child" };#{ attributes.inspect }"
771
782
 
772
- "%s;%s;%s;%s;%s" % [
773
- "FAIL",
774
- description,
775
- identity,
776
- dynamic_attributes[ :__multiple_objects ] ? "children" : "child",
777
- attributes.inspect
778
- ]
779
-
780
- )
781
-
782
- Kernel::raise exception
783
+ raise exception
783
784
 
784
785
  ensure
785
786
 
@@ -839,7 +840,7 @@ module MobyBehaviour
839
840
 
840
841
  rescue MobyBase::TestObjectNotFoundError
841
842
 
842
- Kernel::raise MobyBase::TestObjectNotVisibleError
843
+ raise MobyBase::TestObjectNotVisibleError
843
844
 
844
845
  end
845
846
 
@@ -957,12 +958,12 @@ module MobyBehaviour
957
958
 
958
959
  public
959
960
 
960
- # This method is deprecated, please use [link="#GenericTestObject:parent"]TestObject#parent[/link] instead.
961
961
  # == deprecated
962
962
  # 0.8.x
963
963
  #
964
964
  # == description
965
965
  # This method is deprecated, please use TestObject#parent
966
+ # This method is deprecated, please use [link="#GenericTestObject:parent"]TestObject#parent[/link] instead.
966
967
  #
967
968
  def parent_object
968
969
 
@@ -980,12 +981,11 @@ module MobyBehaviour
980
981
 
981
982
  end
982
983
 
983
- # This method is deprecated, please use [link="#GenericTestObject:state_object"]TestObject#state_object[/link] instead.
984
984
  # == deprecated
985
985
  # 1.1.1
986
986
  #
987
987
  # == description
988
- # This method is deprecated, please use TestObject#state_object
988
+ # This method is deprecated, please use [link="#GenericTestObject:state_object"]TestObject#state_object[/link] instead.
989
989
  #
990
990
  def state
991
991
 
@@ -17,29 +17,95 @@
17
17
  ##
18
18
  ############################################################################
19
19
 
20
- module MobyBase
20
+ module TDriver
21
21
 
22
- # class to represent TestObjectFactory.
23
- #
24
- # when a SUT asks for factory to create test objects, it shall give reference to the SUT so that
25
- # factory can make a call back for SUT object dump (in xml)
26
- class TestObjectFactory
22
+ module TestObjectFactory
23
+
24
+ # private methods and variables
25
+ class << self
26
+
27
+ private
28
+
29
+ # TODO: document me
30
+ def initialize_class
31
+
32
+ reset
33
+
34
+ end
35
+
36
+ # TODO: document me
37
+ def get_object_params( creation_attributes )
38
+
39
+ if creation_attributes[ :type ] != 'application'
40
+
41
+ object_search_params = creation_attributes.clone
42
+
43
+ # see below lines how to do following easier
44
+ #object_search_params[ :className ] = object_search_params.delete( :type ) if creation_attributes.has_key?( :type )
45
+ #object_search_params[ :objectName ] = object_search_params.delete( :name ) if creation_attributes.has_key?( :name )
46
+
47
+ object_search_params.rename_key!( :type, :className ){}
48
+ object_search_params.rename_key!( :name, :objectName ){}
49
+
50
+ object_search_params
51
+
52
+ else
53
+
54
+ {}
55
+
56
+ end
57
+
58
+ end
59
+
60
+ # TODO: document me
61
+ def get_parent_params( test_object )
62
+
63
+ unless [ 'application', 'sut' ].include?( test_object.type )
64
+
65
+ search_params = []
66
+
67
+ search_params.concat( get_parent_params( test_object.parent ) ) if test_object.parent
68
+ search_params.concat( [ :className => test_object.type, :tasId => test_object.id ] ) #if test_object
69
+
70
+ search_params
71
+
72
+ else
73
+
74
+ []
75
+
76
+ end
77
+
78
+ end
79
+
80
+ # TODO: document me
81
+ def list_matching_test_objects_as_list( test_object_adapter, matches )
27
82
 
28
- include Singleton
83
+ test_object_adapter.list_test_objects_as_string( matches ).each_with_index.collect{ | object, object_index |
29
84
 
30
- attr_reader :timeout, :test_object_adapter
85
+ "#{ ( object_index + 1 ).to_s.rjust( 3, '0' ) }) #{ object.to_s }"
31
86
 
32
- # TODO: Document me (TestObjectFactory::initialize)
33
- def initialize( options = {} )
87
+ }.join( "\n" )
88
+
89
+ end
90
+
91
+ end # self
92
+
93
+ # TODO: document me
94
+ def self.reset
34
95
 
35
96
  # get timeout from parameters, use default value if parameter not found
36
97
  @timeout = $parameters[ :application_synchronization_timeout, "20" ].to_f
37
98
 
38
99
  # get timeout retry interval from parameters, use default value if parameter not found
39
100
  @_retry_interval = $parameters[ :application_synchronization_retry_interval, "1" ].to_f
101
+
102
+ end
40
103
 
41
- #@test_object_adapter = TDriver::TestObjectAdapter
42
-
104
+ # function to get timeout for TestObjectFactory
105
+ def self.timeout
106
+
107
+ @timeout
108
+
43
109
  end
44
110
 
45
111
  # Function to set timeout for TestObjectFactory
@@ -50,7 +116,7 @@ module MobyBase
50
116
  # new_timeout:: Fixnum which defines the new timeout
51
117
  # == raises
52
118
  # ArgumentError:: if parameter is not kind of Fixnum
53
- def timeout=( value )
119
+ def self.timeout=( value )
54
120
 
55
121
  value.check_type( Numeric, "Wrong argument type $1 for timeout value (expected $2)" )
56
122
 
@@ -59,7 +125,7 @@ module MobyBase
59
125
  end
60
126
 
61
127
  # TODO: document me
62
- def identify_object( rules )
128
+ def self.identify_object( rules )
63
129
 
64
130
  # retrieve test object identification directives; e.g. :__index, :__xy_sorting etc
65
131
  directives = rules[ :identification_directives ]
@@ -76,9 +142,9 @@ module MobyBase
76
142
  # search parameters for find_objects feature
77
143
  search_parameters = make_object_search_params( rules[ :parent ], rules[ :object_attributes_hash ] )
78
144
 
79
- # default rules
145
+ # default rules
80
146
  directives.default_values(
81
-
147
+
82
148
  # get timeout from rules hash or TestObjectFactory
83
149
  :__timeout => @timeout,
84
150
 
@@ -109,28 +175,53 @@ module MobyBase
109
175
 
110
176
  parent_application = directives[ :__parent_application ] || rules[ :parent_application ]
111
177
 
112
- unless parent_application.nil?
178
+ # application could be retrieved also like this...
179
+ # rules[ :parent ].instance_variable_get( :@parent_application )
180
+
181
+ # when e.g. wait_child is called to SUT, TDriver is unable to determine layout direction used for sorting/indexing
182
+ if rules[ :parent ].sut?
183
+
184
+ application_layout_direction = directives[ :__layout_direction ]
185
+
186
+ raise RuntimeError, 'layout direction is not available for indexing/xy_sorting; please use e.g. :__layout_direction => "LeftToRight"' if application_layout_direction.blank?
187
+
188
+ else
189
+
190
+ # retrieve layout direction from application object if available
191
+ unless parent_application.nil?
113
192
 
114
- begin
193
+ begin
115
194
 
116
- application_layout_direction = parent_application.attribute( 'layoutDirection' ).to_s
195
+ application_layout_direction = ""
117
196
 
118
- raise if application_layout_direction.empty?
197
+ if directives[ :__layout_direction ].blank?
198
+
199
+ application_layout_direction = parent_application.attribute( 'layoutDirection' ).to_s
200
+
201
+ end
119
202
 
120
- rescue
203
+ raise if application_layout_direction.empty?
121
204
 
122
- application_layout_direction = 'LeftToRight'
205
+ rescue
123
206
 
124
- end
207
+ application_layout_direction = directives[ :__layout_direction ]
125
208
 
126
- else
209
+ # parent application not defined/available, use default value
210
+ application_layout_direction = 'LeftToRight' if application_layout_direction.blank?
127
211
 
128
- raise RuntimeError, 'parent application not given, unable to retrieve layoutDirection'
212
+ end
213
+
214
+ else
215
+
216
+ raise RuntimeError, 'parent application not given; unable to retrieve layoutDirection attribute'
217
+
218
+ end
129
219
 
130
220
  end
131
221
 
132
- end
133
222
 
223
+ end
224
+
134
225
  # identify objects until desired matches found or timeout exceeds
135
226
  MobyUtil::Retryable.until(
136
227
 
@@ -159,7 +250,7 @@ module MobyBase
159
250
  directives[ :__find_all_children ]
160
251
 
161
252
  )
162
-
253
+
163
254
  # Temporary prevent users misleading :Text with :text (as they are different)
164
255
  if ( rules[ :object_attributes_hash ].has_key?(:Text) )
165
256
 
@@ -223,7 +314,7 @@ module MobyBase
223
314
  end
224
315
 
225
316
  # TODO: document me
226
- def get_test_objects( rules )
317
+ def self.get_test_objects( rules )
227
318
 
228
319
  # retrieve sut object
229
320
  sut = rules[ :parent ].instance_variable_get( :@sut )
@@ -398,7 +489,7 @@ module MobyBase
398
489
  end
399
490
 
400
491
  # TODO: document me
401
- def make_test_object( rules )
492
+ def self.make_test_object( rules )
402
493
 
403
494
  # get parent object from hash
404
495
  parent = rules[ :parent ]
@@ -532,7 +623,7 @@ module MobyBase
532
623
  end
533
624
 
534
625
  # create test object search parameters for find_objects service
535
- def make_object_search_params( test_object, creation_attributes )
626
+ def self.make_object_search_params( test_object, creation_attributes )
536
627
 
537
628
  result = get_parent_params( test_object ).push( get_object_params( creation_attributes ) )
538
629
 
@@ -542,70 +633,9 @@ module MobyBase
542
633
 
543
634
  end
544
635
 
545
- private
636
+ def self.set_timeout( new_timeout )
546
637
 
547
- # TODO: document me
548
- def get_object_params( creation_attributes )
549
-
550
- if creation_attributes[ :type ] != 'application'
551
-
552
- object_search_params = creation_attributes.clone
553
-
554
- # see below lines how to do following easier
555
- #object_search_params[ :className ] = object_search_params.delete( :type ) if creation_attributes.has_key?( :type )
556
- #object_search_params[ :objectName ] = object_search_params.delete( :name ) if creation_attributes.has_key?( :name )
557
-
558
- object_search_params.rename_key!( :type, :className ){}
559
- object_search_params.rename_key!( :name, :objectName ){}
560
-
561
- object_search_params
562
-
563
- else
564
-
565
- {}
566
-
567
- end
568
-
569
- end
570
-
571
- # TODO: document me
572
- def get_parent_params( test_object )
573
-
574
- unless [ 'application', 'sut' ].include?( test_object.type )
575
-
576
- search_params = []
577
-
578
- search_params.concat( get_parent_params( test_object.parent ) ) if test_object.parent
579
- search_params.concat( [ :className => test_object.type, :tasId => test_object.id ] ) #if test_object
580
-
581
- search_params
582
-
583
- else
584
-
585
- []
586
-
587
- end
588
-
589
- end
590
-
591
- # TODO: document me
592
- def list_matching_test_objects_as_list( test_object_adapter, matches )
593
-
594
- test_object_adapter.list_test_objects_as_string( matches ).each_with_index.collect{ | object, object_index |
595
-
596
- "%3s) %s" % [ object_index + 1, object ]
597
-
598
- }.join( "\n" )
599
-
600
- #list_matching_test_objects( matches ).each_with_index.collect{ | object, object_index | "%3s) %s" % [ object_index + 1, object ] }.join( "\n" )
601
-
602
- end
603
-
604
- public # deprecated methods
605
-
606
- def set_timeout( new_timeout )
607
-
608
- warn "warning: deprecated method TestObjectFactory#set_timeout( value ); please use TestObjectFactory#timeout=( value ) instead"
638
+ warn "warning: deprecated method TDriver::TestObjectFactory#set_timeout( value ); please use TDriver::TestObjectFactory#timeout=( value ) instead"
609
639
 
610
640
  self.timeout = new_timeout
611
641
 
@@ -615,17 +645,38 @@ module MobyBase
615
645
  #
616
646
  # === returns
617
647
  # Numeric:: Timeout
618
- def get_timeout
648
+ def self.get_timeout
619
649
 
620
- warn "warning: deprecated method TestObjectFactory#get_timeout; please use TestObjectFactory#timeout instead"
650
+ warn "warning: deprecated method TDriver::TestObjectFactory#get_timeout; please use TDriver::TestObjectFactory#timeout instead"
621
651
 
622
652
  @timeout
623
653
 
624
654
  end
625
655
 
626
- # enable hoo./base/test_object/factory.rb:king for performance measurement & debug logging
656
+ # enable hooking for performance measurement & debug logging
627
657
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
628
658
 
659
+ # initialize plugin service
660
+ initialize_class
661
+
662
+
629
663
  end # TestObjectFactory
630
664
 
665
+ end # TDriver
666
+
667
+ # for backwards compatibility
668
+ module MobyBase
669
+
670
+ class TestObjectFactory
671
+
672
+ def self.instance
673
+
674
+ warn_caller '$1:$2 deprecated class MobyBase::TestObjectFactory, please use static class TDriver::TestObjectFactory instead'
675
+
676
+ TDriver::TestObjectFactory
677
+
678
+ end
679
+
680
+ end # SUTFactory
681
+
631
682
  end # MobyBase