cutedriver-qt-sut-plugin 2.0.0.20210120165900

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/env.rb +24 -0
  3. data/installer/extconf.rb +62 -0
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +157 -0
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +312 -0
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +300 -0
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +214 -0
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_cpu.rb +145 -0
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_gpu.rb +147 -0
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_mem.rb +142 -0
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_pwr.rb +146 -0
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +192 -0
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +375 -0
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +82 -0
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +214 -0
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +189 -0
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +1039 -0
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +767 -0
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +166 -0
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +157 -0
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +112 -0
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +474 -0
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +134 -0
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +279 -0
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +302 -0
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +840 -0
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +257 -0
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +117 -0
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +272 -0
  36. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +877 -0
  37. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
  38. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
  39. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
  40. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +67 -0
  41. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +44 -0
  42. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
  43. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +171 -0
  44. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
  45. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/version.rb +34 -0
  46. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +199 -0
  47. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/agent.rb +54 -0
  48. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +192 -0
  49. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +53 -0
  50. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +48 -0
  51. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +65 -0
  52. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +57 -0
  53. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +53 -0
  54. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +93 -0
  55. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +53 -0
  56. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +62 -0
  57. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +46 -0
  58. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +98 -0
  59. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +200 -0
  60. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +466 -0
  61. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +185 -0
  62. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +69 -0
  63. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +287 -0
  64. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
  65. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +370 -0
  66. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +79 -0
  67. data/lib/testability-driver-qt-sut-plugin.rb +24 -0
  68. data/xml/behaviour/qt.xml +845 -0
  69. data/xml/defaults/sut_qt.xml +9 -0
  70. data/xml/keymap/qt.xml +321 -0
  71. data/xml/keymap/win.xml +174 -0
  72. data/xml/template/qt.xml +141 -0
  73. metadata +127 -0
@@ -0,0 +1,166 @@
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
+ # KeyPress specific behaviours
26
+ #
27
+ # == behaviour
28
+ # QtKeyPress
29
+ #
30
+ # == requires
31
+ # testability-driver-qt-sut-plugin
32
+ #
33
+ # == input_type
34
+ # *
35
+ #
36
+ # == sut_type
37
+ # qt
38
+ #
39
+ # == sut_version
40
+ # *
41
+ #
42
+ # == objects
43
+ # *
44
+ #
45
+ module KeyPress
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ # == description
50
+ # Perform key press event or a series of events on an object.
51
+ #
52
+ # == arguments
53
+ # key
54
+ # Symbol
55
+ # description: Symbol of key
56
+ # example: :kRight
57
+ # Integer
58
+ # description: Scan code of key
59
+ # example: 0x01000001
60
+ # MobyCommand::KeySequence
61
+ # description: Sequence of key and press types, see [link="#GenericSut:press_key"]KeySequence reference[/link].
62
+ # example: MobyCommand::KeySequence.new( :kTab, :KeyDown )
63
+ #
64
+ # == returns
65
+ # NilClass
66
+ # description: nil
67
+ # example: nil
68
+ #
69
+ # == exceptions
70
+ # ArgumentError
71
+ # description: Wrong argument type %s for key (Expected: %s)
72
+ # ArgumentError
73
+ # description: Scan code for :%s not defined in keymap
74
+ # ArgumentError
75
+ # description: Error occured during keypress (Response: %s)
76
+ def press_key( key )
77
+
78
+ key_sequence = nil
79
+
80
+ begin
81
+
82
+ command = command_params
83
+
84
+ command.command_name('KeyPress')
85
+
86
+ command.set_require_response( true )
87
+
88
+ #raise ArgumentError.new( "Wrong argument type %s for key (Expected: %s)" % [ key.class, "Symbol/Fixnum/KeySequence" ] ) unless [ Fixnum, Symbol, MobyCommand::KeySequence ].include?( key.class )
89
+
90
+ # raise exception if value type other than Fixnum or Symbol
91
+ key.check_type [ Fixnum, Symbol, MobyCommand::KeySequence ], 'wrong argument type $1 for key (expected $2)'
92
+
93
+ # verify that keymap is defined for sut if symbol used.
94
+ raise ArgumentError, "Symbol #{ key.inspect } cannot be used due to no keymap defined for #{ @sut.id } in TDriver configuration file." if key.kind_of?( Symbol ) && sut_parameters.has_key?( :keymap ) == false
95
+
96
+ if key.kind_of?( Symbol )
97
+
98
+ scancode = TDriver::KeymapUtilities.fetch_keycode( key, sut_parameters[ :keymap ] )
99
+
100
+ # convert hexadecimal (string) to fixnum
101
+ scancode = scancode.hex if scancode.kind_of?( String )
102
+
103
+ # raise exception if value is other than fixnum
104
+ raise ArgumentError, "Scan code for :#{ key } not defined in keymap" unless scancode.kind_of?( Fixnum )
105
+
106
+ # add scancode for keypress event
107
+ command.command_value( scancode.to_s )
108
+
109
+ elsif key.kind_of?( MobyCommand::KeySequence )
110
+
111
+ key_sequence = []
112
+
113
+ key.get_sequence.each do | key_event |
114
+
115
+ #tempcode = sut_parameters[ :keymap ][ key_event[ :value ], nil ]
116
+
117
+ tempcode = TDriver::KeymapUtilities.fetch_keycode( key_event[ :value ], sut_parameters[ :keymap ] )
118
+
119
+ tempcode = tempcode.hex if tempcode.kind_of?( String )
120
+
121
+ press_type = { :KeyDown => 'KeyPress', :KeyUp => 'KeyRelease' }.fetch( key_event[ :type ] ){ "KeyClick" }
122
+
123
+ key_sequence << { :value => tempcode, :params => { :name => press_type, :modifiers => "0", :delay => "0" } }
124
+
125
+ end
126
+
127
+ command.command_value( key_sequence )
128
+
129
+ else
130
+
131
+ scancode = key.to_i
132
+
133
+ # raise exception if value is other than fixnum
134
+ raise ArgumentError.new( "Scan code for :%s not defined in keymap" % key ) unless scancode.kind_of?( Fixnum )
135
+
136
+ # add scancode for keypress event
137
+ command.command_value( scancode.to_s )
138
+
139
+ end
140
+
141
+ # execute command & verify that execution passed ("OK" expected as response)
142
+ @sut.execute_command(command)
143
+
144
+ #raise RuntimeError.new("Error occured during keypress (Response: %s)" % @response ) unless ( @response = @sut.execute_command(command) ) == "OK"
145
+
146
+ rescue #Exception
147
+
148
+ $logger.behaviour "FAIL;Failed press_key with key \"#{ key }\".;#{ identity };press_key;"
149
+
150
+ raise $!
151
+
152
+ end
153
+
154
+ $logger.behaviour "PASS;Operation press_key executed successfully with key \"#{ key }\".;#{ identity };press_key;"
155
+
156
+ nil
157
+
158
+ end
159
+
160
+ # enable hooking for performance measurement & debug logging
161
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
162
+
163
+ end
164
+
165
+ end
166
+ end
@@ -0,0 +1,157 @@
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
+ require 'tmpdir'
21
+ require 'base64'
22
+
23
+ module MobyBehaviour
24
+
25
+ module QT
26
+
27
+ # == description
28
+ # LocalisationDB specific behaviours
29
+ #
30
+ # == behaviour
31
+ # QtLocalisationDB
32
+ #
33
+ # == requires
34
+ # testability-driver-qt-sut-plugin
35
+ #
36
+ # == input_type
37
+ # *
38
+ #
39
+ # == sut_type
40
+ # qt
41
+ #
42
+ # == sut_version
43
+ # *
44
+ #
45
+ # == objects
46
+ # sut
47
+ #
48
+ module LocalisationDB
49
+
50
+ include MobyBehaviour::QT::Behaviour
51
+
52
+ # == description
53
+ # Creates a new localisation able for translation using the tdriver_parameters to locate the Localization DB.
54
+ # It uses the temporary folder to store temporary translation files.
55
+ # The table structure will have the different languages as columns and the comun names will be set as the
56
+ # postfix language code from the source filenames for .qm and .ts files. For .loc files, the two-digit postfix
57
+ # will be mapped to the same language codes as in .qm or .ts when possible forlowing the mapping table on
58
+ # symbian reference documentation. To see the full mapping used please check the localization.rb implementation
59
+ # file on testability-driver gem.
60
+ #
61
+ # == arguments
62
+ # path
63
+ # String
64
+ # description: Path where the translation files to upload to the database are found
65
+ # example: "/usr/me/tdriver/localization_files"
66
+ #
67
+ # file
68
+ # String
69
+ # description: File names of the translation files to be uploaded.
70
+ # example: "*.ts"
71
+ #
72
+ # database_file
73
+ # String
74
+ # description: If this is provided it will overwrite the value set in the parameter ':localisation_server_database_name'
75
+ # example: "mysqlitedb.sqlite"
76
+ #
77
+ # column_names_map
78
+ # Hash
79
+ # description: Hash with the language codes from the translation files as keys and the desired column names as values
80
+ # example: {"en" => "en_GB"}
81
+ #
82
+ # == returns
83
+ # NilClass
84
+ # description: -
85
+ # example: -
86
+ #
87
+ def create_locale_db(path = "/", file = "*.qm", database_file = nil, column_names_map = {} )
88
+
89
+ db_type = $parameters[ :localisation_db_type ]
90
+ host = $parameters[ :localisation_server_ip ]
91
+ database_file = $parameters[ :localisation_server_database_name ] if database_file.nil?
92
+ username = $parameters[ :localisation_server_username ]
93
+ password = $parameters[ :localisation_server_password ]
94
+
95
+ db_connection = MobyUtil::DBConnection.new( db_type, host, database_file, username, password )
96
+
97
+ table_name = sut_parameters[ :localisation_server_database_tablename, "" ]
98
+
99
+ begin
100
+ tmp_path = $parameters[:tmp_folder] + "/locale_db_tmp"
101
+ rescue MobyUtil::ParameterNotFoundError
102
+ tmp_path = Dir.tmpdir + "/locale_db_tmp"
103
+ end
104
+
105
+ if (File.directory? tmp_path)
106
+ FileUtils.rm_rf(tmp_path)
107
+ end
108
+
109
+ if (File.directory? tmp_path)
110
+ else
111
+ FileUtils.mkdir(tmp_path)
112
+ end
113
+
114
+ list_of_files = receive_files( path, file, tmp_path )
115
+
116
+ list_of_files.each do |e_file|
117
+ begin
118
+ MobyUtil::Localisation.upload_translation_file( e_file, table_name, db_connection, column_names_map)
119
+ rescue Exception => e
120
+ puts "Error while uploading #{e_file}."
121
+ puts e.message
122
+ end
123
+ end
124
+
125
+ nil
126
+
127
+ end
128
+
129
+ private
130
+
131
+ # == description
132
+ # Receives files from SUT
133
+ #
134
+ def receive_files( device_path, file, tmp_path )
135
+
136
+ list_of_files = fixture( "file", "list_files", {:file_name => file, :file_path => device_path} ).split(';')
137
+ new_list_of_files = Array.new
138
+
139
+ list_of_files.each do |name|
140
+ new_list_of_files.push( tmp_path + "/" + File.basename(name) )
141
+ file = File.open(tmp_path + "/" + File.basename(name), 'w')
142
+ file << Base64.decode64( fixture("file", "read_file", {:file_name => name}) )
143
+ file.close
144
+ end
145
+
146
+ return new_list_of_files
147
+
148
+ end
149
+
150
+ # enable hooking for performance measurement & debug logging
151
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
152
+
153
+ end # LocalisationDB
154
+
155
+ end # QT
156
+
157
+ end # MobyBehaviour
@@ -0,0 +1,112 @@
1
+ # -*- coding: utf-8 -*-
2
+ ############################################################################
3
+ ##
4
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5
+ ## All rights reserved.
6
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
7
+ ##
8
+ ## This file is part of TDriver.
9
+ ##
10
+ ## If you have questions regarding the use of this file, please contact
11
+ ## Nokia at testabilitydriver@nokia.com .
12
+ ##
13
+ ## This library is free software; you can redistribute it and/or
14
+ ## modify it under the terms of the GNU Lesser General Public
15
+ ## License version 2.1 as published by the Free Software Foundation
16
+ ## and appearing in the file LICENSE.LGPL included in the packaging
17
+ ## of this file.
18
+ ##
19
+ ############################################################################
20
+
21
+ module MobyBehaviour
22
+
23
+ module QT
24
+
25
+ # == description
26
+ # Method specific behaviours
27
+ #
28
+ # == behaviour
29
+ # QtMethod
30
+ #
31
+ # == requires
32
+ # testability-driver-qt-sut-plugin
33
+ #
34
+ # == input_type
35
+ # *
36
+ #
37
+ # == sut_type
38
+ # qt
39
+ #
40
+ # == sut_version
41
+ # *
42
+ #
43
+ # == objects
44
+ # *
45
+ #
46
+ module Method
47
+
48
+ include MobyBehaviour::QT::Behaviour
49
+
50
+ # == description
51
+ # Calls an invokable method of the Qt test object.
52
+ # Slots and signals are automatically invokable, but other methods must be explicitly made invokable.
53
+ #
54
+ # Warning: Use with caution - function parameters must match exactly to the Qt slot. Otherwise
55
+ # behavior is undefined.
56
+ #
57
+ # == arguments
58
+ # method_name
59
+ # String
60
+ # description: name of method to invoke, including empty parenthesis
61
+ # example: "clear()"
62
+ # *params
63
+ # Array
64
+ # description: Parameters for the method. Currently primitive types (String,Fixnum,Float, boolean) are supported.
65
+ # Must match the parameters and types of the slot.
66
+ # example: 1.2, 'Hello'
67
+ #
68
+ # == returns
69
+ # String
70
+ # description: returns slot return value, empty string if void.
71
+ # example: "1"
72
+ #
73
+ # == exceptions
74
+ # RuntimeError
75
+ # description: invoking the method failed
76
+ def call_method( method_name, *params )
77
+
78
+ raise ArgumentError.new( "Method name was empty" ) if method_name.empty?
79
+ command = command_params #in qt_behaviour
80
+ command.transitions_off
81
+ command.command_name( 'CallMethod' )
82
+
83
+ # Syntactically terrible..
84
+ pars = {'method_name' => method_name.to_s }
85
+
86
+ params.each_with_index{ |param,i|
87
+ case param
88
+ when String
89
+ key = "S"
90
+ when Fixnum
91
+ key = "I"
92
+ when Float
93
+ key = "D"
94
+ when TrueClass,FalseClass
95
+ key = "B"
96
+ else
97
+ raise ArgumentError.new( "Method parameter #{i}: Only String,Fixunum,Float and Boolean types are supported" )
98
+ end
99
+ pars["method_param#{i}"] = key+param.to_s
100
+ }
101
+ command.command_params(pars)
102
+ command.service( 'objectManipulation' )
103
+
104
+ returnValue = @sut.execute_command( command )
105
+ end
106
+
107
+ # enable hooking for performance measurement & debug logging
108
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
109
+
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,474 @@
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
+ # Behaviours for multitouch operations.
26
+ #
27
+ # == behaviour
28
+ # QtMultitouch
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 Multitouch
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ # == description
50
+ # Performs a pinch zoom in operation. The distance of the operation is
51
+ # is for both fingers. So a distance of 100 will be performed by both
52
+ # end points (fingers).
53
+ #
54
+ # == arguments
55
+ # speed
56
+ # Integer
57
+ # description: Speed of the operation in seconds
58
+ # example: 3
59
+ #
60
+ # distance
61
+ # Integer
62
+ # description: Distance of the pinch zoom
63
+ # example: 100
64
+ #
65
+ # direction
66
+ # Integer
67
+ # description: Direction of the pinch zoom in degrees 0-180
68
+ # example: 90
69
+ # Symbol
70
+ # description: Direction of the pinch zoom either :Horizontal or :Vertical
71
+ # example: :Horizontal
72
+ #
73
+ # differential
74
+ # Integer
75
+ # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
76
+ # example: 10
77
+ #
78
+ # == returns
79
+ # NilClass
80
+ # description: -
81
+ # example: -
82
+ #
83
+ # == exceptions
84
+ # ArgumentError
85
+ # description: In case the given parameters are not valid.
86
+ #
87
+ # == info
88
+ # See method pinch_zoom
89
+ #
90
+ def pinch_zoom_in(speed, distance, direction, differential = 10)
91
+
92
+ pinch_zoom({:type => :in, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
93
+
94
+ self
95
+
96
+ end
97
+
98
+ # == description
99
+ # Performs a pinch zoom out operation. The distance of the operation is
100
+ # is for both fingers. So a distance of 100 will be performed by both
101
+ # fingers.
102
+ #
103
+ # == arguments
104
+ # speed
105
+ # Integer
106
+ # description: Speed of the operation in seconds
107
+ # example: 3
108
+ #
109
+ # distance
110
+ # Integer
111
+ # description: Distance of the pinch zoom
112
+ # example: 100
113
+ #
114
+ # direction
115
+ # Integer
116
+ # description: Direction of the pinch zoom in degrees 0-180
117
+ # example: 90
118
+ # Symbol
119
+ # description: Direction of the pinch zoom either :Horizontal or :Vertical
120
+ # example: :Horizontal
121
+ #
122
+ # differential
123
+ # Integer
124
+ # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
125
+ # example: 10
126
+ #
127
+ # == returns
128
+ # NilClass
129
+ # description: -
130
+ # example: -
131
+ #
132
+ # == exceptions
133
+ # ArgumentError
134
+ # description: In case the given parameters are not valid.
135
+ #
136
+ # == info
137
+ # See method pinch_zoom
138
+ #
139
+ def pinch_zoom_out(speed, distance, direction, differential = 10)
140
+
141
+ pinch_zoom({:type => :out, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
142
+
143
+ self
144
+
145
+ end
146
+
147
+ # == description
148
+ # Causes a pinch zoom gesture on the object. The type of the pinch is based on the given parameters.
149
+ # The parameters make it possible to define various kinds of pinch zoom operations.
150
+ #
151
+ # The image shows how the different parameters will be used to make the pinch gesture.
152
+ # The image show a zoom in type gesture (:type => :in). Direction is the angle of the
153
+ # first part of the pinch gesture against the y axel (0 degrees is up). Distance variables
154
+ # do not have to be the same. This means that you can set the gesture so that one finger
155
+ # moves a longer distance than the other (or even set one distance to 0).
156
+ # The :differential parameter determines the how close the nearest points
157
+ # in the pinch gesture are (:in start points and :out end points).
158
+ # The center points can be set using the :x and :y setting.
159
+ # The values are relative to the object and if not set then the center point of the object is used.
160
+ # \n
161
+ # [img="images/pinch.png"]Pinch zoom parameters[/img]
162
+ #
163
+ # == arguments
164
+ # params
165
+ # Hash
166
+ # description:
167
+ # A Hash table contains all of the parameters required to make the pinch zoom.
168
+ # See [link="#pinch_options_table"]Pinch options table[/link] for valid keys.
169
+ # example: pinch_zoom({:type => :in, :speed => 2, :distance_1 => 100, :distance_2 => 100, :direction => :Vertical, :differential => 10})
170
+ #
171
+ # == tables
172
+ # pinch_options_table
173
+ # title: Pinch options table
174
+ # |Key|Type|Description|Accepted values|Example|Required|
175
+ # |:type|Symbol|Zoom in or out|:in,:out|:type => :in|Yes|
176
+ # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
177
+ # |:distance_1|Integer|Distance of the first finger zoom gesture|Positive integer|:distance_1 => 100|Yes|
178
+ # |:distance_2|Integer|Distance of the second finger zoom gesture|Positive integer|:distance_2 => 100|Yes|
179
+ # |:differential|Integer|The difference from where the zoom starts or ends|Positive integer|:differential => 10|Yes|
180
+ # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer| :x => 120|No|
181
+ # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 200|No|
182
+ #
183
+ # == returns
184
+ # NilClass
185
+ # description: -
186
+ # example: -
187
+ #
188
+ # == exceptions
189
+ # ArgumentError
190
+ # description: In case the given parameters are not valid.
191
+ #
192
+ def pinch_zoom( params )
193
+
194
+ begin
195
+ verify_pinch_params!(params)
196
+
197
+ #convert speed to millis
198
+ time = params[:speed].to_f
199
+ speed = time*1000
200
+ params[:speed] = speed.to_i
201
+ if params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
202
+ params[:useCoordinates] = 'true'
203
+ params[:x] = attribute('x_absolute').to_i + params[:x]
204
+ params[:y] = attribute('y_absolute').to_i + params[:y]
205
+ end
206
+ command = command_params #in qt_behaviour
207
+ command.command_name('PinchZoom')
208
+ command.command_params(params)
209
+
210
+ @sut.execute_command( command )
211
+
212
+ #wait untill the pinch is finished
213
+ do_sleep(time)
214
+
215
+ rescue Exception => e
216
+ $logger.behaviour "FAIL;Failed pinch_zoom with params \"#{ params.inspect }\".;#{ identity };pinch_zoom;"
217
+ raise e
218
+ end
219
+
220
+ $logger.behaviour "PASS;Operation pinch_zoom succeeded with params \"#{ params.inspect }\".;#{ identity };pinch_zoom;"
221
+
222
+ self
223
+
224
+ end
225
+
226
+ # == description
227
+ # Causes rotation motion on the object. The rotation will be so that one point is stationary
228
+ # while other moves to create a rotation motion (like a hinge).
229
+ #
230
+ # == arguments
231
+ # radius
232
+ # Integer
233
+ # description: Radius of the of the rotation in degrees (distance between the points)
234
+ # example: 100
235
+ #
236
+ # start_angle
237
+ # Integer
238
+ # description: Starting angle of the rotation. Integer from 0-360
239
+ # example: 90
240
+ # Symbol
241
+ # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
242
+ # example: :Horizontal
243
+ #
244
+ # rotate_direction
245
+ # Symbol
246
+ # description: Rotation direction :Clockwise or :CounterClockwise.
247
+ # example: :CounterClockwise
248
+ #
249
+ # distance
250
+ # Integer
251
+ # description: Distance of the rotation in degrees
252
+ # example: 360
253
+ #
254
+ # speed
255
+ # Integer
256
+ # description: Speed in seconds
257
+ # example: 3
258
+ #
259
+ # center_point
260
+ # Hash
261
+ # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
262
+ # In one point rotation the other end point will remain stationary (the rotation is done around that point)
263
+ # and that will be the given point. If not given the point will be the center of the object.
264
+ # example: {:x => 50, :y => 100}
265
+ #
266
+ # == returns
267
+ # NilClass
268
+ # description: -
269
+ # example: -
270
+ #
271
+ #
272
+ # == exceptions
273
+ # ArgumentError
274
+ # description: In case the given parameters are not valid.
275
+ #
276
+ # == info
277
+ # See [link="#QtMultitouch:rotate"]rotate[/link] method for more details
278
+ #
279
+ def one_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
280
+ params = {:type => :one_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
281
+ params.merge!(center_point) if center_point
282
+ rotate(params)
283
+ self
284
+ end
285
+
286
+ # == description
287
+ # Causes ratation motion on the object. The rotation will be so that both ends move to create a rotation motion around a point.
288
+ #
289
+ # == arguments
290
+ # radius
291
+ # Integer
292
+ # description: Radius of the of the rotation in degrees (distance between the points)
293
+ # example: 100
294
+ #
295
+ # start_angle
296
+ # Integer
297
+ # description: Starting angle of the rotation. Integer from 0-360
298
+ # example: 90
299
+ # Symbol
300
+ # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
301
+ # example: :Horizontal
302
+ #
303
+ # rotate_direction
304
+ # Symbol
305
+ # description: Rotation direction :Clockwise or :CounterClockwise.
306
+ # example: :CounterClockwise
307
+ #
308
+ # distance
309
+ # Integer
310
+ # description: Distance of the rotation in degrees
311
+ # example: 360
312
+ #
313
+ # speed
314
+ # Integer
315
+ # description: Speed in seconds
316
+ # example: 3
317
+ #
318
+ # center_point
319
+ # Hash
320
+ # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
321
+ # In two point rotation both end points will rotate around a center point which will be
322
+ # the given point. If not given the point will be the center of the object.
323
+ # example: {:x => 50, :y => 100}
324
+ #
325
+ # == returns
326
+ # NilClass
327
+ # description: -
328
+ # example: -
329
+ #
330
+ # == exceptions
331
+ #
332
+ # ArgumentError
333
+ # description: In case the given parameters are not valid.
334
+ #
335
+ # == info
336
+ # See method rotate
337
+ #
338
+ def two_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
339
+ params = {:type => :two_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
340
+ params.merge!(center_point) if center_point
341
+ rotate(params)
342
+ self
343
+ end
344
+
345
+ # == description
346
+ # Causes a rotate motion on the screen using two fingers (e.g. like turning a knob). Similar gesture to pinch zooming except the angle changes.
347
+ # \n
348
+ # \n
349
+ # [img="images/rotate.png"]Rotation parameters[/img]
350
+ # \n
351
+ # The image shows how the different parameters will be used to make the rotation gestures in both
352
+ # one point and two point rotations. In one point rotation the other end remains stationary while
353
+ # the other moves around it based on the given radius. In two point rotation the movement is done
354
+ # by both ends. Note the direction paramters as the :direction parameter defines the starting angle
355
+ # for the gesture and :rotation_direction defines the actual rotation direction (clockwise or counter clockwise).
356
+ # When performing two point rotation note that the radius is in fact a radius not the diameter.
357
+ # Distance is given in degrees from 0-360. Center point can be set using :x and :y and if
358
+ # not set the center point of the object will be used.
359
+ #
360
+ # == arguments
361
+ # params
362
+ # Hash
363
+ # description: A hash of the parameters that define the rotation. See [link="#rotate_options_table"]Rotate options table[/link] for valid keys
364
+ #
365
+ # example: {:type => :one_point, :radius => 100, :rotate_direction => :Clockwise, :distance => 45, :speed => 2, :direction => 35, :x => 2, y => 35}
366
+ #
367
+ # == tables
368
+ # rotate_options_table
369
+ # title: Rotate options table
370
+ # |Key|Type|Description|Accepted values|Example|Required|
371
+ # |:type|Symbol|Rotation type|:one_point,:two_point|:type => :one_point|Yes|
372
+ # |:radius|Integer|Radius of the rotatation in pixels|Any positive Integer|:radius => 100|Yes|
373
+ # |:rotation_direction|Symbol|Rotation direction|:Clockwise, :CounterClockwise|:rotate_direction => :Clockwise|Yes|
374
+ # |:distance|Integer|Rotation distance in degrees|0-360|:distance => 90|Yes|
375
+ # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
376
+ # |:direction|Integer/Symbol|The start angle of the rotation.|0-360 or :Horizontal, :Vertical|:direction => 35|Yes|
377
+ # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer|:x => 50|No|
378
+ # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 120|No|
379
+ #
380
+ #
381
+ # == returns
382
+ # NilClass
383
+ # description: -
384
+ # example: -
385
+ #
386
+ # == exceptions
387
+ #
388
+ # ArgumentError
389
+ # description: In case the given parameters are not valid.
390
+ #
391
+ def rotate(params)
392
+
393
+ begin
394
+
395
+ verify_rotate_params!(params)
396
+
397
+ time = params[:speed].to_f
398
+
399
+ params[:speed] = (time * 1000).to_i
400
+
401
+
402
+ if params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
403
+ params[:useCoordinates] = 'true'
404
+ params[:x] = attribute('x_absolute').to_i + params[:x]
405
+ params[:y] = attribute('y_absolute').to_i + params[:y]
406
+ end
407
+
408
+ command = command_params #in qt_behaviour
409
+ command.command_name('Rotate')
410
+ command.command_params(params)
411
+
412
+ @sut.execute_command( command )
413
+
414
+ #wait untill the operation to finish
415
+ do_sleep( time )
416
+ rescue Exception => e
417
+ $logger.behaviour "FAIL;Failed rotate with params \"#{ params.inspect }\".;#{ identity };rotate;"
418
+ raise e
419
+ end
420
+
421
+ $logger.behaviour "PASS;Operation rotate succeeded with params \"#{ params.inspect }\".;#{ identity };rotate;"
422
+
423
+ self
424
+
425
+ end
426
+
427
+ private
428
+
429
+ def verify_rotate_params!(params)
430
+ raise ArgumentError.new( "Invalid type allowed valued(:sector, :acrs)." ) unless params[:type] == :one_point or params[:type] == :two_point
431
+ raise ArgumentError.new("Speed must be a number.") unless params[:speed].kind_of?(Numeric)
432
+
433
+ #direction
434
+ if params[:direction].kind_of?(Integer)
435
+ raise ArgumentError.new("Direction must be between 0 and 360.") unless params[:direction] >= 0 and params[:direction] < 360
436
+ else
437
+ raise ArgumentError.new( "Invalid direction." ) unless @@_pinch_directions.include?(params[:direction])
438
+ params[:direction] = @@_pinch_directions[params[:direction]]
439
+ end
440
+
441
+ raise ArgumentError.new("Distance must be an integer.") unless params[:distance].kind_of?(Integer)
442
+ raise ArgumentError.new("Distance must be between 0 and 360") unless params[:distance] > 0 and params[:distance] <= 360
443
+
444
+ raise ArgumentError.new("Invalid direction must be " + @@_rotate_direction.to_s) unless @@_rotate_direction.include?(params[:rotate_direction])
445
+ raise ArgumentError.new("Radius must be an integer.") unless params[:radius].kind_of?(Integer)
446
+ end
447
+
448
+ def verify_pinch_params!(params)
449
+ #type
450
+ raise ArgumentError.new( "Invalid type allowed valued(:in, :out)." ) unless params[:type] == :in or params[:type] == :out
451
+ #speed
452
+ raise ArgumentError.new("Speed must be a number.") unless params[:speed].kind_of?(Numeric)
453
+ #distance
454
+ raise ArgumentError.new("Distance 1 must be an integer.") unless params[:distance_1].kind_of?(Integer)
455
+ raise ArgumentError.new("Distance 2 must be an integer.") unless params[:distance_2].kind_of?(Integer)
456
+ #direction
457
+ if params[:direction].kind_of?(Integer)
458
+ raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction].to_i and params[:direction].to_i <= 180
459
+ else
460
+ raise ArgumentError.new( "Invalid direction." ) unless @@_pinch_directions.include?(params[:direction])
461
+ params[:direction] = @@_pinch_directions[params[:direction]]
462
+ end
463
+ #differential
464
+ raise ArgumentError.new("Differential must be an integer.") unless params[:differential].kind_of?(Integer)
465
+ end
466
+
467
+ # enable hooking for performance measurement & debug logging
468
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
469
+
470
+ end # Multitouch
471
+
472
+ end # QT
473
+
474
+ end # MobyBehaviour