testability-driver-qt-sut-plugin 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/env.rb +26 -0
  2. data/installer/extconf.rb +62 -0
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +156 -0
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +318 -0
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +227 -0
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +140 -0
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +165 -0
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +333 -0
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +80 -0
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +178 -0
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +906 -0
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +604 -0
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +152 -0
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +151 -0
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +85 -0
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +455 -0
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +124 -0
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +283 -0
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +492 -0
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +113 -0
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +93 -0
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +230 -0
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +663 -0
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +50 -0
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +45 -0
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +48 -0
  36. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
  37. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +170 -0
  38. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
  39. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +226 -0
  40. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +264 -0
  41. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +60 -0
  42. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +114 -0
  43. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +67 -0
  44. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +52 -0
  45. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +62 -0
  46. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +99 -0
  47. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +54 -0
  48. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +51 -0
  49. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +72 -0
  50. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +119 -0
  51. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +225 -0
  52. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +154 -0
  53. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +58 -0
  54. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
  55. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +82 -0
  56. data/lib/testability-driver-qt-sut-plugin.rb +24 -0
  57. data/xml/behaviour/qt.xml +717 -0
  58. data/xml/defaults/sut_qt.xml +9 -0
  59. data/xml/keymap/qt.xml +321 -0
  60. data/xml/template/qt.xml +124 -0
  61. metadata +141 -0
@@ -0,0 +1,113 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyBehaviour
21
+
22
+ module QT
23
+
24
+ # == description
25
+ # Synchronization specific behaviours
26
+ #
27
+ # == behaviour
28
+ # QtSynchronization
29
+ #
30
+ # == requires
31
+ # testability-driver-qt-sut-plugin
32
+ #
33
+ # == input_type
34
+ # touch
35
+ #
36
+ # == sut_type
37
+ # QT
38
+ #
39
+ # == sut_version
40
+ # *
41
+ #
42
+ # == objects
43
+ # *
44
+ #
45
+ module Synchronization
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ class SignalNotEmittedException < RuntimeError
50
+
51
+ end
52
+
53
+ # Execution of the test script is stopped and TDriver waits for the given signal. If no signals of the
54
+ # given type are found before the timeout an error is raised.
55
+ #
56
+ # === params
57
+ # signal_timeout:: Integer, time to wait for signal, in seconds
58
+ # signal_name:: String, name of the signal to wait for. Note that most signals end with ()
59
+ # block:: (optional) code block to be executed while listening signals
60
+ # === returns
61
+ # nil
62
+ # === errors
63
+ # SignalNotEmittedException:: The given signal was n ot received before the timeout
64
+ # ArgumentError:: signal_timeout was not a positive Integer or signal_name was not a nonempty String
65
+ def wait_for_signal( signal_timeout, signal_name, &block )
66
+
67
+ Kernel::raise ArgumentError.new("The timeout argument was of wrong type: expected 'Integer' was '%s'" % signal_timeout.class ) unless signal_timeout.kind_of?( Integer )
68
+
69
+ Kernel::raise ArgumentError.new("The timeout argument had a value of '%s', it must be a non negative Integer.'" % signal_timeout ) unless signal_timeout >= 0
70
+
71
+ Kernel::raise ArgumentError.new("The signal name argument was of wrong type: expected 'String' was '%s'" % signal_name.class ) unless signal_name.kind_of?( String )
72
+
73
+ Kernel::raise ArgumentError.new("The signal name argument must not be an empty String.") unless !signal_name.empty?
74
+
75
+ # enable signal listening
76
+ self.fixture( 'signal', 'enable_signal', :signal => signal_name )
77
+
78
+ # execute code block if any given
79
+ block.call if block_given?
80
+
81
+ timeout_deadline = ( Time.now + signal_timeout )
82
+
83
+ signal_found = false
84
+
85
+ while( Time.now < timeout_deadline && !signal_found )
86
+
87
+ begin
88
+
89
+ signals_xml = MobyUtil::XML.parse_string( self.fixture( 'signal', 'get_signal' ) )
90
+
91
+ signal_found = ( signals_xml.xpath( '//object[@type="QtSignal" and @name="%s"]' % signal_name ).count > 0 )
92
+
93
+ end # begin
94
+
95
+ end # while
96
+
97
+ # disable signal listening
98
+ self.fixture( "signal", "remove_signals" )
99
+
100
+ Kernel::raise SignalNotEmittedException.new("The signal %s was not emitted within %s seconds." % [ signal_name, signal_timeout ] ) unless signal_found
101
+
102
+ nil
103
+
104
+ end # wait_for_signal
105
+
106
+ # enable hooking for performance measurement & debug logging
107
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
108
+
109
+ end # Synchronization
110
+
111
+ end # QT
112
+
113
+ end # MobyBehaviour
@@ -0,0 +1,93 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+
22
+ module MobyBehaviour
23
+
24
+ module QT
25
+
26
+ # == description
27
+ # TreeWidgetItemColumn specific behaviours
28
+ #
29
+ # == behaviour
30
+ # QtTreeWidgetItemColumn
31
+ #
32
+ # == requires
33
+ # testability-driver-qt-sut-plugin
34
+ #
35
+ # == input_type
36
+ # *
37
+ #
38
+ # == sut_type
39
+ # QT
40
+ #
41
+ # == sut_version
42
+ # *
43
+ #
44
+ # == objects
45
+ # TreeWidgetItemColumn
46
+ #
47
+ module TreeWidgetItemColumn
48
+
49
+ include MobyBehaviour::QT::Behaviour
50
+
51
+ # Sets the check state of the item in a treewidget
52
+ # == params
53
+ # == returns
54
+ # == raises
55
+ def check_state(new_state)
56
+
57
+ ret = nil
58
+
59
+ begin
60
+
61
+ raise ArgumentError.new( "new_state must be an integer. Check qt docs for allowed values (Qt::CheckState." ) unless new_state.kind_of?(Integer)
62
+
63
+ command = MobyCommand::WidgetCommand.new
64
+ command.object_id(self.attribute('parentWidget'))
65
+ command.application_id(get_application_id)
66
+ command.object_type(:Standard)
67
+ command.command_name('CheckState')
68
+ command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
69
+ params = {:state => new_state, :column => self.attribute('column'), :item => self.attribute('parentItem')}
70
+
71
+ command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
72
+
73
+ command.command_params(params)
74
+ @sut.execute_command(command)
75
+
76
+ rescue Exception => e
77
+
78
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed select"#{identity};drag;"
79
+ Kernel::raise e
80
+
81
+ end
82
+
83
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation select executed successfully"#{identity};drag;"
84
+ ret
85
+
86
+ end
87
+
88
+ # enable hooking for performance measurement & debug logging
89
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,97 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+
22
+ module MobyBehaviour
23
+
24
+ module QT
25
+
26
+ # == description
27
+ # TypeText specific behaviours
28
+ #
29
+ # == behaviour
30
+ # QtTypeText
31
+ #
32
+ # == requires
33
+ # testability-driver-qt-sut-plugin
34
+ #
35
+ # == input_type
36
+ # *
37
+ #
38
+ # == sut_type
39
+ # QT
40
+ #
41
+ # == sut_version
42
+ # *
43
+ #
44
+ # == objects
45
+ # *
46
+ #
47
+ module TypeText
48
+
49
+ include MobyBehaviour::QT::Behaviour
50
+
51
+ # == description
52
+ # Write text on to a widget (e.g QLineEdit) as if it was typed by user
53
+ # \n
54
+ # == arguments
55
+ # text
56
+ # String
57
+ # description: Text to type
58
+ # example: "abc"
59
+ #
60
+ # == returns
61
+ # NilClass
62
+ # description: -
63
+ # example: -
64
+ #
65
+ # == exceptions
66
+ # Exception
67
+ # description: No special exceptions, may throw any exception
68
+ def type_text( text )
69
+ ret = nil
70
+
71
+ begin
72
+ command = command_params #in qt_behaviour
73
+ command.command_name('TypeText')
74
+ command.command_value(text)
75
+ @sut.execute_command(command)
76
+ sleep 0.2
77
+
78
+ rescue Exception => e
79
+
80
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed type_text with text \"#{text}\".;#{identity};type_text;"
81
+ Kernel::raise e
82
+
83
+ end
84
+
85
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation type_text executed successfully with text \"#{text}\".;#{identity};type_text;"
86
+
87
+ ret
88
+
89
+ end
90
+
91
+ # enable hooking for performance measurement & debug logging
92
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
93
+
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,97 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+
22
+ module MobyBehaviour
23
+
24
+ module QT
25
+
26
+ # == description
27
+ # ViewItem specific behaviours
28
+ #
29
+ # == behaviour
30
+ # QtViewItem
31
+ #
32
+ # == requires
33
+ # testability-driver-qt-sut-plugin
34
+ #
35
+ # == input_type
36
+ # *
37
+ #
38
+ # == sut_type
39
+ # QT
40
+ #
41
+ # == sut_version
42
+ # *
43
+ #
44
+ # == objects
45
+ # ItemData;QTreeWidgetItem;QListWidgetItem;QTableWidgetItem
46
+ #
47
+ module ViewItem
48
+
49
+ include MobyBehaviour::QT::Behaviour
50
+
51
+ # Selects an item from a list that uses qt view model system (e.g. QTreeView)
52
+ # == params
53
+ # == returns
54
+ # == raises
55
+ def select
56
+
57
+ ret = nil
58
+
59
+ begin
60
+
61
+ button=:Left
62
+ command = MobyCommand::WidgetCommand.new
63
+ command.object_id(self.attribute('viewPort'))
64
+ command.application_id(get_application_id)
65
+ command.object_type(:Standard)
66
+ command.command_name('Tap')
67
+ command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
68
+
69
+ mouse_move = @sut.parameter[:in_tap_move_pointer]
70
+ mouse_move = 'false' unless mouse_move
71
+
72
+ params = {'x'=>center_x, 'y' => center_y, 'count' => 1, 'button' => @@_buttons_map[button], 'mouseMove'=>mouse_move, 'useCoordinates' => 'true'}
73
+
74
+ command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
75
+
76
+ command.command_params(params)
77
+ @sut.execute_command(command)
78
+
79
+ rescue Exception => e
80
+
81
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed select"#{identity};drag;"
82
+ Kernel::raise e
83
+
84
+ end
85
+
86
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation select executed successfully"#{identity};drag;"
87
+ ret
88
+
89
+ end
90
+
91
+ # enable hooking for performance measurement & debug logging
92
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,230 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyBehaviour
21
+
22
+ module QT
23
+
24
+ # == description
25
+ # Webkit specific behaviours
26
+ #
27
+ # == behaviour
28
+ # QtWebkit
29
+ #
30
+ # == requires
31
+ # testability-driver-qt-sut-plugin
32
+ #
33
+ # == input_type
34
+ # *
35
+ #
36
+ # == sut_type
37
+ # QT;S60QT
38
+ #
39
+ # == sut_version
40
+ # *
41
+ #
42
+ # == objects
43
+ # *
44
+ #
45
+ module Webkit
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ # Send javascript to target object on the screen
50
+ # == params
51
+ # java_script::( )java script to be executed to target object
52
+ # == returns
53
+ # == raises
54
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
55
+ # ArgumentError:: If an invalid button type is given
56
+ # ArgumentError:: If coordinates are outside of the object
57
+ # === examples
58
+ # @object.execute_javascript_query
59
+ def execute_javascript_query(java_script, locator_query = nil, index = -1, webframe_id = 0)
60
+
61
+ returnValue = ""
62
+
63
+ begin
64
+
65
+ command = command_params #in qt_behaviour
66
+ =begin
67
+ if(locator_query == nil)
68
+ command.command_name('ExecuteJavaScriptOnQWebFrame')
69
+ locator_query=""
70
+ else
71
+ command.command_name('ExecuteJavaScriptOnWebElement')
72
+ end
73
+ =end
74
+
75
+ if type != "QWebFrame"
76
+ command.command_name('ExecuteJavaScriptOnWebElement')
77
+ webframe_id = self.attribute('webFrame') if webframe_id.to_s == "0"
78
+ else
79
+ command.command_name('ExecuteJavaScriptOnQWebFrame')
80
+ end
81
+
82
+ command.service( 'webkitCommand' )
83
+ params = {
84
+ 'java_script' => java_script,
85
+ 'locator_query' => locator_query,
86
+ 'index' => index.to_s,
87
+ 'elementId' => self.id.to_s,
88
+ 'webframe_id' => webframe_id.to_s
89
+ }
90
+
91
+ command.command_params( params )
92
+
93
+ returnValue = @sut.execute_command( command )
94
+
95
+ rescue Exception => e
96
+
97
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed send javascript with execute_javascript \"#{java_script}\""
98
+ Kernel::raise e
99
+
100
+ end
101
+
102
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation send javascript executed successfully with execute_javascript \"#{java_script}\""
103
+
104
+ returnValue
105
+
106
+ end
107
+
108
+
109
+
110
+ # Send javascript to target object on the screen
111
+ # == params
112
+ # java_script::( )java script to be executed to target object
113
+ # == returns
114
+ # == raises
115
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
116
+ # ArgumentError:: If an invalid button type is given
117
+ # ArgumentError:: If coordinates are outside of the object
118
+ # === examples
119
+ # @object.execute_javascript
120
+ def execute_javascript( java_script )
121
+
122
+ webframe_id = 0
123
+ query = ""
124
+ index = -1
125
+ if type == "QWebFrame"
126
+ query = nil
127
+ else
128
+ query << self.type.to_s
129
+ creation_attributes.each {|param, value|
130
+ if param.to_s == "__index"
131
+ index=value.to_i
132
+ next
133
+ end
134
+ query << "[" << param.to_s << "='" << value.to_s << "'" << "]"
135
+ }
136
+ end
137
+
138
+ if type != "QWebFrame" #&& parent_object.type == "QWebFrame")
139
+ #webframe_id = parent_object.id
140
+ webframe_id = self.attribute('webFrame')
141
+ end
142
+
143
+ execute_javascript_query( java_script, nil, index, webframe_id)
144
+ end
145
+
146
+ # Scrolls the
147
+ # == params
148
+ # dx, dy. pixels to scroll down (value may be negative)
149
+ # == returns
150
+ # == raises
151
+ # === examples
152
+ # @QwebFrame.scroll(0, 10)
153
+ # @app.a.scroll()
154
+ def scroll( dx=0, dy=0, tap=0 )
155
+ temp_id = ""
156
+
157
+ if type == "QWebFrame"
158
+ temp_id = self.id
159
+ else
160
+ temp_id = self.attribute('webFrame')
161
+
162
+ x_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='x_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
163
+ y_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='y_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
164
+ width = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='width']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
165
+ height = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='height']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
166
+
167
+ horizontalScrollBarHeight = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='horizontalScrollBarHeight']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
168
+ verticalScrollBarWidth = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='verticalScrollBarWidth']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
169
+
170
+ #calculate borders
171
+ frame_down_border = y_absolute + height - horizontalScrollBarHeight
172
+ frame_right_border = x_absolute + width - verticalScrollBarWidth
173
+
174
+ if(tap==1)
175
+
176
+ #adjust image to be visible for tap
177
+ if(center_y.to_i > frame_down_border)
178
+ dy = center_y.to_i - frame_down_border + 1
179
+ elsif (center_y.to_i < y_absolute)
180
+ dy = center_y.to_i - y_absolute - 1
181
+ end
182
+
183
+ if(center_x.to_i > frame_right_border)
184
+ dx = center_x.to_i - frame_right_border + 1
185
+ elsif (center_x.to_i < x_absolute)
186
+ dx = center_x.to_i - x_absolute - 1
187
+ end
188
+ else
189
+ #bring fully visible
190
+ if(center_y.to_i > frame_down_border)
191
+ dy = self.attribute("y_absolute").to_i + self.attribute("height").to_i - y_absolute - height + horizontalScrollBarHeight
192
+ elsif (center_y.to_i < y_absolute)
193
+ dy = self.attribute("y_absolute").to_i - y_absolute
194
+ end
195
+
196
+ if(center_x.to_i > frame_right_border)
197
+ dx = self.attribute("x_absolute").to_i + self.attribute("width").to_i - x_absolute - width + verticalScrollBarWidth
198
+ elsif (center_x.to_i < x_absolute)
199
+ dx = self.attribute("x_absolute").to_i - x_absolute
200
+ end
201
+ end
202
+ end
203
+
204
+ command = command_params #in qt_behaviour
205
+ command.command_name('ScrollQWebFrame')
206
+
207
+ command.service( 'webkitCommand' )
208
+ params = {
209
+ 'dx' => dx.to_s,
210
+ 'dy'=> dy.to_s,
211
+ 'target_webframe'=> temp_id
212
+ }
213
+
214
+ command.command_params( params )
215
+
216
+ returnValue = @sut.execute_command( command )
217
+ Kernel::raise RuntimeError.new( "Scrollign webframe failed with error: %s" % [ returnValue ] ) if ( returnValue != "OK" )
218
+
219
+ end
220
+
221
+
222
+ # enable hooking for performance measurement & debug logging
223
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
224
+
225
+
226
+ end # Webkit
227
+
228
+ end # QT
229
+
230
+ end # MobyBehaviour