testability-driver 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +2 -2
- data/lib/tdriver-devtools/tdriver-devtools.rb +1 -1
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +3 -3
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +6 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +5 -3
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/factory.rb +225 -225
- data/lib/tdriver/base/errors.rb +1 -1
- data/lib/tdriver/base/state_object.rb +227 -179
- data/lib/tdriver/base/sut/controller.rb +2 -2
- data/lib/tdriver/base/sut/factory.rb +190 -182
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +69 -25
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +1 -1
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +4 -4
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +3 -3
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +350 -165
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +9 -9
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +191 -103
- data/lib/tdriver/base/sut/generic/commands/application.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +1 -1
- data/lib/tdriver/base/sut/generic/plugin.rb +1 -1
- data/lib/tdriver/base/sut/sut.rb +5 -1
- data/lib/tdriver/base/test_object/abstract.rb +136 -151
- data/lib/tdriver/base/test_object/adapter.rb +293 -82
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +20 -17
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +159 -532
- data/lib/tdriver/base/test_object/cache.rb +1 -1
- data/lib/tdriver/base/test_object/factory.rb +254 -605
- data/lib/tdriver/base/test_object/identificator.rb +1 -1
- data/lib/tdriver/base/test_object/loader.rb +1 -1
- data/lib/tdriver/base/test_object/verification.rb +17 -17
- data/lib/tdriver/loader.rb +20 -9
- data/lib/tdriver/report/report.rb +5 -0
- data/lib/tdriver/report/report_creator.rb +2 -2
- data/lib/tdriver/report/report_cucumber_listener.rb +4 -4
- data/lib/tdriver/report/report_cucumber_reporter.rb +4 -4
- data/lib/tdriver/report/report_execution_statistics.rb +22 -22
- data/lib/tdriver/report/report_grouping.rb +2 -2
- data/lib/tdriver/report/report_javascript.rb +11 -4
- data/lib/tdriver/report/report_test_case_run.rb +2 -2
- data/lib/tdriver/report/report_test_run.rb +5 -5
- data/lib/tdriver/report/report_test_unit.rb +74 -26
- data/lib/tdriver/report/report_writer.rb +70 -13
- data/lib/tdriver/tdriver.rb +17 -8
- data/lib/tdriver/util/common/array.rb +1 -1
- data/lib/tdriver/util/common/crc16.rb +1 -1
- data/lib/tdriver/util/common/environment.rb +1 -1
- data/lib/tdriver/util/common/file.rb +18 -9
- data/lib/tdriver/util/common/gem.rb +1 -1
- data/lib/tdriver/util/common/hash.rb +21 -0
- data/lib/tdriver/util/common/kernel.rb +1 -1
- data/lib/tdriver/util/common/loader.rb +5 -2
- data/lib/tdriver/util/common/numeric.rb +54 -3
- data/lib/tdriver/util/common/retryable.rb +30 -12
- data/lib/tdriver/util/common/stackable.rb +185 -0
- data/lib/tdriver/util/common/string.rb +21 -5
- data/lib/tdriver/util/{dbaccess/dbaccess.rb → database/access.rb} +4 -1
- data/lib/tdriver/util/{dbaccess/dbconnection.rb → database/connection.rb} +3 -0
- data/lib/tdriver/util/{dbaccess → database}/error.rb +0 -1
- data/lib/tdriver/util/{dbaccess → database}/loader.rb +5 -6
- data/lib/tdriver/util/{dynamic_attribute_filter.rb → filters/dynamic_attributes.rb} +1 -1
- data/lib/tdriver/util/hooking/hooking.rb +477 -0
- data/lib/tdriver/util/loader.rb +35 -29
- data/lib/tdriver/util/localisation/error.rb +0 -1
- data/lib/tdriver/util/localisation/loader.rb +1 -4
- data/lib/tdriver/util/localisation/localisation.rb +30 -27
- data/lib/tdriver/util/{common.rb → logger/loader.rb} +2 -4
- data/lib/tdriver/util/logger/logger.rb +574 -0
- data/lib/tdriver/util/operator_data/loader.rb +4 -3
- data/lib/tdriver/util/operator_data/operator_data.rb +5 -5
- data/lib/tdriver/util/parameter/parameter.rb +7 -1
- data/lib/tdriver/util/parameter/parameter_hash.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_template.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_user_api.rb +28 -20
- data/lib/tdriver/util/parameter/parameter_xml.rb +1 -1
- data/lib/tdriver/util/plugin/abstract.rb +1 -1
- data/lib/tdriver/util/plugin/service.rb +1 -1
- data/lib/tdriver/util/{localisation.rb → recorder/loader.rb} +4 -3
- data/lib/tdriver/util/recorder/recorder.rb +66 -0
- data/lib/tdriver/util/recorder/scripter.rb +258 -0
- data/lib/tdriver/util/{stats.rb → statistics/statistics.rb} +7 -8
- data/lib/tdriver/util/user_data/error.rb +0 -1
- data/lib/tdriver/util/user_data/loader.rb +1 -2
- data/lib/tdriver/util/user_data/user_data.rb +6 -6
- data/lib/tdriver/util/video/camera.rb +67 -0
- data/lib/tdriver/util/video/camera_linux.rb +139 -0
- data/lib/tdriver/util/video/camera_windows.rb +174 -0
- data/lib/tdriver/util/video/loader.rb +31 -0
- data/lib/tdriver/util/video/video_utils.rb +139 -0
- data/lib/tdriver/util/xml/abstraction.rb +56 -5
- data/lib/tdriver/util/xml/builder.rb +2 -5
- data/lib/tdriver/util/{parameter.rb → xml/comment.rb} +10 -2
- data/lib/tdriver/util/xml/loader.rb +32 -22
- data/lib/tdriver/util/xml/nil_node.rb +2 -2
- data/lib/tdriver/util/xml/parsers/loader.rb +0 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +18 -44
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +9 -13
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +9 -3
- data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +6 -11
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +2 -122
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +26 -16
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +203 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +1 -2
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +2 -20
- data/lib/tdriver/util/xml/xml.rb +52 -20
- data/lib/tdriver/verify/verify.rb +238 -81
- data/xml/behaviours/generic.xml +12 -10
- metadata +156 -180
- data/lib/tdriver/base/test_object/factory_new.rb +0 -202
- data/lib/tdriver/util/hooking.rb +0 -434
- data/lib/tdriver/util/logger.rb +0 -506
- data/lib/tdriver/util/recorder.rb +0 -297
- data/lib/tdriver/util/video_utils.rb +0 -384
- data/lib/tdriver/util/xml/nil_element.rb +0 -89
@@ -17,10 +17,11 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
-
|
21
20
|
# user data inputs related errors
|
22
21
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'error.rb' ) )
|
23
|
-
|
24
|
-
# user data inputs
|
22
|
+
#
|
23
|
+
# user data inputs module implementation
|
25
24
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'operator_data.rb' ) )
|
25
|
+
#
|
26
|
+
|
26
27
|
|
@@ -61,11 +61,11 @@ module MobyUtil
|
|
61
61
|
Kernel::raise OperatorDataNotFoundError.new( "Search string parameter cannot be nil" ) if operator_data_lname == nil
|
62
62
|
|
63
63
|
# Get Localization parameters for DB Connection
|
64
|
-
db_type =
|
65
|
-
host =
|
66
|
-
username =
|
67
|
-
password =
|
68
|
-
database_name =
|
64
|
+
db_type = $parameters[ :operator_data_db_type, nil ].to_s.downcase
|
65
|
+
host = $parameters[ :operator_data_server_ip ]
|
66
|
+
username = $parameters[ :operator_data_server_username ]
|
67
|
+
password = $parameters[ :operator_data_server_password ]
|
68
|
+
database_name = $parameters[ :operator_data_server_database_name ]
|
69
69
|
|
70
70
|
db_connection = DBConnection.new( db_type, host, database_name, username, password )
|
71
71
|
|
@@ -278,8 +278,14 @@ module MobyUtil
|
|
278
278
|
|
279
279
|
end
|
280
280
|
|
281
|
-
|
281
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
282
282
|
|
283
283
|
end # Parameter
|
284
284
|
|
285
285
|
end # MobyUtil
|
286
|
+
|
287
|
+
# set global variable pointing to parameter class
|
288
|
+
$parameters = MobyUtil::Parameter
|
289
|
+
|
290
|
+
# set global variable pointing to parameter API class
|
291
|
+
$parameters_api = MobyUtil::ParameterUserAPI
|
@@ -21,63 +21,71 @@ module MobyUtil
|
|
21
21
|
|
22
22
|
class ParameterUserAPI
|
23
23
|
|
24
|
-
include Singleton
|
24
|
+
#include Singleton
|
25
25
|
|
26
|
-
def
|
26
|
+
def self.instance
|
27
27
|
|
28
|
-
MobyUtil::
|
28
|
+
warn("warning: #{ self.name } is static class, use MobyUtil::ParameterUserAPI#method instead of using instance method")
|
29
|
+
|
30
|
+
MobyUtil::ParameterUserAPI
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.[]=( key, value )
|
35
|
+
|
36
|
+
$parameters[ key ] = value
|
29
37
|
|
30
38
|
end
|
31
39
|
|
32
|
-
def []( *args )
|
40
|
+
def self.[]( *args )
|
33
41
|
|
34
|
-
|
42
|
+
$parameters[ *args ]
|
35
43
|
|
36
44
|
end
|
37
45
|
|
38
|
-
def fetch( *args, &block )
|
46
|
+
def self.fetch( *args, &block )
|
39
47
|
|
40
|
-
|
48
|
+
$parameters.fetch( *args, &block )
|
41
49
|
|
42
50
|
end
|
43
51
|
|
44
|
-
def files
|
52
|
+
def self.files
|
45
53
|
|
46
|
-
|
54
|
+
$parameters.files
|
47
55
|
|
48
56
|
end
|
49
57
|
|
50
|
-
def clear
|
58
|
+
def self.clear
|
51
59
|
|
52
|
-
|
60
|
+
$parameters.instance.clear
|
53
61
|
|
54
62
|
end
|
55
63
|
|
56
|
-
def load_xml( filename )
|
64
|
+
def self.load_xml( filename )
|
57
65
|
|
58
|
-
|
66
|
+
$parameters.instance.load_parameters_xml( filename )
|
59
67
|
|
60
68
|
end
|
61
69
|
|
62
|
-
def reset( *keys )
|
70
|
+
def self.reset( *keys )
|
63
71
|
|
64
|
-
|
72
|
+
$parameters.instance.reset_parameters
|
65
73
|
|
66
74
|
end
|
67
75
|
|
68
|
-
def inspect
|
76
|
+
def self.inspect
|
69
77
|
|
70
|
-
|
78
|
+
$parameters.inspect
|
71
79
|
|
72
80
|
end
|
73
81
|
|
74
|
-
def to_s
|
82
|
+
def self.to_s
|
75
83
|
|
76
|
-
|
84
|
+
$parameters.to_s
|
77
85
|
|
78
86
|
end
|
79
87
|
|
80
|
-
|
88
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
81
89
|
|
82
90
|
end # ParameterUserAPI
|
83
91
|
|
@@ -53,7 +53,7 @@ module MobyUtil
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# enable hooking for performance measurement & debug logging
|
56
|
-
|
56
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
57
57
|
|
58
58
|
end # Plugin
|
59
59
|
|
@@ -193,7 +193,7 @@ module MobyUtil
|
|
193
193
|
end
|
194
194
|
|
195
195
|
# enable hooking for performance measurement & debug logging
|
196
|
-
|
196
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
197
197
|
|
198
198
|
end # PluginService
|
199
199
|
|
@@ -17,8 +17,9 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
+
# Recorder module
|
21
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'recorder.rb' ) )
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
require File.expand_path( File.join( File.dirname( __FILE__ ), 'localisation/loader.rb' ) )
|
23
|
+
# Scripter module
|
24
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'scripter.rb' ) )
|
24
25
|
|
@@ -0,0 +1,66 @@
|
|
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 Testability Driver.
|
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
|
+
# Class for recording scripts from qt applications.
|
21
|
+
# Complete test script recording not supported.
|
22
|
+
# Application must be running when recording is started and
|
23
|
+
# must not be closed as a during the recording.
|
24
|
+
|
25
|
+
module MobyUtil
|
26
|
+
|
27
|
+
class Recorder
|
28
|
+
|
29
|
+
#TODO detect app start for later versions...
|
30
|
+
def self.start_rec( app )
|
31
|
+
|
32
|
+
#Kernel::raise ArgumentError.new("Application must be defined.") unless app
|
33
|
+
app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
|
34
|
+
|
35
|
+
app.start_recording
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
# Prints the recorded events as an tdriver script fragment.
|
40
|
+
def self.print_script( sut, app, object_identificators = ['text','icontext','label'] )
|
41
|
+
|
42
|
+
# verify that sut type is type of MobyBase::SUT
|
43
|
+
#Kernel::raise ArgumentError.new("Sut must be defined.") unless sut
|
44
|
+
sut.check_type( MobyBase::SUT, "Wrong argument type $1 for SUT (expected $2)" )
|
45
|
+
|
46
|
+
#Kernel::raise ArgumentError.new("Application must be defined.") unless app
|
47
|
+
app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
|
48
|
+
|
49
|
+
#Kernel::raise ArgumentError.new("Object identificators must be set, use defaults if not sure what the use.") unless object_identificators
|
50
|
+
object_identificators.check_type( Array, "Wrong argument type $1 for object identificators (expected $2)" )
|
51
|
+
|
52
|
+
xml_source = app.print_recordings
|
53
|
+
|
54
|
+
app.stop_recording
|
55
|
+
|
56
|
+
MobyUtil::Scripter.new( sut.id, object_identificators ).write_fragment( MobyBase::StateObject.new( xml_source ), app.name )
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# enable hooking for performance measurement & debug logging
|
61
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
62
|
+
|
63
|
+
end # Recorder
|
64
|
+
|
65
|
+
end # MobyUtil
|
66
|
+
|
@@ -0,0 +1,258 @@
|
|
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 Testability Driver.
|
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 MobyUtil
|
21
|
+
|
22
|
+
class Scripter
|
23
|
+
|
24
|
+
def initialize(sut_id, object_identificators)
|
25
|
+
|
26
|
+
@_object_identificators = object_identificators
|
27
|
+
|
28
|
+
@_tap_max_time = $parameters[sut_id][:record_tap_time_treshold].to_i
|
29
|
+
@_tap_min_distance = $parameters[sut_id][:record_move_treshold].to_i
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_fragment(xml_as_object, app_name)
|
34
|
+
|
35
|
+
script = "# Insert the script fragment below into your test \n"
|
36
|
+
script << "# Add verification points if needed. \n \n"
|
37
|
+
script << "# For testing the script! Do not include in your own test scripts. \n"
|
38
|
+
script << "@app = sut.application(:name =>'" << app_name << "') \n"
|
39
|
+
script << "# To test the script make sure the application is in the same state as it was when recording was started. \n\n"
|
40
|
+
script << "#################################### \n"
|
41
|
+
script << "# Begin recorded script \n"
|
42
|
+
script << "#################################### \n \n"
|
43
|
+
|
44
|
+
event_list = xml_as_object.events
|
45
|
+
event_count = event_list.attribute('eventCount').to_i
|
46
|
+
|
47
|
+
mouse_down = false
|
48
|
+
points = Array.new
|
49
|
+
active_target = nil
|
50
|
+
scripting = false;
|
51
|
+
mouse_status = 0
|
52
|
+
previous_time = nil
|
53
|
+
event = nil
|
54
|
+
|
55
|
+
for i in 0...event_count
|
56
|
+
|
57
|
+
event = event_list.event(:id => i.to_s)
|
58
|
+
type = event.name
|
59
|
+
|
60
|
+
previous_time = event.attribute('timeStamp').to_i unless previous_time
|
61
|
+
|
62
|
+
if type == 'MouseButtonPress'
|
63
|
+
active_target = get_target_details(event.child(:id => i.to_s))
|
64
|
+
scripting = true
|
65
|
+
mouse_status = 1
|
66
|
+
end
|
67
|
+
|
68
|
+
duration = get_duration(previous_time, event.attribute('timeStamp').to_i)
|
69
|
+
|
70
|
+
point = {'x' => event.attribute('windowX'), 'y' => event.attribute('windowY'), 'interval' => duration}
|
71
|
+
points.push(point) if scripting
|
72
|
+
|
73
|
+
previous_time = event.attribute('timeStamp').to_i
|
74
|
+
|
75
|
+
if type == 'MouseButtonRelease' and scripting
|
76
|
+
|
77
|
+
#mouse status based on the previous (if target changed no press)
|
78
|
+
mouse_status = 3 if mouse_status == 1
|
79
|
+
mouse_status = 2 if mouse_status == 0
|
80
|
+
script << generate_command(active_target, points, mouse_status) << "\n"
|
81
|
+
points.clear
|
82
|
+
active_target = nil
|
83
|
+
scripting = false
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if scripting and event
|
89
|
+
|
90
|
+
script << generate_command(active_target, points, mouse_status) << "\n"
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
script << "\n"
|
95
|
+
script << "#################################### \n"
|
96
|
+
script << "# End recorded script \n"
|
97
|
+
script << "#################################### \n"
|
98
|
+
script
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def add_command( mouse_status, active_target, points, duration )
|
105
|
+
|
106
|
+
fragment << fragment
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_target_details(test_object)
|
111
|
+
|
112
|
+
target = test_object.type
|
113
|
+
params = Array.new
|
114
|
+
|
115
|
+
params.push(":name=>'#{ test_object.name }'")
|
116
|
+
|
117
|
+
if test_object.name.empty?
|
118
|
+
|
119
|
+
params.clear
|
120
|
+
|
121
|
+
@_object_identificators.each do |attribute|
|
122
|
+
|
123
|
+
begin
|
124
|
+
|
125
|
+
value = test_object.attribute(attribute)
|
126
|
+
params.push(":#{ attribute } => '#{ value }'") unless value == ""
|
127
|
+
|
128
|
+
rescue MobyBase::AttributeNotFoundError
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
if params.size > 0
|
137
|
+
|
138
|
+
target << "( "
|
139
|
+
|
140
|
+
until params.size == 0
|
141
|
+
|
142
|
+
target << params.pop
|
143
|
+
target << ", " if params.size > 0
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
target << " )"
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
target
|
152
|
+
end
|
153
|
+
|
154
|
+
# mouse_status:
|
155
|
+
# 0 = no press or release
|
156
|
+
# 1 = press, no release
|
157
|
+
# 2 = release, no press
|
158
|
+
# 3 = press and release
|
159
|
+
def generate_command(target_details, points, mouse_status)
|
160
|
+
|
161
|
+
command = "@app."
|
162
|
+
|
163
|
+
if valid_gesture?(points)
|
164
|
+
|
165
|
+
command << target_details << ".gesture_points(\n\t[\n"
|
166
|
+
duration = 0
|
167
|
+
|
168
|
+
for i in 0...points.size
|
169
|
+
|
170
|
+
value = points[ i ]
|
171
|
+
command << "\t\t{'x' => " << value[ "x" ].to_s << ", 'y' => " << value[ "y" ].to_s << ", 'interval' => " << value[ "interval" ].to_s << " }"
|
172
|
+
command << ", \n" unless i == points.size - 1
|
173
|
+
duration = duration + value[ 'interval' ]
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
command << "\n\t], \n\t" << duration.to_s << ", \n\t"
|
178
|
+
|
179
|
+
case mouse_status
|
180
|
+
when 0
|
181
|
+
command << "{ :press => false, :release => false }"
|
182
|
+
when 1
|
183
|
+
command << "{ :press => true, :release => false }"
|
184
|
+
when 2
|
185
|
+
command << "{ :press => false, :release => true }"
|
186
|
+
when 3
|
187
|
+
command << "{ :press => true, :release => true }"
|
188
|
+
end
|
189
|
+
|
190
|
+
command << "\n)"
|
191
|
+
|
192
|
+
command
|
193
|
+
|
194
|
+
elsif mouse_status > 0
|
195
|
+
|
196
|
+
duration = 0
|
197
|
+
|
198
|
+
points.each{|value| duration = duration + value['interval']}
|
199
|
+
|
200
|
+
if mouse_status == 1
|
201
|
+
|
202
|
+
command << target_details << ".tap_down"
|
203
|
+
|
204
|
+
elsif duration < @_tap_max_time
|
205
|
+
|
206
|
+
command << target_details << ".tap"
|
207
|
+
|
208
|
+
else
|
209
|
+
|
210
|
+
command << target_details << ".long_tap( " << duration.to_s << " )"
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def valid_gesture?(points)
|
218
|
+
|
219
|
+
return false if points.size < 2
|
220
|
+
|
221
|
+
min_x = -1
|
222
|
+
max_x = -1
|
223
|
+
min_y = -1
|
224
|
+
max_y = -1
|
225
|
+
|
226
|
+
for i in 0...points.size
|
227
|
+
|
228
|
+
value = points[i]
|
229
|
+
|
230
|
+
x = value['x'].to_i
|
231
|
+
y = value['y'].to_i
|
232
|
+
|
233
|
+
min_x = x if x < min_x or min_x == -1
|
234
|
+
max_x = x if x > max_x or max_x == -1
|
235
|
+
min_y = y if y < min_y or min_y == -1
|
236
|
+
max_y = y if y > max_y or max_y == -1
|
237
|
+
|
238
|
+
end
|
239
|
+
|
240
|
+
return false if (max_x - min_x).abs < @_tap_min_distance and (max_y - min_y).abs < @_tap_min_distance
|
241
|
+
|
242
|
+
true
|
243
|
+
end
|
244
|
+
|
245
|
+
def get_duration(start_time, end_time)
|
246
|
+
duration_millis = end_time - start_time
|
247
|
+
#we want this in second
|
248
|
+
duration_millis = duration_millis.to_f
|
249
|
+
duration_secs = duration_millis / 1000
|
250
|
+
duration_secs
|
251
|
+
end
|
252
|
+
|
253
|
+
# enable hooking for performance measurement & debug logging
|
254
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
255
|
+
|
256
|
+
end # Scripter
|
257
|
+
|
258
|
+
end # MobyUtil
|