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.
- data/installer/extconf.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +4 -4
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +5 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +130 -91
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +3 -3
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +5 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +40 -26
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +88 -71
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +10 -10
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +5 -5
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +3 -3
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +4 -4
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +5 -5
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +3 -3
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +11 -11
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +8 -8
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +12 -12
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +7 -7
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +126 -126
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +49 -29
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +17 -21
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +4 -3
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +59 -86
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +19 -17
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +13 -10
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +38 -25
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +6 -7
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +1 -4
- data/xml/template/qt.xml +1 -0
- metadata +28 -9
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb
CHANGED
@@ -28,8 +28,8 @@ module MobyBehaviour
|
|
28
28
|
attr_reader :value, :type
|
29
29
|
|
30
30
|
def initialize( type, value )
|
31
|
-
|
32
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
117
|
+
raise e
|
118
118
|
|
119
119
|
end
|
120
120
|
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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(
|
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
|
-
|
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(
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
741
|
-
|
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
|
-
|
744
|
+
freeze
|
745
745
|
|
746
746
|
#disable sleep to avoid unnecessary sleeping
|
747
|
-
|
747
|
+
parameter[ :sleep_disabled ] = true
|
748
748
|
|
749
749
|
ret = execute_command( MobyCommand::Group.new(interval_millis.to_i, app, block ) )
|
750
750
|
|
751
|
-
|
752
|
-
|
751
|
+
parameter[ :sleep_disabled ] = false
|
752
|
+
parameter[ :use_find_object] = find_object_state
|
753
753
|
|
754
|
-
|
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[
|
791
|
+
$parameters[ id ][ :event_type] = @@_event_type_map[new_type]
|
792
792
|
nil
|
793
793
|
end
|
794
794
|
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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 =
|
200
|
+
app = get_application
|
201
201
|
begin
|
202
|
-
app.enable_events(events, {"track_id" =>
|
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 #{
|
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 =
|
234
|
+
result = fixture( 'signal', 'get_signal' )
|
235
235
|
|
236
236
|
signals_xml = MobyUtil::XML.parse_string( result )
|
237
237
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
module MobyBehaviour
|
21
21
|
|
22
|
-
|
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
|
-
|
45
|
+
module Webkit
|
46
46
|
|
47
|
-
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
returnValue = ""
|
64
|
+
|
65
|
+
begin
|
66
|
+
|
67
|
+
command = command_params #in qt_behaviour
|
68
68
|
=begin
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
93
|
+
command.command_params( params )
|
94
|
+
|
95
|
+
returnValue = @sut.execute_command( command )
|
96
|
+
|
97
|
+
rescue Exception => e
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
$logger.behaviour "FAIL;Failed send javascript with execute_javascript \"#{java_script}\""
|
100
|
+
raise e
|
101
101
|
|
102
|
-
|
102
|
+
end
|
103
103
|
|
104
|
-
|
104
|
+
$logger.behaviour "PASS;Operation send javascript executed successfully with execute_javascript \"#{java_script}\""
|
105
105
|
|
106
|
-
|
106
|
+
returnValue
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
end
|
109
|
+
|
110
110
|
# == description
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
161
|
-
|
160
|
+
execute_javascript_query( java_script, nil, index, webframe_id)
|
161
|
+
end
|
162
162
|
|
163
163
|
# == description
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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 +
|
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 -
|
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
|
-
|
259
|
+
raise RuntimeError.new( "Scrollign webframe failed with error: %s" % [ returnValue ] ) if ( returnValue != "OK" )
|
260
260
|
|
261
261
|
end
|
262
262
|
|
263
263
|
|
264
|
-
|
265
|
-
|
264
|
+
# enable hooking for performance measurement & debug logging
|
265
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
266
266
|
|
267
267
|
|
268
|
-
|
268
|
+
end # Webkit
|
269
269
|
|
270
|
-
|
270
|
+
end # QT
|
271
271
|
|
272
272
|
end # MobyBehaviour
|