testability-driver-qt-sut-plugin 0.9.2 → 1.0.0
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.
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +11 -8
- 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 +76 -74
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +2 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +10 -4
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +49 -42
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +0 -9
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +5 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +11 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +441 -324
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +32 -11
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +54 -34
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +26 -26
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +61 -21
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +528 -344
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +16 -138
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +3 -67
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +4 -18
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +166 -149
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +80 -75
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +93 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +161 -0
- data/xml/behaviour/qt.xml +26 -26
- data/xml/template/qt.xml +9 -7
- metadata +7 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +0 -45
@@ -21,90 +21,95 @@ require 'zlib'
|
|
21
21
|
|
22
22
|
module MobyController
|
23
23
|
|
24
|
-
|
24
|
+
module QT
|
25
25
|
|
26
|
-
|
26
|
+
module Comms
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# Command types
|
29
|
+
ERROR_MSG = 0
|
30
|
+
VALID_MSG = 1
|
31
|
+
OK_MESSAGE = "OK"
|
32
32
|
|
33
|
-
|
33
|
+
class Inflator
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def self.inflate( response )
|
36
|
+
# strip 4 extra bytes written by qt compression, return empty string if no raw data found, otherwise inflate it
|
37
|
+
( raw_data = response[ 4 .. -1 ] ).empty? ? "" : Zlib::Inflate.inflate( raw_data )
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
# enable hooking for performance measurement & debug logging
|
41
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
42
42
|
|
43
|
-
|
43
|
+
end
|
44
44
|
|
45
45
|
# deprecated: see send_service_request#adapter.rb
|
46
|
-
|
47
|
-
|
46
|
+
# Wrapper for protocol message.
|
47
|
+
class QTResponse
|
48
48
|
|
49
|
-
|
49
|
+
attr_accessor :msg_body, :flag, :crc, :message_id
|
50
50
|
|
51
51
|
# deprecated: see send_service_request#adapter.rb
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
# Initialize QT Response.
|
53
|
+
# == params
|
54
|
+
# command_flag Indicator flad for message type (error or ok)
|
55
|
+
# message_code 0 or an error code
|
56
|
+
# msg_body Body of the message. For command a simple "OK" message for ui state the xml document as string
|
57
|
+
# == returns
|
58
|
+
def initialize( command_flag, msg_body, crc, message_id )
|
59
59
|
|
60
60
|
|
61
|
-
|
61
|
+
@flag, @msg_body, @crc, @message_id = command_flag, msg_body, crc, message_id
|
62
62
|
|
63
|
-
|
63
|
+
end
|
64
64
|
|
65
65
|
# deprecated: see send_service_request#adapter.rb
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
66
|
+
def validate_message( msg_id )
|
67
|
+
|
68
|
+
#check that response matches the request
|
69
|
+
if @message_id != msg_id
|
70
|
+
|
71
|
+
MobyUtil::Logger.instance.log "fatal" , "Response to request did not match: \"#{@message_id}\"!=\"#{msg_id.to_s}\""
|
72
|
+
MobyUtil::Logger.instance.log "fatal" , @msg_body
|
73
|
+
|
74
|
+
Kernel::raise RuntimeError.new("Response to request did not match: \"#{@message_id}\"!=\"#{msg_id.to_s}\"")
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
#raise error if error flag
|
79
|
+
if @flag == Comms::ERROR_MSG
|
80
|
+
if @msg_body =~ /The application with Id \d+ is no longer available/
|
81
|
+
Kernel::raise MobyBase::ApplicationNotAvailableError.new( @msg_body)
|
82
|
+
else
|
83
|
+
Kernel::raise RuntimeError.new( @msg_body )
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
82
87
|
|
83
|
-
|
84
|
-
|
88
|
+
# enable hooking for performance measurement & debug logging
|
89
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
85
90
|
|
86
|
-
|
91
|
+
end #class
|
87
92
|
|
88
|
-
|
89
|
-
|
93
|
+
# Message generator for qt tas messages
|
94
|
+
class MessageGenerator
|
90
95
|
|
91
|
-
|
96
|
+
def self.generate( message_data, message_flag = VALID_MSG )
|
92
97
|
|
93
|
-
|
98
|
+
MobyController::QT::Comms::QtMessage.new( message_flag, message_data )
|
94
99
|
|
95
|
-
|
100
|
+
end
|
96
101
|
|
97
|
-
|
98
|
-
|
102
|
+
# enable hooking for performance measurement & debug logging
|
103
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
99
104
|
|
100
|
-
|
105
|
+
end
|
101
106
|
|
102
|
-
|
107
|
+
class QtMessage
|
103
108
|
|
104
|
-
|
105
|
-
|
109
|
+
attr_reader :flag, :data, :crc, :compression, :size
|
110
|
+
attr_accessor :message_id
|
106
111
|
|
107
|
-
|
112
|
+
def initialize( message_flag, message_data )
|
108
113
|
# message flag
|
109
114
|
@flag = message_flag
|
110
115
|
|
@@ -116,23 +121,23 @@ module MobyController
|
|
116
121
|
|
117
122
|
# calculate outgoing message crc; sent in message header to receiver for data validation
|
118
123
|
@crc = CRC::Crc16.crc16_ibm( @data, 0xffff )
|
119
|
-
|
124
|
+
end
|
120
125
|
|
121
|
-
|
126
|
+
def make_binary_message( message_id )
|
122
127
|
|
123
|
-
|
128
|
+
[ @flag, @size, @crc, @compression, message_id, @data ].pack( 'CISCIa*' )
|
124
129
|
|
125
|
-
|
130
|
+
end
|
126
131
|
|
127
|
-
|
128
|
-
|
129
|
-
|
132
|
+
def compression
|
133
|
+
@compression
|
134
|
+
end
|
130
135
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
+
def deflate
|
137
|
+
@compression = 2
|
138
|
+
#qUncompress required the data length at the beginning so append it
|
139
|
+
#the bytes need to be arranged in the below method (see QByteArray::qUncompress)
|
140
|
+
@data = [
|
136
141
|
(@data.size & 0xff000000) >> 24, (@data.size & 0x00ff0000) >> 16,
|
137
142
|
(@data.size & 0x0000ff00) >> 8, (@data.size & 0x000000ff),
|
138
143
|
Zlib::Deflate.deflate( @data, 9)
|
@@ -141,14 +146,14 @@ module MobyController
|
|
141
146
|
# update data size
|
142
147
|
@size = @data.size
|
143
148
|
|
144
|
-
|
149
|
+
end
|
145
150
|
|
146
|
-
|
147
|
-
|
151
|
+
# enable hooking for performance measurement & debug logging
|
152
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
148
153
|
|
149
|
-
|
154
|
+
end # class
|
150
155
|
|
151
|
-
|
156
|
+
end # module Comms
|
152
157
|
|
153
|
-
|
158
|
+
end
|
154
159
|
end
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb
ADDED
@@ -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 MobyUtil
|
23
|
+
|
24
|
+
module FindObjectGenerator
|
25
|
+
|
26
|
+
def generate_message
|
27
|
+
filters = make_params if MobyUtil::Parameter[ @_sut.id ][ :filter_type, 'none' ] == 'dynamic'
|
28
|
+
|
29
|
+
params = search_parameters
|
30
|
+
|
31
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
32
|
+
xml.TasCommands( ( application_details || {} ).merge( :service => "findObject") ) {
|
33
|
+
xml.Target{
|
34
|
+
add_objects(xml, params)
|
35
|
+
xml.Command( :name => 'findObject' ){
|
36
|
+
filters.collect{ | name, value |
|
37
|
+
xml.param( :name => name, :value => value )
|
38
|
+
}
|
39
|
+
} if MobyUtil::Parameter[ @_sut.id ][ :filter_type, 'none' ] == 'dynamic'
|
40
|
+
} if params and params.size > 0
|
41
|
+
}
|
42
|
+
end
|
43
|
+
builder.to_xml
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def add_objects(builder, params)
|
49
|
+
parent = builder.parent
|
50
|
+
params.each{|objectParams| parent = create_object_node(builder, objectParams, parent)}
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_object_node(builder, params, parent)
|
54
|
+
node = Nokogiri::XML::Node.new('object', builder.doc)
|
55
|
+
params.keys.each{|key| node[key.to_s] = params[key].to_s}
|
56
|
+
parent.add_child(node)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def make_params
|
61
|
+
params = {}
|
62
|
+
|
63
|
+
# get sut paramteres only once, store to local variable
|
64
|
+
sut_parameters = MobyUtil::Parameter[ @_sut.id ]
|
65
|
+
|
66
|
+
params[ 'filterProperties' ] = $last_parameter if sut_parameters[ :filter_properties, nil ]
|
67
|
+
params[ 'pluginBlackList' ] = $last_parameter if sut_parameters[ :plugin_blacklist, nil ]
|
68
|
+
params[ 'pluginWhiteList' ] = $last_parameter if sut_parameters[ :plugin_whitelist, nil ]
|
69
|
+
|
70
|
+
case sut_parameters[ :filter_type, 'none' ]
|
71
|
+
|
72
|
+
when 'dynamic'
|
73
|
+
|
74
|
+
# updates the filter with the current backtrace file list
|
75
|
+
MobyUtil::DynamicAttributeFilter.instance.update_filter( caller( 0 ) )
|
76
|
+
|
77
|
+
white_list = MobyUtil::DynamicAttributeFilter.instance.filter_string
|
78
|
+
params['attributeWhiteList'] = white_list if white_list
|
79
|
+
|
80
|
+
when 'static'
|
81
|
+
|
82
|
+
params['attributeBlackList'] = $last_parameter if sut_parameters[ :attribute_blacklist, nil ]
|
83
|
+
params['attributeWhiteList'] = $last_parameter if sut_parameters[ :attribute_whitelist, nil ]
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
params
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,161 @@
|
|
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 MobyUtil
|
23
|
+
|
24
|
+
module MessageComposer
|
25
|
+
|
26
|
+
def make_parametrized_message( service_details, command_name, params, command_params = {} )
|
27
|
+
|
28
|
+
Nokogiri::XML::Builder.new{
|
29
|
+
TasCommands( service_details ) {
|
30
|
+
Target( :TasId => "Application" ) {
|
31
|
+
Command( ( params || {} ).merge( :name => command_name ) ){
|
32
|
+
command_params.collect{ | name, value |
|
33
|
+
param( :name => name, :value => value )
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}.to_xml
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def make_xml_message( service_details, command_name, params, command_value = nil )
|
43
|
+
|
44
|
+
Nokogiri::XML::Builder.new{
|
45
|
+
TasCommands( service_details ) {
|
46
|
+
Target( :TasId => "Application" ) {
|
47
|
+
Command( command_value || "", ( params || {} ).merge( :name => command_name ) )
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}.to_xml
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def make_fixture_message(fixture_plugin, params)
|
55
|
+
Nokogiri::XML::Builder.new{
|
56
|
+
TasCommands( :id => params[:application_id].to_s, :service => "fixture", :async => params[:async].to_s ) {
|
57
|
+
Target( :TasId => params[:object_id].to_s, :type => params[:object_type].to_s ) {
|
58
|
+
Command( :name => "Fixture", :plugin => fixture_plugin, :method => params[:command_name].to_s ) {
|
59
|
+
params[:parameters].collect{ | name, value |
|
60
|
+
param( :name => name, :value => value )
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}.to_xml
|
66
|
+
end
|
67
|
+
|
68
|
+
def encode_string( source )
|
69
|
+
source = source.to_s
|
70
|
+
source.gsub!( '&', '&' );
|
71
|
+
source.gsub!( '>', '>' );
|
72
|
+
source.gsub!( '<', '<' );
|
73
|
+
source.gsub!( '"', '"' );
|
74
|
+
source.gsub!( '\'', ''' );
|
75
|
+
source
|
76
|
+
end
|
77
|
+
|
78
|
+
def make_filters
|
79
|
+
|
80
|
+
params = {}
|
81
|
+
|
82
|
+
# get sut paramteres only once, store to local variable
|
83
|
+
sut_parameters = MobyUtil::Parameter[ @_sut.id ]
|
84
|
+
|
85
|
+
params[ 'filterProperties' ] = $last_parameter if sut_parameters[ :filter_properties, nil ]
|
86
|
+
params[ 'pluginBlackList' ] = $last_parameter if sut_parameters[ :plugin_blacklist, nil ]
|
87
|
+
params[ 'pluginWhiteList' ] = $last_parameter if sut_parameters[ :plugin_whitelist, nil ]
|
88
|
+
|
89
|
+
case sut_parameters[ :filter_type, 'none' ]
|
90
|
+
|
91
|
+
when 'dynamic'
|
92
|
+
|
93
|
+
# updates the filter with the current backtrace file list
|
94
|
+
MobyUtil::DynamicAttributeFilter.instance.update_filter( caller( 0 ) )
|
95
|
+
|
96
|
+
white_list = MobyUtil::DynamicAttributeFilter.instance.filter_string
|
97
|
+
params['attributeWhiteList'] = white_list if white_list
|
98
|
+
|
99
|
+
when 'static'
|
100
|
+
|
101
|
+
params['attributeBlackList'] = $last_parameter if sut_parameters[ :attribute_blacklist, nil ]
|
102
|
+
params['attributeWhiteList'] = $last_parameter if sut_parameters[ :attribute_whitelist, nil ]
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
params
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def state_message
|
111
|
+
app_details = { :service => 'uiState', :name => @_application_name, :id => @_application_uid }
|
112
|
+
app_details[ :applicationUid ] = @_refresh_args[ :applicationUid ] if @_refresh_args.include?( :applicationUid )
|
113
|
+
|
114
|
+
case MobyUtil::Parameter[ @_sut.id ][ :filter_type, 'none' ]
|
115
|
+
when 'none'
|
116
|
+
command_xml = make_xml_message( app_details, 'UiState', @_flags || {} )
|
117
|
+
when 'dynamic'
|
118
|
+
params = @_flags || {}
|
119
|
+
params[ :filtered ] = 'true'
|
120
|
+
command_xml = make_parametrized_message( app_details, 'UiState', params, make_filters )
|
121
|
+
else
|
122
|
+
command_xml = make_parametrized_message( app_details, 'UiState', @_flags || {}, make_filters )
|
123
|
+
end
|
124
|
+
command_xml
|
125
|
+
end
|
126
|
+
|
127
|
+
def run_message
|
128
|
+
#clone to not make changes permanent
|
129
|
+
arguments = MobyUtil::Parameter[ @_sut.id ][ :application_start_arguments, "" ].clone
|
130
|
+
if @_arguments
|
131
|
+
arguments << "," unless arguments.empty?
|
132
|
+
arguments << @_arguments
|
133
|
+
end
|
134
|
+
|
135
|
+
parameters = {
|
136
|
+
'application_path' => @_application_name,
|
137
|
+
'arguments' => arguments,
|
138
|
+
'environment' => @_environment,
|
139
|
+
'events_to_listen' => @_events_to_listen,
|
140
|
+
'signals_to_listen' => @_signals_to_listen,
|
141
|
+
'start_command' => @_start_command
|
142
|
+
}
|
143
|
+
|
144
|
+
make_xml_message({:service => 'startApplication'}, 'Run', parameters)
|
145
|
+
end
|
146
|
+
|
147
|
+
def close_message
|
148
|
+
sut_id = @_sut.id
|
149
|
+
|
150
|
+
parameters = {
|
151
|
+
'uid' => @_application_uid,
|
152
|
+
'kill' => ( @_flags || {} )[ :force_kill ] || MobyUtil::Parameter[ sut_id ][ :application_close_kill ],
|
153
|
+
'wait_time' => MobyUtil::Parameter[ sut_id ][ :application_close_wait ]
|
154
|
+
}
|
155
|
+
|
156
|
+
make_xml_message({:service => 'closeApplication', :id => @_application_uid }, 'Close', parameters)
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|