testability-driver-qt-sut-plugin 1.3.0 → 1.3.1

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.
@@ -72,6 +72,7 @@ module MobyBehaviour
72
72
  def enable_events(filter_array = nil, params = {})
73
73
 
74
74
  begin
75
+
75
76
  command = plugin_command #in qt_behaviour
76
77
  command.command_name( 'EnableEvents' )
77
78
  params_str = ''
@@ -81,15 +82,18 @@ module MobyBehaviour
81
82
  command.service( 'collectEvents' )
82
83
  @sut.execute_command( command)
83
84
  @@_events_enabled = true
84
- rescue Exception => e
85
+
86
+ rescue
85
87
 
86
88
  $logger.behaviour "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
87
- Kernel::raise e
89
+ raise $!
88
90
 
89
91
  end
90
92
 
91
93
  $logger.behaviour "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
94
+
92
95
  nil
96
+
93
97
  end
94
98
 
95
99
  # == description
@@ -104,37 +108,46 @@ module MobyBehaviour
104
108
  # Exception
105
109
  # description: In case of an error
106
110
  #
107
- def disable_events()
111
+ def disable_events
108
112
 
109
113
  begin
114
+
110
115
  command = plugin_command #in qt_behaviour
111
116
  command.command_name( 'DisableEvents' )
112
117
  command.service( 'collectEvents' )
113
118
  @sut.execute_command( command)
114
119
  @@_events_enabled = false
115
- rescue Exception => e
120
+
121
+ rescue
122
+
116
123
  $logger.behaviour "FAIL;Failed disable_events.;#{ identity };disable_events;"
117
- Kernel::raise e
124
+
125
+ raise $!
126
+
118
127
  end
119
128
 
120
129
  $logger.behaviour "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
130
+
121
131
  nil
122
132
 
123
133
  end
124
134
 
125
135
  # == description
126
- # Gets event list occured since the enabling of events. The format of the XML string is the same as with the UI state.
136
+ # Gets event list occured since the enabling of events. The format of the XML string is the same as with the UI state.\n
137
+ # [b]NOTE:[/b] It is highly recommended to create a StateObject with result XML and access the data through appropriate API.\n
138
+ # \n
139
+ # See [link="#GenericSut:state_object"]state_object[/link] method for more details.
127
140
  #
128
141
  # == returns
129
142
  # String
130
- # description: Xml listing containing the details of the events logger since enable_events
143
+ # description: XML containing the details of the events logger since enable_events
131
144
  # example: -
132
145
  #
133
146
  # == exceptions
134
147
  # Exception
135
148
  # description: In case of an error
136
149
  #
137
- def get_events()
150
+ def get_events
138
151
 
139
152
  ret = nil
140
153
 
@@ -146,10 +159,11 @@ module MobyBehaviour
146
159
  ret = @sut.execute_command( command)
147
160
  # TODO: how to parse the output?
148
161
 
149
- rescue Exception => e
162
+ rescue
150
163
 
151
164
  $logger.behaviour "FAIL;Failed get_events.;#{ identity };get_events;"
152
- Kernel::raise e
165
+
166
+ raise $!
153
167
 
154
168
  end
155
169
 
@@ -144,7 +144,7 @@ module MobyBehaviour
144
144
 
145
145
  if arguments[ :file ]!=nil
146
146
  file=arguments[ :file ].gsub('\\','/')
147
- else file='*.*'
147
+ else
148
148
  file='*.*'
149
149
  end
150
150
 
@@ -165,13 +165,13 @@ module MobyBehaviour
165
165
  end_index=(name.index File.basename(name))-1
166
166
  start_index=(name.index device_path)+device_path.length
167
167
  file_folder=name[start_index..end_index]
168
- write_file("#{tmp_path}#{file_folder}",name)
168
+ receive_file_from_device(name,File.join("#{tmp_path}#{file_folder}",File.basename(name)))
169
169
  end
170
170
  return list_of_files
171
171
  else
172
172
  Kernel::raise ArgumentError.new( "Argument :file not found") unless arguments.include?( :file )
173
- new_file=write_file(tmp_path,file)
174
- return new_file
173
+ return receive_file_from_device(File.join(tmp_path,name),File.join(tmp_path,name))
174
+
175
175
  end
176
176
  end
177
177
 
@@ -223,10 +223,10 @@ module MobyBehaviour
223
223
  Kernel::raise ArgumentError.new( "Argument :from not found") unless arguments.include?( :from )
224
224
  local_dir.entries.each do | local_file_or_subdir |
225
225
  if !File.directory?( File.join( arguments[ :from ], local_file_or_subdir ) )
226
- fixture("file","write_file",
227
- {:file_name=>arguments[ :to ]+'/'+File.basename(local_file_or_subdir),
228
- :file_data=>Base64.encode64(read_file(File.join( arguments[ :from ],
229
- local_file_or_subdir )))})
226
+ send_file_to_device(
227
+ File.join( arguments[ :from ], local_file_or_subdir ),
228
+ File.join( arguments[ :to ], File.basename(local_file_or_subdir))
229
+ )
230
230
  transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}"
231
231
  elsif local_file_or_subdir != "." && local_file_or_subdir != ".."
232
232
  fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"})
@@ -237,10 +237,10 @@ module MobyBehaviour
237
237
  elsif arguments.include?( :file ) && arguments.include?( :from )
238
238
  local_dir.entries.each do | local_file_or_subdir |
239
239
  if !File.directory?( File.join( arguments[ :from ], local_file_or_subdir ) )
240
- fixture("file","write_file",
241
- {:file_name=>arguments[ :to ]+'/'+File.basename(local_file_or_subdir),
242
- :file_data=>Base64.encode64(read_file(File.join( arguments[ :from ],
243
- local_file_or_subdir )))}) if local_file_or_subdir.include?(file)
240
+ send_file_to_device(
241
+ File.join( arguments[ :from ],local_file_or_subdir ),
242
+ File.join( arguments[ :to ], File.basename(local_file_or_subdir))
243
+ ) if local_file_or_subdir.include?(file)
244
244
  transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}"
245
245
  elsif local_file_or_subdir != "." && local_file_or_subdir != ".."
246
246
  fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"})
@@ -251,9 +251,10 @@ module MobyBehaviour
251
251
  else
252
252
  Kernel::raise ArgumentError.new( "Argument :file not found") unless arguments.include?( :file )
253
253
  fixture("file","mk_dir",{:file_name=>{:file_name=>arguments[ :to ]}})
254
- fixture("file","write_file",
255
- {:file_name=>arguments[ :to ]+'/'+File.basename(file),
256
- :file_data=>Base64.encode64(read_file(file))})
254
+ send_file_to_device(
255
+ File.join(Dir.pwd,file),
256
+ File.join(arguments[ :to ],File.basename(file))
257
+ )
257
258
  transfered_files << "#{arguments[ :to ]}/#{File.basename(file)}"
258
259
  end
259
260
  return transfered_files
@@ -300,40 +301,52 @@ module MobyBehaviour
300
301
 
301
302
  private
302
303
 
303
- def write_file(target_folder,source_file)
304
- if File::directory?(target_folder)==false
305
- FileUtils.mkdir_p target_folder
304
+ def receive_file_from_device(device_file,local_file)
305
+ if File::directory?(File.dirname(local_file))==false
306
+ FileUtils.mkdir_p File.dirname(local_file)
307
+ end
308
+ new_file = File.new(local_file, 'wb')
309
+ block_size = 100000
310
+ temp_size = block_size
311
+ offset = 0
312
+ while( temp_size == block_size )
313
+ temp_data = Base64.decode64( fixture("file", "read_file_part",
314
+ {:file_name => device_file,
315
+ :file_offset => offset,
316
+ :data_lenght => block_size
317
+ }) )
318
+ temp_size = temp_data.size
319
+ offset = offset + temp_size
320
+ new_file.write(temp_data)
306
321
  end
307
- new_file = File.open(target_folder + "/" + File.basename(source_file), 'w')
308
- new_file << Base64.decode64( fixture("file", "read_file", {:file_name => source_file}) )
309
322
  new_file.close
310
- return target_folder + "/" + File.basename(source_file)
323
+ return local_file
311
324
  end
312
325
 
313
- def read_file(source_file)
314
- =begin
315
- file_data=''
316
- if File.file?(source_file)
317
- open_file = File.open(source_file, 'r')
318
- open_file.each_line do |line|
319
- file_data += line
326
+ def send_file_to_device(local_file, device_file)
327
+ fixture("file", "delete_file", {:file_name => device_file})
328
+ block_max_size = 100000
329
+ offset = 0
330
+ file_size = File.stat(local_file).size
331
+
332
+ file_to_be_sent = File.open(local_file,"rb")
333
+ while(offset < file_size)
334
+ block_size = file_size - offset
335
+ if(block_size > block_max_size)
336
+ block_size = block_max_size
337
+ end
338
+ buff = file_to_be_sent.readpartial(block_size)
339
+ if(buff != nil)
340
+ file_data = Base64.encode64(buff)
341
+ fixture("file","write_file_append",
342
+ { :file_name=>device_file,
343
+ :file_data=>file_data,
344
+ :file_offset=>offset,
345
+ :data_lenght=>buff.size} )
346
+ offset = offset + buff.size
347
+ end
320
348
  end
321
- end
322
- return file_data.to_s
323
- =end
324
-
325
- begin
326
-
327
- # return file content as string
328
- File.open( source_file, 'rb:binary' ).read
329
-
330
- rescue
331
-
332
- # return empty string in case of exception raised
333
- ''
334
-
335
- end
336
-
349
+ file_to_be_sent.close
337
350
  end
338
351
 
339
352
 
@@ -274,7 +274,7 @@ module MobyBehaviour
274
274
  # description: In case the given parameters are not valid.
275
275
  #
276
276
  # == info
277
- # See method rotate
277
+ # See [link="#QtMultitouch:rotate"]rotate[/link] method for more details
278
278
  #
279
279
  def one_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
280
280
  params = {:type => :one_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
@@ -164,26 +164,12 @@ module MobyBehaviour
164
164
 
165
165
  end
166
166
 
167
- # == description
168
- # Returns list of crashed applications running on SUT known to qttasserver
169
- # == returns
170
- # String
171
- # description: XML string containing crashed applications, their names, process ids and crash times
172
- # example: "<tasMessage dateTime="2010.11.02 14:48:11.056" version="0.9.1" ><tasInfo id="1" name="Qt4.6.2" type="qt" ><object id="" name="QApplications" type="applications" ></object></tasInfo></tasMessage>"
167
+ # == nodoc
168
+ # NOT SUPPORTED ANYMORE
173
169
  def list_crashed_apps
174
170
 
175
- apps = nil
171
+ raise ArgumentError, 'Behaviour "list_crashed_apps" is no longer supported.'
176
172
 
177
- begin
178
- # execute the application control service request
179
- apps = execute_command( MobyCommand::Application.new( :ListCrashedApps ) )
180
- $logger.behaviour "PASS;Successfully listed crashed applications.;#{ id };sut;{};list_crashed_apps;"
181
- rescue Exception => e
182
- $logger.behaviour "FAIL;Failed to list crashed applications.;#{ id };sut;{};list_crashed_apps;"
183
- raise RuntimeError, "Unable to list crashed applications: Exception: #{ e.message } (#{ e.class })"
184
- end
185
-
186
- apps
187
173
  end
188
174
 
189
175
  # == description
@@ -133,7 +133,11 @@ module MobyBehaviour
133
133
 
134
134
  ensure
135
135
 
136
- self.fixture( "signal", "remove_signals" )
136
+ begin
137
+ self.fixture( "signal", "remove_signals" )
138
+ rescue Exception => e
139
+ $logger.warning "Fixture removal failed. Message received: #{e.message}"
140
+ end
137
141
 
138
142
  end
139
143
 
@@ -104,17 +104,6 @@ module MobyController
104
104
 
105
105
  command_xml = make_xml_message( service_details, 'startedApps', nil )
106
106
 
107
- # list crashed applications
108
- when :ListCrashedApps
109
-
110
- service_details = {
111
- :service => 'listCrashedApps',
112
- :name => @_application_name,
113
- :id => @_application_uid
114
- }
115
-
116
- command_xml = make_xml_message( service_details, 'listCrashedApps', nil )
117
-
118
107
  # shell command
119
108
  when :Shell
120
109
 
@@ -18,7 +18,9 @@
18
18
  ############################################################################
19
19
 
20
20
  # verify that TDriver is loaded
21
- Kernel::raise RuntimeError.new( "This SUT plugin requires Testability Driver and cannot be launched in standalone mode" ) unless (defined?( MATTI ) || defined?( TDriver ))
21
+ raise RuntimeError, 'This SUT plugin requires Testability Driver and cannot be launched in standalone mode' unless (defined?( MATTI ) || defined?( TDriver ))
22
+
23
+ raise RuntimeError, 'Installed Testability Driver is too old; please update to later version' unless defined?( TDriver::TestObjectFactory ) || defined?( TDriver::SUTFactory )
22
24
 
23
25
  include TDriverVerify
24
26
 
@@ -97,7 +99,7 @@ module MobyPlugin
97
99
 
98
100
  end
99
101
 
100
- # returns SUT object - this method will be called from MobyBase::SUTFactory
102
+ # returns SUT object - this method will be called from TDriver::SUTFactory
101
103
  def self.make_sut( sut_id )
102
104
 
103
105
  # retrieve sut specific parameters
@@ -133,7 +135,7 @@ module MobyPlugin
133
135
  sut_controller,
134
136
 
135
137
  # pass test object factory class
136
- MobyBase::TestObjectFactory.instance,
138
+ TDriver::TestObjectFactory,
137
139
 
138
140
  # pass sut id
139
141
  sut_id
@@ -36,7 +36,8 @@ module MobyController
36
36
  :socket_read_timeout,
37
37
  :socket_write_timeout,
38
38
  :deflate_service_request,
39
- :defalte_minimum_size
39
+ :deflate_minimum_size,
40
+ :deflate_compression_level
40
41
  )
41
42
 
42
43
  # TODO: better way to set the host and port parameters
@@ -86,14 +87,10 @@ module MobyController
86
87
  # determine which inflate method to use
87
88
  if _sut_parameters[ :win_native, false ].to_s.true?
88
89
 
89
- @zlib_inflate_method = Zlib::Inflate.new( -Zlib::MAX_WBITS ).method( :inflate )
90
-
91
90
  @inflate_method = method( :inflate_windows_native )
92
91
 
93
92
  else
94
93
 
95
- @zlib_inflate_method = Zlib::Inflate.method( :inflate )
96
-
97
94
  @inflate_method = method( :inflate )
98
95
 
99
96
  end
@@ -384,18 +381,17 @@ module MobyController
384
381
  # inflate to be used in native windows env.
385
382
  def inflate_windows_native( body )
386
383
 
387
- tmp = body
388
-
389
- unless tmp.empty?
390
-
391
- @zlib_inflate_method.call( tmp )
392
-
393
- else
394
-
395
- tmp
384
+ unless body.empty?
385
+
386
+ zstream = Zlib::Inflate.new( -Zlib::MAX_WBITS )
387
+ body = zstream.inflate( body )
388
+ zstream.finish
389
+ zstream.close
396
390
 
397
391
  end
398
392
 
393
+ body
394
+
399
395
  end
400
396
 
401
397
  # inflate to be used by default
@@ -405,15 +401,13 @@ module MobyController
405
401
  tmp = body[ 4 .. -1 ]
406
402
 
407
403
  unless tmp.empty?
408
-
409
- @zlib_inflate_method.call( tmp )
410
-
411
- else
412
-
413
- tmp
414
-
404
+
405
+ tmp = Zlib::Inflate.inflate( tmp )
406
+
415
407
  end
416
408
 
409
+ tmp
410
+
417
411
  end
418
412
 
419
413
  # enable hooking for performance measurement & debug logging
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testability-driver-qt-sut-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TDriver team
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2011-08-17 00:00:00 +03:00
12
+ date: 2011-09-14 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency