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.
- data/env.rb +26 -0
- data/installer/extconf.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +156 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +318 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +227 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +140 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +165 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +333 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +80 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +178 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +906 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +604 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +152 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +151 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +85 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +455 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +124 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +283 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +492 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +113 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +93 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +230 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +663 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +50 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +45 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +48 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +170 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +226 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +264 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +60 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +114 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +67 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +52 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +99 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +51 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +72 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +119 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +225 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +154 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +58 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +82 -0
- data/lib/testability-driver-qt-sut-plugin.rb +24 -0
- data/xml/behaviour/qt.xml +717 -0
- data/xml/defaults/sut_qt.xml +9 -0
- data/xml/keymap/qt.xml +321 -0
- data/xml/template/qt.xml +124 -0
- metadata +141 -0
@@ -0,0 +1,165 @@
|
|
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
|
+
# Events specific behaviours
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtEvents
|
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
|
+
# *;application
|
44
|
+
#
|
45
|
+
module Events
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Enable event listening. You can specify which events you want to listen for by including the names of
|
51
|
+
# those events separated by comma or integers if using user events. Use ALL if you want to listen for all
|
52
|
+
# events but be aware that there will be a lot of events.
|
53
|
+
# \n
|
54
|
+
# The events listened need to be sent the object to which the enabling is done for e.g. sut.button.enable_events('ALL')
|
55
|
+
# would listen to all events sent to the button. When disabling or getting the events the operation must be done to the same object.
|
56
|
+
#
|
57
|
+
# == arguments
|
58
|
+
# filter_array
|
59
|
+
# Array
|
60
|
+
# description: Array of the event named to listen
|
61
|
+
# example: ["Timer","MouseButtonPress","45677","67889"]
|
62
|
+
#
|
63
|
+
# == returns
|
64
|
+
# NilClass
|
65
|
+
# description: -
|
66
|
+
# example: -
|
67
|
+
#
|
68
|
+
# == exceptions
|
69
|
+
# Exception
|
70
|
+
# description: In case of an error
|
71
|
+
#
|
72
|
+
def enable_events(filter_array = nil)
|
73
|
+
|
74
|
+
begin
|
75
|
+
command = plugin_command #in qt_behaviour
|
76
|
+
command.command_name( 'EnableEvents' )
|
77
|
+
params_str = ''
|
78
|
+
filter_array.each {|value| params_str << value << ','} if filter_array
|
79
|
+
command.command_params( 'EventsToListen' => params_str)
|
80
|
+
command.service( 'collectEvents' )
|
81
|
+
@sut.execute_command( command)
|
82
|
+
|
83
|
+
rescue Exception => e
|
84
|
+
|
85
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
|
86
|
+
Kernel::raise e
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
|
94
|
+
# == description
|
95
|
+
# Disables event listening on the target
|
96
|
+
#
|
97
|
+
# == returns
|
98
|
+
# NilClass
|
99
|
+
# description: -
|
100
|
+
# example: -
|
101
|
+
#
|
102
|
+
# == exceptions
|
103
|
+
# Exception
|
104
|
+
# description: In case of an error
|
105
|
+
#
|
106
|
+
def disable_events()
|
107
|
+
|
108
|
+
begin
|
109
|
+
command = plugin_command #in qt_behaviour
|
110
|
+
command.command_name( 'DisableEvents' )
|
111
|
+
command.service( 'collectEvents' )
|
112
|
+
@sut.execute_command( command)
|
113
|
+
rescue Exception => e
|
114
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed disable_events.;#{ identity };disable_events;"
|
115
|
+
Kernel::raise e
|
116
|
+
end
|
117
|
+
|
118
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
|
119
|
+
nil
|
120
|
+
end
|
121
|
+
|
122
|
+
# == description
|
123
|
+
# Gets event list occured since the enabling of events
|
124
|
+
# \n
|
125
|
+
# The format of the xml string is the same as with the ui state.
|
126
|
+
#
|
127
|
+
# == returns
|
128
|
+
# String
|
129
|
+
# description: Xml listing containing the details of the events logger since enable_events
|
130
|
+
# example: -
|
131
|
+
#
|
132
|
+
# == exceptions
|
133
|
+
# Exception
|
134
|
+
# description: In case of an error
|
135
|
+
#
|
136
|
+
def get_events()
|
137
|
+
ret = nil
|
138
|
+
|
139
|
+
begin
|
140
|
+
|
141
|
+
command = plugin_command(true) #in qt_behaviour
|
142
|
+
command.command_name( 'GetEvents' )
|
143
|
+
command.service( 'collectEvents' )
|
144
|
+
ret = @sut.execute_command( command)
|
145
|
+
# TODO: how to parse the output?
|
146
|
+
|
147
|
+
rescue Exception => e
|
148
|
+
|
149
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed get_events.;#{ identity };get_events;"
|
150
|
+
Kernel::raise e
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation get_events executed successfully.;#{ identity };get_events;"
|
155
|
+
return ret
|
156
|
+
end
|
157
|
+
|
158
|
+
# enable hooking for performance measurement & debug logging
|
159
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
160
|
+
|
161
|
+
end # EventsBehaviour
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end # MobyBase
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb
ADDED
@@ -0,0 +1,333 @@
|
|
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
|
+
# This module contains implementation to control sut file transfers
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# FileTransfer
|
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
|
+
# sut
|
44
|
+
#
|
45
|
+
module FileTransfer
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Delete files from sut \n
|
51
|
+
#
|
52
|
+
#
|
53
|
+
# == arguments
|
54
|
+
# arguments
|
55
|
+
# Hash
|
56
|
+
# description: Hash containing parameters to be used in file transfer
|
57
|
+
# example: Following symbols are supported
|
58
|
+
# [:file]
|
59
|
+
# [:from]
|
60
|
+
# [:dir]
|
61
|
+
#
|
62
|
+
# == returns
|
63
|
+
# Array
|
64
|
+
# description: Deleted files
|
65
|
+
# example: ["/dir/file.txt","/dir/file2.txt"]
|
66
|
+
#
|
67
|
+
# == exceptions
|
68
|
+
# ArgumentErrors
|
69
|
+
# description: For missing / wrong argument types
|
70
|
+
#
|
71
|
+
# == info
|
72
|
+
#
|
73
|
+
def delete_from_sut(arguments)
|
74
|
+
MobyBase::Error.raise( :WrongArgumentType, arguments.class, "hash" ) unless arguments.kind_of?( Hash )
|
75
|
+
|
76
|
+
if arguments.include?( :file )
|
77
|
+
|
78
|
+
file=arguments[ :file ].gsub('\\','/')
|
79
|
+
device_path=arguments[ :from ].gsub('\\','/') if arguments.include?(:from)
|
80
|
+
|
81
|
+
if device_path!=nil
|
82
|
+
|
83
|
+
ret_list_of_files = []
|
84
|
+
list_of_files = list_files_from_sut(:from=>device_path,:file=>file)
|
85
|
+
list_of_files.each do |name|
|
86
|
+
if fixture("file", "delete_file", {:file_name => name}) == "OK"
|
87
|
+
ret_list_of_files << name
|
88
|
+
end
|
89
|
+
end
|
90
|
+
return ret_list_of_files
|
91
|
+
|
92
|
+
else
|
93
|
+
|
94
|
+
if fixture("file", "delete_file", {:file_name => file}) == "OK"
|
95
|
+
return File.basename(file)
|
96
|
+
end
|
97
|
+
return
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
elsif arguments.include?(:dir)
|
102
|
+
|
103
|
+
if fixture("file", "rm_dir", {:file_name => arguments[:dir]}) == "OK"
|
104
|
+
return arguments[:dir]
|
105
|
+
end
|
106
|
+
return
|
107
|
+
|
108
|
+
else
|
109
|
+
|
110
|
+
Kernel::raise ArgumentError.new( "Argument :file not found") unless arguments.include?( :file )
|
111
|
+
Kernel::raise ArgumentError.new( "Argument :dir not found") unless arguments.include?( :dir )
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
# == description
|
118
|
+
# Copy files from sut \n
|
119
|
+
#
|
120
|
+
# == arguments
|
121
|
+
# arguments
|
122
|
+
# Hash
|
123
|
+
# description: Hash containing parameters to be used in file transfer
|
124
|
+
# example: Following symbols are supported
|
125
|
+
# [:file]
|
126
|
+
# [:from]
|
127
|
+
# [:to]
|
128
|
+
#
|
129
|
+
# == returns
|
130
|
+
# Array
|
131
|
+
# description: Copied files
|
132
|
+
# example: ["/dir/file.txt","/dir/file2.txt"]
|
133
|
+
#
|
134
|
+
# == exceptions
|
135
|
+
# ArgumentErrors
|
136
|
+
# description: For missing / wrong argument types
|
137
|
+
#
|
138
|
+
# == info
|
139
|
+
#
|
140
|
+
def copy_from_sut(arguments)
|
141
|
+
MobyBase::Error.raise( :WrongArgumentType, arguments.class, "hash" ) unless arguments.kind_of?( Hash )
|
142
|
+
|
143
|
+
device_path=arguments[ :from ].gsub('\\','/') if arguments.include?( :from )
|
144
|
+
|
145
|
+
if arguments[ :file ]!=nil
|
146
|
+
file=arguments[ :file ].gsub('\\','/')
|
147
|
+
else file='*.*'
|
148
|
+
file='*.*'
|
149
|
+
end
|
150
|
+
|
151
|
+
if arguments[:to]!=nil
|
152
|
+
tmp_path=arguments[:to].gsub('\\','/')
|
153
|
+
if File::directory?(tmp_path)==false
|
154
|
+
FileUtils.mkdir_p tmp_path
|
155
|
+
end
|
156
|
+
else
|
157
|
+
tmp_path=Dir.getwd
|
158
|
+
end
|
159
|
+
|
160
|
+
if device_path!=nil
|
161
|
+
list_of_files = list_files_from_sut(:from=>device_path,:file=>file)
|
162
|
+
|
163
|
+
|
164
|
+
list_of_files.each do |name|
|
165
|
+
end_index=(name.index File.basename(name))-1
|
166
|
+
start_index=(name.index device_path)+device_path.length
|
167
|
+
file_folder=name[start_index..end_index]
|
168
|
+
write_file("#{tmp_path}#{file_folder}",name)
|
169
|
+
end
|
170
|
+
return list_of_files
|
171
|
+
else
|
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
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# == description
|
179
|
+
# Copy files to sut \n
|
180
|
+
#
|
181
|
+
# == arguments
|
182
|
+
# arguments
|
183
|
+
# Hash
|
184
|
+
# description: Hash containing parameters to be used in file transfer
|
185
|
+
# example: Following symbols are supported
|
186
|
+
# [:file]
|
187
|
+
# [:from]
|
188
|
+
# [:to]
|
189
|
+
#
|
190
|
+
#
|
191
|
+
# == returns
|
192
|
+
# Array
|
193
|
+
# description: Copied files
|
194
|
+
# example: ["/dir/file.txt","/dir/file2.txt"]
|
195
|
+
#
|
196
|
+
# == exceptions
|
197
|
+
# ArgumentErrors
|
198
|
+
# description: For missing / wrong argument types
|
199
|
+
#
|
200
|
+
# == info
|
201
|
+
#
|
202
|
+
def copy_to_sut(arguments)
|
203
|
+
MobyBase::Error.raise( :WrongArgumentType, arguments.class, "hash" ) unless arguments.kind_of?( Hash )
|
204
|
+
Kernel::raise ArgumentError.new( "Argument :to not found") unless arguments.include?( :to )
|
205
|
+
|
206
|
+
begin
|
207
|
+
local_dir = Dir.new( arguments[ :from ] ) if arguments.include?( :from )
|
208
|
+
rescue Errno::ENOENT => ee
|
209
|
+
Kernel::raise RuntimeError.new( "The source folder does not exist. Details:\n" + ee.inspect )
|
210
|
+
end
|
211
|
+
|
212
|
+
if arguments[ :file ]!=nil
|
213
|
+
file=arguments[ :file ].gsub('\\','/')
|
214
|
+
else file='*.*'
|
215
|
+
file='*.*'
|
216
|
+
end
|
217
|
+
transfered_files=Array.new
|
218
|
+
|
219
|
+
#ensure that the base dir exist
|
220
|
+
fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}"})
|
221
|
+
|
222
|
+
if arguments.include?( :file )==false
|
223
|
+
Kernel::raise ArgumentError.new( "Argument :from not found") unless arguments.include?( :from )
|
224
|
+
local_dir.entries.each do | local_file_or_subdir |
|
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 )))})
|
230
|
+
transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}"
|
231
|
+
elsif local_file_or_subdir != "." && local_file_or_subdir != ".."
|
232
|
+
fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"})
|
233
|
+
transfered_files << copy_to_sut(:from=>"#{arguments[ :from ]}/#{local_file_or_subdir}",
|
234
|
+
:to=>"#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}")
|
235
|
+
end
|
236
|
+
end
|
237
|
+
elsif arguments.include?( :file ) && arguments.include?( :from )
|
238
|
+
local_dir.entries.each do | local_file_or_subdir |
|
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)
|
244
|
+
transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}"
|
245
|
+
elsif local_file_or_subdir != "." && local_file_or_subdir != ".."
|
246
|
+
fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"})
|
247
|
+
transfered_files << copy_to_sut(:file => arguments( :file ), :from=>"#{arguments[ :from ]}/#{local_file_or_subdir}",
|
248
|
+
:to=>"#{arguments[ :to ]}/#{local_file_or_subdir}")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
else
|
252
|
+
Kernel::raise ArgumentError.new( "Argument :file not found") unless arguments.include?( :file )
|
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))})
|
257
|
+
transfered_files << "#{arguments[ :to ]}/#{File.basename(file)}"
|
258
|
+
end
|
259
|
+
return transfered_files
|
260
|
+
end
|
261
|
+
|
262
|
+
# == description
|
263
|
+
# List files from sut \n
|
264
|
+
#
|
265
|
+
# == arguments
|
266
|
+
# arguments
|
267
|
+
# Hash
|
268
|
+
# description: Hash containing parameters to be used in file transfer
|
269
|
+
# example: Following symbols are supported
|
270
|
+
# [:file]
|
271
|
+
# [:from]
|
272
|
+
#
|
273
|
+
# == returns
|
274
|
+
# Array
|
275
|
+
# description: file list array
|
276
|
+
# example: ["/dir/file.txt","/dir/file2.txt"]
|
277
|
+
#
|
278
|
+
# == exceptions
|
279
|
+
# ArgumentErrors
|
280
|
+
# description: For missing / wrong argument types
|
281
|
+
#
|
282
|
+
# == Info
|
283
|
+
#
|
284
|
+
def list_files_from_sut(arguments)
|
285
|
+
MobyBase::Error.raise( :WrongArgumentType, arguments.class, "hash" ) unless arguments.kind_of?( Hash )
|
286
|
+
Kernel::raise ArgumentError.new( "Argument :from not found") unless arguments.include?( :from )
|
287
|
+
device_path=arguments[ :from ].gsub('\\','/')
|
288
|
+
|
289
|
+
if arguments[ :file ]!=nil
|
290
|
+
file=arguments[ :file ].gsub('\\','/')
|
291
|
+
else file='*.*'
|
292
|
+
file='*.*'
|
293
|
+
end
|
294
|
+
list_of_files = fixture("file", "list_files",
|
295
|
+
{:file_name => file,
|
296
|
+
:file_path => device_path}).split(';')
|
297
|
+
return list_of_files
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
private
|
302
|
+
|
303
|
+
def write_file(target_folder,source_file)
|
304
|
+
if File::directory?(target_folder)==false
|
305
|
+
FileUtils.mkdir_p target_folder
|
306
|
+
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
|
+
new_file.close
|
310
|
+
return target_folder + "/" + File.basename(source_file)
|
311
|
+
end
|
312
|
+
|
313
|
+
def read_file(source_file)
|
314
|
+
file_data=''
|
315
|
+
if File.file?(source_file)
|
316
|
+
open_file = File.open(source_file, 'r')
|
317
|
+
open_file.each_line do |line|
|
318
|
+
file_data += line
|
319
|
+
end
|
320
|
+
end
|
321
|
+
return file_data.to_s
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
# enable hooking for performance measurement & debug logging
|
326
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
327
|
+
|
328
|
+
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|