Module: MobyUtil::MessageComposer
- Included in:
- MobyController::QT::Application, MobyController::QT::Fixture
- Defined in:
- lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb
Defined Under Namespace
Classes: TasCommands
Instance Method Summary collapse
- #close_message ⇒ Object
- #encode_string(source) ⇒ Object
- #hash_to_attributes(hash) ⇒ Object
- #make_filters ⇒ Object
- #make_fixture_message(fixture_plugin, params) ⇒ Object
-
#make_parametrized_message(service_details, command_name, params, command_params = {}) ⇒ Object
TasCommands.
- #make_xml_message(service_details, command_name, params, command_value = nil) ⇒ Object
- #run_message ⇒ Object
- #state_message ⇒ Object
Instance Method Details
#close_message ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 350 def sut_parameters = $parameters[ @_sut.id ] parameters = { 'uid' => @_application_uid, 'kill' => ( @_flags || {} )[ :force_kill ] || sut_parameters[ :application_close_kill ], 'wait_time' => sut_parameters[ :application_close_wait ] } ({:service => 'closeApplication', :id => @_application_uid }, 'Close', parameters) end |
#encode_string(source) ⇒ Object
253 254 255 256 257 258 259 260 261 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 253 def encode_string( source ) source = source.to_s source.gsub!( '&', '&' ); source.gsub!( '>', '>' ); source.gsub!( '<', '<' ); source.gsub!( '"', '"' ); source.gsub!( '\'', ''' ); source end |
#hash_to_attributes(hash) ⇒ Object
195 196 197 198 199 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 195 def hash_to_attributes( hash ) ( hash || {} ).collect{ | value | "#{ value.first }=\"#{ value.last }\"" }.join(" ") end |
#make_filters ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 263 def make_filters params = {} # get sut paramteres only once, store to local variable sut_parameters = $parameters[ @_sut.id ] params[ 'filterProperties' ] = $last_parameter if sut_parameters[ :filter_properties, nil ] params[ 'pluginBlackList' ] = $last_parameter if sut_parameters[ :plugin_blacklist, nil ] params[ 'pluginWhiteList' ] = $last_parameter if sut_parameters[ :plugin_whitelist, nil ] params[ 'useViewCrop' ] = "true" if sut_parameters[ :use_crop_view, nil ] case sut_parameters[ :filter_type, 'none' ] when 'dynamic' white_list = TDriver::AttributeFilter.filter_string params['attributeWhiteList'] = white_list if white_list when 'static' params['attributeBlackList'] = $last_parameter if sut_parameters[ :attribute_blacklist, nil ] params['attributeWhiteList'] = $last_parameter if sut_parameters[ :attribute_whitelist, nil ] end params end |
#make_fixture_message(fixture_plugin, params) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 237 def (fixture_plugin, params) service_details[:plugin_timeout] = $parameters[ @_sut.id ][ :qttas_plugin_timeout, 10000 ] if @_sut Nokogiri::XML::Builder.new{ TasCommands( :id => params[:application_id].to_s, :service => "fixture", :async => params[:async].to_s ) { Target( :TasId => params[:object_id].to_s, :type => params[:object_type].to_s ) { Command( :name => "Fixture", :plugin => fixture_plugin, :method => params[:command_name].to_s ) { params[:parameters].collect{ | name, value | param( :name => name, :value => value ) } } } } }.to_xml end |
#make_parametrized_message(service_details, command_name, params, command_params = {}) ⇒ Object
TasCommands
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 178 def ( service_details, command_name, params, command_params = {} ) service_details[:plugin_timeout] = $parameters[ @_sut.id ][ :qttas_plugin_timeout, 10000 ] if @_sut Nokogiri::XML::Builder.new{ TasCommands( service_details ) { Target( :TasId => "Application" ) { Command( ( params || {} ).merge( :name => command_name ) ){ command_params.collect{ | name, value | param( :name => name, :value => value ) } } } } }.to_xml end |
#make_xml_message(service_details, command_name, params, command_value = nil) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 201 def ( service_details, command_name, params, command_value = nil ) service_details[:plugin_timeout] = $parameters[ @_sut.id ][ :qttas_plugin_timeout, 10000 ] if @_sut =begin # create message as string #MobyUtil::MessageComposer::hash_to_attributes 140 0.00405100 0.00405100 0.010% 0.00002894 #MobyUtil::MessageComposer::make_xml_message 70 0.00762200 0.00357100 0.009% 0.00010889 "<TasCommands #{ hash_to_attributes( service_details ) }>" << "<Target TasId=\"Application\">" << "<Command name=\"#{ command_name }\" #{ hash_to_attributes( params ) }#{ command_value ? ">#{ command_value }</Command>" : " />" }" << "</Target>" << "</TasCommands>" # vs. # create message using builder #MobyUtil::MessageComposer::make_xml_message 70 0.03611100 0.03611100 0.090% 0.00051587 # create message MobyUtil::XML.build{ TasCommands( service_details ) { Target( :TasId => "Application" ) { Command( command_value || "", ( params || {} ).merge( :name => command_name ) ) } } }.to_xml =end # construct xml message as string; using builder is approx. 67% slower, see statistics above "<TasCommands #{ hash_to_attributes( service_details ) }><Target TasId=\"Application\"><Command name=\"#{ command_name }\" #{ hash_to_attributes( params ) }#{ command_value ? ">#{ command_value }</Command>" : " />" }</Target></TasCommands>" end |
#run_message ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 325 def #clone to not make changes permanent arguments = $parameters[ @_sut.id ][ :application_start_arguments, "" ].clone if @_arguments arguments << "," unless arguments.empty? arguments << @_arguments end parameters = { 'application_path' => @_application_name, 'arguments' => arguments, 'environment' => @_environment, 'directory' => @_working_directory, 'events_to_listen' => @_events_to_listen, 'signals_to_listen' => @_signals_to_listen, 'start_command' => @_start_command } #set search search_path = $parameters[ @_sut.id ][ :app_path, nil ] parameters[:app_path] = search_path if search_path ({:service => 'startApplication'}, 'Run', parameters) end |
#state_message ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb', line 293 def app_details = { :service => 'uiState', :name => @_application_name, :id => @_application_uid } app_details[ :applicationUid ] = @_refresh_args[ :applicationUid ] if @_refresh_args.include?( :applicationUid ) app_details[ :checksum ] = @_checksum unless @_checksum.nil? params = @_flags || {} case $parameters[ @_sut.id ][ :filter_type, 'none' ] when 'none' command_xml = ( app_details, 'UiState', params ) when 'dynamic' params[ :filtered ] = 'true' command_xml = ( app_details, 'UiState', params, make_filters ) else command_xml = ( app_details, 'UiState', params, make_filters ) end command_xml end |