testability-driver-qt-sut-plugin 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/installer/extconf.rb +1 -1
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +4 -4
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +5 -2
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +130 -91
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +3 -3
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +5 -0
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +40 -26
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +1 -1
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +88 -71
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +10 -10
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +5 -5
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +3 -3
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +2 -2
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +2 -2
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +4 -4
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +5 -5
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +3 -3
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +11 -11
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +8 -8
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +12 -12
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +7 -7
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +1 -1
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +1 -1
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +1 -1
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +126 -126
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +49 -29
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +17 -21
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +4 -3
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +59 -86
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +19 -17
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +13 -10
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +38 -25
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +6 -7
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +1 -1
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +1 -4
  36. data/xml/template/qt.xml +1 -0
  37. metadata +28 -9
@@ -28,8 +28,8 @@ module MobyBehaviour
28
28
  attr_reader :value, :type
29
29
 
30
30
  def initialize( type, value )
31
- Kernel::raise ArgumentError.new("Invalid argument type for type. (Actual: %s, Expected: String)" % [ type.class.to_s ] ) unless type.kind_of?( String )
32
- Kernel::raise ArgumentError.new("Invalid argument type for value. (Actual: %s, Expected: String)" % [ value.class.to_s ] ) unless value.kind_of?( String )
31
+ raise ArgumentError.new("Invalid argument type for type. (Actual: %s, Expected: String)" % [ type.class.to_s ] ) unless type.kind_of?( String )
32
+ raise ArgumentError.new("Invalid argument type for value. (Actual: %s, Expected: String)" % [ value.class.to_s ] ) unless value.kind_of?( String )
33
33
  @type, @value = type, value
34
34
  end
35
35
 
@@ -53,7 +53,7 @@ module MobyBehaviour
53
53
  RETURN_RESULT_AS_XML = 0x03
54
54
 
55
55
  def initialize( parent, fixture_name )
56
- Kernel::raise ArgumentError.new("Invalid argument type for fixture name. (Actual: %s, Expected: String)" % [ fixture_name.class.to_s ] ) unless fixture_name.kind_of?( String )
56
+ raise ArgumentError.new("Invalid argument type for fixture name. (Actual: %s, Expected: String)" % [ fixture_name.class.to_s ] ) unless fixture_name.kind_of?( String )
57
57
  @parent, @fixture_name = parent, fixture_name
58
58
  end
59
59
 
@@ -62,7 +62,7 @@ module MobyBehaviour
62
62
  end
63
63
 
64
64
  def list_class_methods( class_name )
65
- Kernel::raise ArgumentError.new("Invalid argument type for class name. (Actual: %s, Expected: String)" % [ class_name.class.to_s ]) unless class_name.kind_of?( String )
65
+ raise ArgumentError.new("Invalid argument type for class name. (Actual: %s, Expected: String)" % [ class_name.class.to_s ]) unless class_name.kind_of?( String )
66
66
  execute( RETURN_RESULT_AS_LIST, 'list_class methods', { :class => class_name } )
67
67
  end
68
68
 
@@ -97,7 +97,7 @@ module MobyBehaviour
97
97
  }
98
98
  }
99
99
 
100
- Kernel::raise RuntimeError.new("Unable to parse fixture result xml (QtApiAccessor)") if result.nil?
100
+ raise RuntimeError.new("Unable to parse fixture result xml (QtApiAccessor)") if result.nil?
101
101
 
102
102
  when RETURN_RESULT_AS_LIST
103
103
 
@@ -63,7 +63,7 @@ module MobyBehaviour
63
63
  rescue Exception => e
64
64
 
65
65
  $logger.behaviour "FAIL;Failed start_recording.;#{ identity };start_recording;"
66
- Kernel::raise e
66
+ raise e
67
67
 
68
68
  end
69
69
 
@@ -89,7 +89,7 @@ module MobyBehaviour
89
89
  rescue Exception => e
90
90
 
91
91
  $logger.behaviour "FAIL;Failed stop_recording.;#{ identity };stop_recording;"
92
- Kernel::raise e
92
+ raise e
93
93
 
94
94
  end
95
95
 
@@ -114,7 +114,7 @@ module MobyBehaviour
114
114
  rescue Exception => e
115
115
 
116
116
  $logger.behaviour "FAIL;Failed print_recordings.;#{ identity };print_recordings;"
117
- Kernel::raise e
117
+ raise e
118
118
 
119
119
  end
120
120
 
@@ -91,13 +91,13 @@ module MobyBehaviour
91
91
  draw = ( draw.downcase == 'true' ? true : false ) if draw.kind_of?( String )
92
92
 
93
93
  # verify that image format is type of string
94
- Kernel::raise ArgumentError.new( "Unexpected argument type (%s) for image format, expected %s" % [ format.class, "String" ] ) unless format.kind_of?( String )
94
+ raise ArgumentError.new( "Unexpected argument type (%s) for image format, expected %s" % [ format.class, "String" ] ) unless format.kind_of?( String )
95
95
 
96
96
  # verify that filename is type of string
97
- Kernel::raise ArgumentError.new( "Unexpected argument type (%s) for filename, expected %s" % [ file_name.class, "String" ] ) unless file_name.nil? || file_name.kind_of?( String )
97
+ raise ArgumentError.new( "Unexpected argument type (%s) for filename, expected %s" % [ file_name.class, "String" ] ) unless file_name.nil? || file_name.kind_of?( String )
98
98
 
99
99
  # verify that draw flag is type of boolean
100
- Kernel::raise ArgumentError.new( "Unexpected argument type (%s) for draw flag, expected %s" % [ draw.class, "boolean (TrueClass or FalseClass)" ] ) unless [ TrueClass, FalseClass ].include?( draw.class )
100
+ raise ArgumentError.new( "Unexpected argument type (%s) for draw flag, expected %s" % [ draw.class, "boolean (TrueClass or FalseClass)" ] ) unless [ TrueClass, FalseClass ].include?( draw.class )
101
101
 
102
102
  command = command_params #in qt_behaviour
103
103
  command.command_name( 'Screenshot' )
@@ -116,7 +116,7 @@ module MobyBehaviour
116
116
 
117
117
  $logger.behaviour "FAIL;Failed capture_screen with format \"%s\", file_name \"%s\".;%s;capture_screen;" % [ format, file_name, identity ]
118
118
 
119
- Kernel::raise e
119
+ raise e
120
120
 
121
121
  end
122
122
 
@@ -169,7 +169,7 @@ module MobyBehaviour
169
169
 
170
170
  require 'RMagick'
171
171
 
172
- Kernel::raise ArgumentError.new("The tolerance argument was not an Integer in the [0,100] range.") unless tolerance.kind_of? Integer and tolerance >= 0 and tolerance <= 100
172
+ raise ArgumentError.new("The tolerance argument was not an Integer in the [0,100] range.") unless tolerance.kind_of? Integer and tolerance >= 0 and tolerance <= 100
173
173
 
174
174
  target = nil
175
175
 
@@ -179,7 +179,7 @@ module MobyBehaviour
179
179
 
180
180
  elsif image_or_path.kind_of? Magick::ImageList
181
181
 
182
- Kernel::raise ArgumentError.new("The supplied ImageList argument did not contain any images.") unless image_or_path.length > 0
182
+ raise ArgumentError.new("The supplied ImageList argument did not contain any images.") unless image_or_path.length > 0
183
183
  target = image_or_path
184
184
 
185
185
  elsif image_or_path.kind_of? String and !image_or_path.empty?
@@ -187,18 +187,18 @@ module MobyBehaviour
187
187
  begin
188
188
  target = Magick::ImageList.new(image_or_path)
189
189
  rescue
190
- Kernel::raise RuntimeError.new("Could not load target for image comparison from path: \"#{image_or_path.to_s}\".")
190
+ raise RuntimeError.new("Could not load target for image comparison from path: \"#{image_or_path.to_s}\".")
191
191
  end
192
192
 
193
193
  else
194
- Kernel::raise ArgumentError.new("The image_or_path argument was not of one of the allowed image types or a non empty String.")
194
+ raise ArgumentError.new("The image_or_path argument was not of one of the allowed image types or a non empty String.")
195
195
  end
196
196
 
197
197
  begin
198
198
  screen = Magick::Image.from_blob(capture_screen){ self.format = "PNG" }.first
199
199
  screen.fuzz = tolerance.to_s + "%"
200
200
  rescue
201
- Kernel::raise RuntimeError.new("Failed to capture SUT screen for comparison. Details:\n" << $!.message)
201
+ raise RuntimeError.new("Failed to capture SUT screen for comparison. Details:\n" << $!.message)
202
202
  end
203
203
 
204
204
  result = screen.find_similar_region( target )
@@ -207,7 +207,7 @@ module MobyBehaviour
207
207
 
208
208
  $logger.behaviour "FAIL;Failed when searching for image on the screen.;#{ identity };find_on_screen;#{(image_or_path.respond_to?(:filename) ? image_or_path.filename : image_or_path.to_s)},#{tolerance.to_s}"
209
209
 
210
- Kernel::raise e
210
+ raise e
211
211
 
212
212
  end
213
213
 
@@ -258,7 +258,7 @@ module MobyBehaviour
258
258
 
259
259
  $logger.behaviour "FAIL;Failed when searching for image on the screen.;#{ identity };screen_contains?;#{(image_or_path.respond_to?(:filename) ? image_or_path.filename : image_or_path.to_s)},#{tolerance.to_s}"
260
260
 
261
- Kernel::raise exc
261
+ raise exc
262
262
 
263
263
 
264
264
  end
@@ -102,12 +102,12 @@ module MobyBehaviour
102
102
 
103
103
  params = generate_fixture_params(identifiers, values)
104
104
 
105
- self.fixture('setting', 'set', params)
105
+ fixture('setting', 'set', params)
106
106
 
107
107
  rescue Exception => e
108
108
 
109
109
  $logger.behaviour "FAIL;Failed set settings \"#{identifiers.to_s}\", \"#{values.to_s}\".;set_settings;"
110
- Kernel::raise e
110
+ raise e
111
111
 
112
112
  end
113
113
 
@@ -155,12 +155,12 @@ module MobyBehaviour
155
155
  params = generate_fixture_params(identifiers, nil)
156
156
  setting_keys.each{|value| params[value.to_sym] = ''}
157
157
 
158
- self.fixture('setting', 'remove', params)
158
+ fixture('setting', 'remove', params)
159
159
 
160
160
  rescue Exception => e
161
161
 
162
162
  $logger.behaviour "FAIL;Failed remove settings \"#{identifiers.to_s}\", \"#{setting_keys.to_s}\".;remove_settings;"
163
- Kernel::raise e
163
+ raise e
164
164
 
165
165
  end
166
166
 
@@ -209,12 +209,12 @@ module MobyBehaviour
209
209
  params = generate_fixture_params(identifiers, nil)
210
210
  setting_keys.each{|value| params[value.to_sym] = ''}
211
211
 
212
- hash = eval(self.fixture('setting', 'read', params))
212
+ hash = eval(fixture('setting', 'read', params))
213
213
 
214
214
  rescue Exception => e
215
215
 
216
216
  $logger.behaviour "FAIL;Failed read settings \"#{identifiers.to_s}\", \"#{setting_keys.to_s}\".;read_settings;"
217
- Kernel::raise e
217
+ raise e
218
218
 
219
219
  end
220
220
 
@@ -256,12 +256,12 @@ module MobyBehaviour
256
256
  begin
257
257
 
258
258
  params = generate_fixture_params(identifiers, nil)
259
- hash = eval(self.fixture('setting', 'readAll', params))
259
+ hash = eval(fixture('setting', 'readAll', params))
260
260
 
261
261
  rescue Exception => e
262
262
 
263
263
  $logger.behaviour "FAIL;Failed read all settings \"#{identifiers.to_s}\".;read_all_settings;"
264
- Kernel::raise e
264
+ raise e
265
265
 
266
266
  end
267
267
 
@@ -122,7 +122,7 @@ module MobyBehaviour
122
122
  rescue Exception => e
123
123
 
124
124
  $logger.behaviour "FAIL;Failed to list processes.;#{ id };sut;{};list_processes;"
125
- Kernel::raise RuntimeError.new( "Unable to list processes: Exception: #{ e.message } (#{ e.class })" )
125
+ raise RuntimeError.new( "Unable to list processes: Exception: #{ e.message } (#{ e.class })" )
126
126
 
127
127
  end
128
128
 
@@ -424,7 +424,7 @@ module MobyBehaviour
424
424
  # example: 7376896
425
425
  # == exceptions
426
426
  def agent_mem_usage
427
- info = self.system_information
427
+ info = system_information
428
428
  begin
429
429
  info.MemoryStatus.attribute('qttasMemUsage').to_i
430
430
  rescue Exception => e
@@ -441,7 +441,7 @@ module MobyBehaviour
441
441
  # example: 2147483647
442
442
  # == exceptions
443
443
  def system_total_mem
444
- info = self.system_information
444
+ info = system_information
445
445
  begin
446
446
  info.MemoryStatus.attribute('total').to_i
447
447
  rescue Exception => e
@@ -458,7 +458,7 @@ module MobyBehaviour
458
458
  # example: 1214980096
459
459
  # == exceptions
460
460
  def system_available_mem
461
- info = self.system_information
461
+ info = system_information
462
462
  begin
463
463
  info.MemoryStatus.attribute('available').to_i
464
464
  rescue Exception => e
@@ -737,21 +737,21 @@ module MobyBehaviour
737
737
  interval_millis = interval*1000 # to millis
738
738
 
739
739
  # make one refresh before execution then freeze
740
- find_object_state = self.parameter[ :use_find_object, false ]
741
- self.parameter[ :use_find_object] = false
740
+ find_object_state = parameter[ :use_find_object, false ]
741
+ parameter[ :use_find_object] = false
742
742
 
743
743
  app.force_refresh({:id => get_application_id})
744
- self.freeze
744
+ freeze
745
745
 
746
746
  #disable sleep to avoid unnecessary sleeping
747
- self.parameter[ :sleep_disabled ] = true
747
+ parameter[ :sleep_disabled ] = true
748
748
 
749
749
  ret = execute_command( MobyCommand::Group.new(interval_millis.to_i, app, block ) )
750
750
 
751
- self.parameter[ :sleep_disabled ] = false
752
- self.parameter[ :use_find_object] = find_object_state
751
+ parameter[ :sleep_disabled ] = false
752
+ parameter[ :use_find_object] = find_object_state
753
753
 
754
- self.unfreeze
754
+ unfreeze
755
755
 
756
756
  # the behaviour returns the amout of behaviours
757
757
  # sleep to avoid sending messages to the app until the
@@ -788,7 +788,7 @@ module MobyBehaviour
788
788
  #
789
789
  def set_event_type(new_type)
790
790
  raise ArgumentError.new("Invalid event type. Accepted values :" << @@_event_type_map.keys.join(", :") ) unless @@_event_type_map.include?(new_type)
791
- $parameters[ self.id ][ :event_type] = @@_event_type_map[new_type]
791
+ $parameters[ id ][ :event_type] = @@_event_type_map[new_type]
792
792
  nil
793
793
  end
794
794
 
@@ -112,7 +112,7 @@ module MobyBehaviour
112
112
  params.check_type [ Hash, NilClass ], 'wrong argument type $1 for signal parameters (expected $2)'
113
113
 
114
114
  # enable signal listening
115
- self.fixture( 'signal', 'enable_signal', :signal => signal_name )
115
+ fixture( 'signal', 'enable_signal', :signal => signal_name )
116
116
 
117
117
  # execute code block if any given
118
118
  begin
@@ -134,7 +134,7 @@ module MobyBehaviour
134
134
  ensure
135
135
 
136
136
  begin
137
- self.fixture( "signal", "remove_signals" )
137
+ fixture( "signal", "remove_signals" )
138
138
  rescue Exception => e
139
139
  $logger.warning "Fixture removal failed. Message received: #{e.message}"
140
140
  end
@@ -187,7 +187,7 @@ module MobyBehaviour
187
187
  def ensure_event(params = nil, &block)
188
188
 
189
189
  raise EventsEnabledException.new("enable_events is used - ensure_events can not be Used at the same time.") if @@_events_enabled
190
- raise ArgumentError.new("Must be called to TestObject" ) unless self.kind_of? MobyBase::TestObject
190
+ raise ArgumentError.new("Must be called to TestObject" ) unless kind_of? MobyBase::TestObject
191
191
 
192
192
  retry_timeout = (params.nil? || params[:retry_timeout].nil?) ? 30 : params[:retry_timeout]
193
193
  retry_interval = (params.nil? || params[:retry_interval].nil?) ? 1 : params[:retry_interval]
@@ -197,9 +197,9 @@ module MobyBehaviour
197
197
  if params && params[:events]
198
198
  events = params[:events]
199
199
  end
200
- app = self.get_application
200
+ app = get_application
201
201
  begin
202
- app.enable_events(events, {"track_id" => self.id.to_s})
202
+ app.enable_events(events, {"track_id" => id.to_s})
203
203
 
204
204
  MobyUtil::Retryable.until(:timeout => retry_timeout,:interval => retry_interval, :exception => EventNotReceivedException) {
205
205
  block.call if block_given?
@@ -208,7 +208,7 @@ module MobyBehaviour
208
208
  begin
209
209
  @sut.state_object(ev).events.attribute('trackedFound')
210
210
  rescue MobyBase::AttributeNotFoundError
211
- $stderr.puts "Warning: Operation not received by object #{self.id} : #{self.name}. Retrying"
211
+ $stderr.puts "Warning: Operation not received by object #{id} : #{self.name}. Retrying"
212
212
  raise EventNotReceivedException.new("No event received during call")
213
213
  end
214
214
  }
@@ -231,7 +231,7 @@ module MobyBehaviour
231
231
 
232
232
  begin
233
233
 
234
- result = self.fixture( 'signal', 'get_signal' )
234
+ result = fixture( 'signal', 'get_signal' )
235
235
 
236
236
  signals_xml = MobyUtil::XML.parse_string( result )
237
237
 
@@ -100,7 +100,7 @@ module MobyBehaviour
100
100
  rescue Exception => e
101
101
 
102
102
  $logger.behaviour "FAIL;Failed select"#{identity};drag;"
103
- Kernel::raise e
103
+ raise e
104
104
 
105
105
  end
106
106
 
@@ -78,7 +78,7 @@ module MobyBehaviour
78
78
  rescue Exception => e
79
79
 
80
80
  $logger.behaviour "FAIL;Failed type_text with text \"#{text}\".;#{identity};type_text;"
81
- Kernel::raise e
81
+ raise e
82
82
 
83
83
  end
84
84
 
@@ -79,7 +79,7 @@ module MobyBehaviour
79
79
  rescue Exception => e
80
80
 
81
81
  $logger.behaviour "FAIL;Failed select"#{identity};drag;"
82
- Kernel::raise e
82
+ raise e
83
83
 
84
84
  end
85
85
 
@@ -19,7 +19,7 @@
19
19
 
20
20
  module MobyBehaviour
21
21
 
22
- module QT
22
+ module QT
23
23
 
24
24
  # == description
25
25
  # Webkit specific behaviours
@@ -42,88 +42,88 @@ module MobyBehaviour
42
42
  # == objects
43
43
  # *
44
44
  #
45
- module Webkit
45
+ module Webkit
46
46
 
47
- include MobyBehaviour::QT::Behaviour
47
+ include MobyBehaviour::QT::Behaviour
48
48
 
49
- # == nodoc
50
- # == description
51
- # Send javascript to target object on the screen
52
- # == params
53
- # java_script::( )java script to be executed to target object
54
- # == returns
55
- # == raises
56
- # TestObjectNotFoundError:: If a graphics item is not visible on screen
57
- # ArgumentError:: If an invalid button type is given
58
- # ArgumentError:: If coordinates are outside of the object
59
- # === examples
60
- # @object.execute_javascript_query
61
- def execute_javascript_query(java_script, locator_query = nil, index = -1, webframe_id = 0)
49
+ # == nodoc
50
+ # == description
51
+ # Send javascript to target object on the screen
52
+ # == params
53
+ # java_script::( )java script to be executed to target object
54
+ # == returns
55
+ # == raises
56
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
57
+ # ArgumentError:: If an invalid button type is given
58
+ # ArgumentError:: If coordinates are outside of the object
59
+ # === examples
60
+ # @object.execute_javascript_query
61
+ def execute_javascript_query(java_script, locator_query = nil, index = -1, webframe_id = 0)
62
62
 
63
- returnValue = ""
64
-
65
- begin
66
-
67
- command = command_params #in qt_behaviour
63
+ returnValue = ""
64
+
65
+ begin
66
+
67
+ command = command_params #in qt_behaviour
68
68
  =begin
69
- if(locator_query == nil)
70
- command.command_name('ExecuteJavaScriptOnQWebFrame')
71
- locator_query=""
72
- else
73
- command.command_name('ExecuteJavaScriptOnWebElement')
74
- end
69
+ if(locator_query == nil)
70
+ command.command_name('ExecuteJavaScriptOnQWebFrame')
71
+ locator_query=""
72
+ else
73
+ command.command_name('ExecuteJavaScriptOnWebElement')
74
+ end
75
75
  =end
76
76
 
77
- if type != "QWebFrame"
78
- command.command_name('ExecuteJavaScriptOnWebElement')
79
- webframe_id = attribute('webFrame') if webframe_id.to_s == "0"
80
- else
81
- command.command_name('ExecuteJavaScriptOnQWebFrame')
82
- end
77
+ if type != "QWebFrame"
78
+ command.command_name('ExecuteJavaScriptOnWebElement')
79
+ webframe_id = attribute('webFrame') if webframe_id.to_s == "0"
80
+ else
81
+ command.command_name('ExecuteJavaScriptOnQWebFrame')
82
+ end
83
83
 
84
- command.service( 'webkitCommand' )
85
- params = {
86
- 'java_script' => java_script,
87
- 'locator_query' => locator_query,
88
- 'index' => index.to_s,
89
- 'elementId' => @id.to_s,
90
- 'webframe_id' => webframe_id.to_s
91
- }
92
-
93
- command.command_params( params )
94
-
95
- returnValue = @sut.execute_command( command )
84
+ command.service( 'webkitCommand' )
85
+ params = {
86
+ 'java_script' => java_script,
87
+ 'locator_query' => locator_query,
88
+ 'index' => index.to_s,
89
+ 'elementId' => @id.to_s,
90
+ 'webframe_id' => webframe_id.to_s
91
+ }
96
92
 
97
- rescue Exception => e
93
+ command.command_params( params )
94
+
95
+ returnValue = @sut.execute_command( command )
96
+
97
+ rescue Exception => e
98
98
 
99
- $logger.behaviour "FAIL;Failed send javascript with execute_javascript \"#{java_script}\""
100
- Kernel::raise e
99
+ $logger.behaviour "FAIL;Failed send javascript with execute_javascript \"#{java_script}\""
100
+ raise e
101
101
 
102
- end
102
+ end
103
103
 
104
- $logger.behaviour "PASS;Operation send javascript executed successfully with execute_javascript \"#{java_script}\""
104
+ $logger.behaviour "PASS;Operation send javascript executed successfully with execute_javascript \"#{java_script}\""
105
105
 
106
- returnValue
106
+ returnValue
107
107
 
108
- end
109
-
108
+ end
109
+
110
110
  # == description
111
- # Executes java script on the target test object
112
- #
113
- # == arguments
114
- # java_script
115
- # String
116
- # description: Script to be executed to target object
117
- # example: "this.onclick();"
118
- #
119
- # == returns
120
- # MobyBase::TestObject
121
- # description: Target test object
122
- # example: -
123
- #
124
- # == raises
125
- # RuntimeError
126
- # description: When executing JavaScript to QWebFrame: QWebPage not found.
111
+ # Executes java script on the target test object
112
+ #
113
+ # == arguments
114
+ # java_script
115
+ # String
116
+ # description: Script to be executed to target object
117
+ # example: "this.onclick();"
118
+ #
119
+ # == returns
120
+ # MobyBase::TestObject
121
+ # description: Target test object
122
+ # example: -
123
+ #
124
+ # == raises
125
+ # RuntimeError
126
+ # description: When executing JavaScript to QWebFrame: QWebPage not found.
127
127
  #
128
128
  # RuntimeError
129
129
  # description: When executing JavaScript to QWebFrame: QWebFrame not found.
@@ -134,63 +134,63 @@ module MobyBehaviour
134
134
  # RuntimeError
135
135
  # description: When executing JavaScript to WebElement: QWebElement not found.
136
136
  #
137
- def execute_javascript( java_script )
138
-
139
- webframe_id = 0
140
- query = ""
141
- index = -1
142
- if type == "QWebFrame"
143
- query = nil
144
- else
145
- query << self.type.to_s
146
- creation_attributes.each {|param, value|
147
- if param.to_s == "__index"
148
- index=value.to_i
149
- next
150
- end
151
- query << "[" << param.to_s << "='" << value.to_s << "'" << "]"
152
- }
153
- end
154
-
155
- if type != "QWebFrame" #&& parent_object.type == "QWebFrame")
156
- #webframe_id = parent_object.id
157
- webframe_id = attribute('webFrame')
158
- end
137
+ def execute_javascript( java_script )
138
+
139
+ webframe_id = 0
140
+ query = ""
141
+ index = -1
142
+ if type == "QWebFrame"
143
+ query = nil
144
+ else
145
+ query << self.type.to_s
146
+ creation_attributes.each {|param, value|
147
+ if param.to_s == "__index"
148
+ index=value.to_i
149
+ next
150
+ end
151
+ query << "[" << param.to_s << "='" << value.to_s << "'" << "]"
152
+ }
153
+ end
154
+
155
+ if type != "QWebFrame" #&& parent_object.type == "QWebFrame")
156
+ #webframe_id = parent_object.id
157
+ webframe_id = attribute('webFrame')
158
+ end
159
159
 
160
- execute_javascript_query( java_script, nil, index, webframe_id)
161
- end
160
+ execute_javascript_query( java_script, nil, index, webframe_id)
161
+ end
162
162
 
163
163
  # == description
164
- # Scroll QWebFrame to correct position. Valid target object types are: QWebFrame, all QWebElements.
165
- #
166
- # == arguments
167
- # dx
168
- # Fixnum
169
- # description: Delta x in pixels, positive value to right negative to left. Ignored for QWebElements.
170
- # example: 313
164
+ # Scroll QWebFrame to correct position. Valid target object types are: QWebFrame, all QWebElements.
165
+ #
166
+ # == arguments
167
+ # dx
168
+ # Fixnum
169
+ # description: Delta x in pixels, positive value to right negative to left. Ignored for QWebElements.
170
+ # example: 313
171
171
  #
172
- # dy
173
- # Fixnum
174
- # description: Delta y in pixels, positive value to down negative to up. Ignored for QWebElements.
175
- # example: 313
176
- #
177
- # center
178
- # Fixnum
179
- # description: Value 1 means that scroll is done only to reveal the center position of the element. Value 0 means that element is tried to bring fully visible. Ignored for QWebFrame.
180
- # example: 1
181
- #
182
- # == returns
172
+ # dy
173
+ # Fixnum
174
+ # description: Delta y in pixels, positive value to down negative to up. Ignored for QWebElements.
175
+ # example: 313
176
+ #
177
+ # center
178
+ # Fixnum
179
+ # description: Value 1 means that scroll is done only to reveal the center position of the element. Value 0 means that element is tried to bring fully visible. Ignored for QWebFrame.
180
+ # example: 1
181
+ #
182
+ # == returns
183
183
  # NilClass
184
184
  # description: -
185
185
  # example: -
186
186
  #
187
- # == exceptions
188
- # RuntimeError
189
- # description: Scrollign webframe failed with error: %s
190
- #
191
- # === examples
192
- # @QwebFrame.scroll(0, 10)
193
- # @app.a.scroll()
187
+ # == exceptions
188
+ # RuntimeError
189
+ # description: Scrollign webframe failed with error: %s
190
+ #
191
+ # === examples
192
+ # @QwebFrame.scroll(0, 10)
193
+ # @app.a.scroll()
194
194
  def scroll( dx = 0, dy = 0, center = 0 )
195
195
  temp_id = ""
196
196
 
@@ -217,9 +217,9 @@ module MobyBehaviour
217
217
 
218
218
  #adjust image to be visible for tap
219
219
  if(center_y.to_i > frame_down_border)
220
- dy = center_y.to_i - frame_down_border + 1
220
+ dy = center_y.to_i - frame_down_border + 5
221
221
  elsif (center_y.to_i < y_absolute)
222
- dy = center_y.to_i - y_absolute - 1
222
+ dy = center_y.to_i - y_absolute - 5
223
223
  end
224
224
 
225
225
  if(center_x.to_i > frame_right_border)
@@ -234,7 +234,7 @@ module MobyBehaviour
234
234
  elsif (center_y.to_i < y_absolute)
235
235
  dy = attribute("y_absolute").to_i - y_absolute
236
236
  end
237
-
237
+
238
238
  if(center_x.to_i > frame_right_border)
239
239
  dx = attribute("x_absolute").to_i + attribute("width").to_i - x_absolute - width + verticalScrollBarWidth
240
240
  elsif (center_x.to_i < x_absolute)
@@ -256,17 +256,17 @@ module MobyBehaviour
256
256
  command.command_params( params )
257
257
 
258
258
  returnValue = @sut.execute_command( command )
259
- Kernel::raise RuntimeError.new( "Scrollign webframe failed with error: %s" % [ returnValue ] ) if ( returnValue != "OK" )
259
+ raise RuntimeError.new( "Scrollign webframe failed with error: %s" % [ returnValue ] ) if ( returnValue != "OK" )
260
260
 
261
261
  end
262
262
 
263
263
 
264
- # enable hooking for performance measurement & debug logging
265
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
264
+ # enable hooking for performance measurement & debug logging
265
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
266
266
 
267
267
 
268
- end # Webkit
268
+ end # Webkit
269
269
 
270
- end # QT
270
+ end # QT
271
271
 
272
272
  end # MobyBehaviour