testability-driver 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tdriver-devtools +0 -0
- data/ext/native_extensions.c +165 -6
- data/lib/tdriver-devtools/behaviour/old/xml/update +0 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +0 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +15 -1
- data/lib/tdriver-devtools/doc/update +0 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +24 -14
- data/lib/tdriver-devtools/doc/xslt/update +0 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +0 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +0 -0
- data/lib/tdriver/base/behaviour/{behaviour.rb → abstract.rb} +3 -6
- data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +2 -2
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +47 -37
- data/lib/tdriver/base/behaviour/factory.rb +260 -382
- data/lib/tdriver/base/behaviour/loader.rb +22 -4
- data/lib/tdriver/base/controller/abstraction.rb +56 -0
- data/lib/tdriver/base/controller/loader.rb +21 -0
- data/lib/tdriver/base/loader.rb +3 -1
- data/lib/tdriver/base/sut/controller.rb +91 -74
- data/lib/tdriver/base/sut/factory.rb +8 -8
- data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +116 -96
- data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
- data/lib/tdriver/base/sut/sut.rb +10 -8
- data/lib/tdriver/base/test_object/abstract.rb +25 -24
- data/lib/tdriver/base/test_object/adapter.rb +67 -44
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +79 -20
- data/lib/tdriver/base/test_object/factory.rb +45 -15
- data/lib/tdriver/base/test_object/xml/adapter.rb +80 -57
- data/lib/tdriver/env.rb +0 -0
- data/lib/tdriver/loader.rb +0 -0
- data/lib/tdriver/matti.rb +0 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +1 -0
- data/lib/tdriver/report/report.rb +2 -1
- data/lib/tdriver/report/report_crash_file_capture.rb +12 -0
- data/lib/tdriver/report/report_creator.rb +6 -2
- data/lib/tdriver/report/report_execution_statistics.rb +27 -11
- data/lib/tdriver/report/report_graph_generator.rb +59 -0
- data/lib/tdriver/report/report_test_case_run.rb +34 -2
- data/lib/tdriver/report/report_writer.rb +12 -0
- data/lib/tdriver/tdriver.rb +12 -1
- data/lib/tdriver/util/agent/loader.rb +22 -0
- data/lib/tdriver/util/agent/service.rb +107 -0
- data/lib/tdriver/util/common/crc16.rb +17 -10
- data/lib/tdriver/util/common/hash.rb +4 -1
- data/lib/tdriver/util/common/kernel.rb +11 -0
- data/lib/tdriver/util/common/numeric.rb +48 -0
- data/lib/tdriver/util/common/object.rb +5 -2
- data/lib/tdriver/util/common/string.rb +8 -1
- data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
- data/lib/tdriver/util/filters/loader.rb +29 -0
- data/lib/tdriver/util/fixture/loader.rb +22 -0
- data/lib/tdriver/util/fixture/service.rb +157 -0
- data/lib/tdriver/util/loader.rb +8 -2
- data/lib/tdriver/util/logger/logger.rb +12 -6
- data/lib/tdriver/util/other/config.rb +0 -0
- data/lib/tdriver/util/parameter/parameter.rb +221 -152
- data/lib/tdriver/util/plugin/error.rb +0 -0
- data/lib/tdriver/util/video/camera_linux.rb +36 -22
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +3 -13
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +13 -8
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +51 -9
- data/lib/tdriver/util/xml/xml.rb +4 -2
- data/lib/tdriver/verify/verify.rb +280 -621
- data/lib/tdriver/version.rb +1 -1
- data/xml/behaviours/generic.xml +34 -0
- data/xml/templates/generic.xml +20 -3
- metadata +168 -240
- data/lib/tdriver-devtools/tests/feature_tests/output/application_closable_0x3f.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_close.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/application_environment.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_executable_name.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_uid.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/created.rid +0 -1
- data/lib/tdriver-devtools/tests/feature_tests/output/find_find.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash_images.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_application.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_capture_screen.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_child.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_clear_verify_blocks.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_connect.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order_0x3d.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_current_application_id.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_disconnect.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_dump_count.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_freeze.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_frozen.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_application_id.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_object.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_operator_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_ui_dump.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_user_information.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_input.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_parameter.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_press_key.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_received_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_timeout.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_tries.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_ui_dump.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_run.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_sent_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_state.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_translate.feature +0 -30
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_type.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_version.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_unfreeze.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_update.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_always.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_blocks.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_x_path.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_0x3d.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_crc.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_down.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_status.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_up.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_reset.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/verification_test_object_exists_0x3f.feature +0 -15
- data/lib/tdriver/base/behaviour/factory_new.rb +0 -409
- data/lib/tdriver/base/test_object/identificator.rb +0 -518
- data/lib/tdriver/util/filters/dynamic_attributes.rb +0 -189
@@ -17,12 +17,30 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
+
# behaviour abstract class
|
21
|
+
#require File.expand_path( File.join( File.dirname( __FILE__ ), 'abstract.rb' ) )
|
20
22
|
|
23
|
+
# factory class
|
24
|
+
#require File.expand_path( File.join( File.dirname( __FILE__ ), 'factory.rb' ) )
|
21
25
|
|
26
|
+
[
|
27
|
+
# behaviour abstract class
|
28
|
+
'abstract.rb',
|
22
29
|
|
23
|
-
# behaviour
|
24
|
-
|
25
|
-
|
30
|
+
# behaviour factory class
|
31
|
+
'factory.rb'
|
32
|
+
|
33
|
+
].each{ | filename |
|
34
|
+
|
35
|
+
require File.expand_path(
|
36
|
+
File.join( File.dirname( __FILE__ ), filename )
|
37
|
+
)
|
38
|
+
|
39
|
+
}
|
26
40
|
|
27
41
|
# load generic behaviours
|
28
|
-
MobyUtil::FileHelper.load_modules(
|
42
|
+
MobyUtil::FileHelper.load_modules(
|
43
|
+
File.expand_path(
|
44
|
+
File.join( File.dirname( __FILE__ ), 'behaviours' )
|
45
|
+
)
|
46
|
+
)
|
@@ -0,0 +1,56 @@
|
|
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 MobyController
|
21
|
+
|
22
|
+
module Abstraction
|
23
|
+
|
24
|
+
# TODO: document me
|
25
|
+
def set_adapter( adapter )
|
26
|
+
|
27
|
+
@sut_adapter = adapter
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# Execute the command(s). Sends output generated by make_message to the device using the @sut_adapter (see base class)
|
32
|
+
# == params
|
33
|
+
# == returns
|
34
|
+
# == raises
|
35
|
+
def execute
|
36
|
+
|
37
|
+
@sut_adapter.send_service_request(
|
38
|
+
|
39
|
+
*make_message
|
40
|
+
|
41
|
+
)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# TODO: document me
|
48
|
+
def make_message
|
49
|
+
|
50
|
+
raise NotImplementedError, "controller not implemented for #{ self.class.name }"
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end # Abstraction
|
55
|
+
|
56
|
+
end # MobyController
|
@@ -0,0 +1,21 @@
|
|
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
|
+
# command_data controller abstraction class etc.
|
21
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'abstraction.rb' ) )
|
data/lib/tdriver/base/loader.rb
CHANGED
@@ -17,13 +17,15 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
-
|
21
20
|
# behaviour abstraction class, factory and all other related modules etc
|
22
21
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'behaviour/loader' ) )
|
23
22
|
|
24
23
|
# command_data abstraction class etc.
|
25
24
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'command_data/loader' ) )
|
26
25
|
|
26
|
+
# command_data controller abstraction class etc.
|
27
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'controller/loader' ) )
|
28
|
+
|
27
29
|
# sut abstract class, generic sut etc
|
28
30
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'sut/loader' ) )
|
29
31
|
|
@@ -19,110 +19,127 @@
|
|
19
19
|
|
20
20
|
module MobyBase
|
21
21
|
|
22
|
-
|
22
|
+
class SutController
|
23
23
|
|
24
|
-
|
24
|
+
attr_accessor :sut_controllers, :execution_order #, :test_object_adapter, :test_object_factory
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
# Creating new SutController associates SutAdapter to the controller
|
27
|
+
# == params
|
28
|
+
# sut_adapter:: MobyController::SutAdapter descendant, e.g. MobyController::QT::SutAdapter
|
29
|
+
# == raises
|
30
30
|
# TypeError:: Wrong argument type $1 for SUT controller (expected $2)
|
31
|
-
|
32
|
-
|
31
|
+
# NameError:: No SUT controller found for %s (%s)
|
32
|
+
def initialize( sut_controllers, sut_adapter )
|
33
33
|
|
34
|
-
sut_controllers.check_type
|
34
|
+
sut_controllers.check_type String, 'Wrong argument type $1 for SUT controller (expected $2)'
|
35
35
|
|
36
|
-
|
36
|
+
@sut_adapter = sut_adapter
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
# empty sut controllers hash
|
39
|
+
@sut_controllers = {}
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
# empty sut controller execution order, this will be used when multiple sut controllers given
|
42
|
+
@execution_order = []
|
43
43
|
|
44
|
-
|
44
|
+
sut_controllers.split( ';' ).each{ | sut_type |
|
45
45
|
|
46
|
-
|
46
|
+
begin
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
# add sut_controller to execution order list
|
49
|
+
@execution_order << sut_type
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
# store sut controller
|
52
|
+
@sut_controllers[ sut_type ] = "MobyController::#{ sut_type }"
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
# extend controller module
|
55
|
+
extend( eval( "#{ @sut_controllers[ sut_type ] }::SutController" ) )
|
56
56
|
|
57
|
-
|
58
|
-
self.extend controller_module
|
57
|
+
rescue NameError
|
59
58
|
|
60
|
-
|
59
|
+
raise MobyBase::ControllerNotFoundError, "No SUT controller found for #{ sut_type } (#{ @sut_controllers[ sut_type ] }::SutController)"
|
61
60
|
|
62
|
-
|
61
|
+
end
|
63
62
|
|
64
|
-
|
63
|
+
}
|
65
64
|
|
66
|
-
|
65
|
+
end
|
67
66
|
|
68
|
-
|
67
|
+
# Function to execute a command on a SutController
|
68
|
+
# This method is not meant to be overwritten in descendants.
|
69
|
+
#
|
70
|
+
# Associates MobyCommand::CommandData implementation based on the MobyCommand class name,
|
71
|
+
# by finding implementation from the same module as the SutController instance.
|
72
|
+
#
|
73
|
+
# example: MobyController::QT::SutController instance associates MobyController::QT::Application (module)
|
74
|
+
# implementation to MobyCommand::Application command_data object
|
75
|
+
#
|
76
|
+
# == params
|
77
|
+
# command_data:: MobyCommand::CommandData descendant
|
78
|
+
# == returns
|
79
|
+
# command_data implementation specific return value
|
80
|
+
# == raises
|
81
|
+
# TypeError:: Wrong argument type $1 for command_data (expected $2)
|
82
|
+
# MobyBase::CommandNotFoundError:: if no implementation is found for the CommandData object
|
83
|
+
def execute_command( command_data )
|
69
84
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
# example: MobyController::QT::SutController instance associates MobyController::QT::Application (module)
|
77
|
-
# implementation to MobyCommand::Application command_data object
|
78
|
-
#
|
79
|
-
# == params
|
80
|
-
# command_data:: MobyCommand::CommandData descendant
|
81
|
-
# == returns
|
82
|
-
# command_data implementation specific return value
|
83
|
-
# == raises
|
84
|
-
# TypeError:: Wrong argument type $1 for command_data (expected $2)
|
85
|
-
# MobyBase::CommandNotFoundError:: if no implementation is found for the CommandData object
|
86
|
-
def execute_command( command_data )
|
87
|
-
command_data.check_type( MobyCommand::CommandData, "Wrong argument type $1 for command_data (expected $2)" )
|
88
|
-
|
89
|
-
@execution_order.each{ | controller |
|
90
|
-
|
91
|
-
begin
|
92
|
-
|
93
|
-
# extend command_data with combinination of command data object name and module name to be extended
|
94
|
-
eval 'command_data.extend %s::%s' % [ @sut_controllers[ controller ].first.first, command_data.class.name.scan( /::(.+)/ ).first.first ]
|
85
|
+
command_data.check_type MobyCommand::CommandData, 'Wrong argument type $1 for command_data (expected $2)'
|
86
|
+
|
87
|
+
# retrieve controller for command; iterate through each sut controller
|
88
|
+
@execution_order.each_with_index do | controller, index |
|
89
|
+
|
90
|
+
begin
|
95
91
|
|
96
|
-
|
97
|
-
|
92
|
+
# extend command_data with combinination of corresponding sut specific controller
|
93
|
+
command_data.extend eval("#{ @sut_controllers[ controller ] }::#{ command_data.class.name.gsub(/^MobyCommand::/, '') }")
|
94
|
+
|
95
|
+
break
|
96
|
+
|
97
|
+
rescue NameError
|
98
|
+
|
99
|
+
# raise exception only if none controller found
|
100
|
+
if ( index + 1 ) == @execution_order.count
|
98
101
|
|
99
|
-
|
102
|
+
raise MobyBase::ControllerNotFoundError, "No controller found for command data object #{ command_data.inspect }"
|
100
103
|
|
101
|
-
# raise exception only if none controller found
|
102
|
-
Kernel::raise MobyBase::ControllerNotFoundError.new( 'No controller found for CommandData object %s' % command_data.inspect ) unless controller.object_id != @execution_order.last.object_id
|
103
104
|
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
# pass sut_adapter for command_data
|
111
|
+
command_data.set_adapter( @sut_adapter )
|
112
|
+
|
108
113
|
retries = 0
|
114
|
+
|
109
115
|
begin
|
116
|
+
|
117
|
+
# execute the command
|
110
118
|
command_data.execute
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
119
|
+
|
120
|
+
rescue Errno::EPIPE, IOError
|
121
|
+
|
122
|
+
raise if retries == 1
|
123
|
+
|
124
|
+
retries += 1
|
125
|
+
|
126
|
+
if MobyBase::SUTFactory.instance.connected_suts.include?( @sut_adapter.sut_id.to_sym )
|
127
|
+
|
128
|
+
@sut_adapter.disconnect
|
129
|
+
|
130
|
+
@sut_adapter.connect( @sut_adapter.sut_id )
|
131
|
+
|
132
|
+
end
|
133
|
+
|
118
134
|
retry
|
135
|
+
|
119
136
|
end
|
120
|
-
|
121
|
-
|
122
|
-
# enable hooking for performance measurement & debug logging
|
123
|
-
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
137
|
+
|
138
|
+
end # execute_command
|
124
139
|
|
140
|
+
# enable hooking for performance measurement & debug logging
|
141
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
125
142
|
|
126
|
-
|
143
|
+
end # SutController
|
127
144
|
|
128
145
|
end # MobyBase
|
@@ -195,14 +195,14 @@ module MobyBase
|
|
195
195
|
end
|
196
196
|
|
197
197
|
# apply sut generic behaviours
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
198
|
+
TDriver::BehaviourFactory.apply_behaviour(
|
199
|
+
|
200
|
+
:object => created_sut,
|
201
|
+
:object_type => [ 'sut' ],
|
202
|
+
:sut_type => [ '*', created_sut.ui_type ],
|
203
|
+
:input_type => [ '*', created_sut.input.to_s ],
|
204
|
+
:env => [ '*', *sut_env.to_s.split(";") ],
|
205
|
+
:version => [ '*', created_sut.ui_version.to_s ]
|
206
206
|
|
207
207
|
)
|
208
208
|
|
@@ -0,0 +1,77 @@
|
|
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 MobyBehaviour
|
21
|
+
|
22
|
+
# == description
|
23
|
+
# Agent specific commands
|
24
|
+
#
|
25
|
+
# == behaviour
|
26
|
+
# AgentCommands
|
27
|
+
#
|
28
|
+
# == requires
|
29
|
+
# *
|
30
|
+
#
|
31
|
+
# == input_type
|
32
|
+
# *
|
33
|
+
#
|
34
|
+
# == sut_type
|
35
|
+
# *
|
36
|
+
#
|
37
|
+
# == sut_version
|
38
|
+
# *
|
39
|
+
#
|
40
|
+
# == objects
|
41
|
+
# AgentCommandService
|
42
|
+
module AgentCommands
|
43
|
+
|
44
|
+
include MobyBehaviour::Behaviour
|
45
|
+
|
46
|
+
# == nodoc
|
47
|
+
# == description
|
48
|
+
# Queries version of used agent
|
49
|
+
#
|
50
|
+
# == arguments
|
51
|
+
# == returns
|
52
|
+
# String
|
53
|
+
# description: version number in String format
|
54
|
+
# example: "1.3"
|
55
|
+
#
|
56
|
+
# == exceptions
|
57
|
+
#
|
58
|
+
# == info
|
59
|
+
# See SUT#agent method
|
60
|
+
def version
|
61
|
+
|
62
|
+
# execute command/model by using sut controller
|
63
|
+
execute_command(
|
64
|
+
|
65
|
+
# model
|
66
|
+
MobyCommand::AgentCommand.new( :command => :version )
|
67
|
+
|
68
|
+
)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# enable hooking for performance measurement & debug logging
|
73
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
74
|
+
|
75
|
+
end # AgentCommands
|
76
|
+
|
77
|
+
end # MobyBehaviour
|
@@ -51,23 +51,70 @@ module MobyBehaviour
|
|
51
51
|
:current_application_id, # id of the current appication if set
|
52
52
|
:input, # the input method used for interacting with this sut as a symbol, eg. :key or :touch.
|
53
53
|
:refresh_tries, # number of retries for ui dump on error case
|
54
|
-
:refresh_timeout
|
54
|
+
:refresh_timeout # timeout between timeout retry
|
55
55
|
|
56
56
|
)
|
57
57
|
|
58
58
|
# == nodoc
|
59
59
|
attr_reader(
|
60
60
|
|
61
|
-
:xml_data,
|
62
|
-
:x_path,
|
63
|
-
:ui_type,
|
64
|
-
:ui_version,
|
65
|
-
:frozen,
|
66
|
-
:
|
67
|
-
:verify_blocks
|
61
|
+
:xml_data, # sut xml_data
|
62
|
+
:x_path, # x_path pattern for xml_data
|
63
|
+
:ui_type, # type of the UI used on the sut, ie. s60, qt, windows
|
64
|
+
:ui_version, # version of the ui used on the sut, ie 3.2.3
|
65
|
+
:frozen, # flag that tells if the ui dump getting is disabled
|
66
|
+
:xml_data_checksum, # checksum of the previous ui state message
|
67
|
+
:verify_blocks, # verify blocks
|
68
|
+
:sut
|
68
69
|
|
69
70
|
)
|
70
71
|
|
72
|
+
private
|
73
|
+
|
74
|
+
# this method will be automatically invoked after module is extended to sut object
|
75
|
+
def self.extended( target_object )
|
76
|
+
|
77
|
+
target_object.instance_exec{
|
78
|
+
|
79
|
+
initialize_settings
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
# TODO: document me
|
86
|
+
def initialize_settings
|
87
|
+
|
88
|
+
# default values
|
89
|
+
@x_path = '.'
|
90
|
+
@xml_data = ""
|
91
|
+
@dump_count = 0
|
92
|
+
|
93
|
+
# determines that should child test objects be updated
|
94
|
+
@update_childs = true
|
95
|
+
|
96
|
+
@last_xml_data = nil
|
97
|
+
@frozen = false
|
98
|
+
|
99
|
+
# initialize cache for sut children
|
100
|
+
@child_object_cache = TDriver::TestObjectCache.new
|
101
|
+
|
102
|
+
@current_application_id = nil
|
103
|
+
|
104
|
+
# create empty hash for sut parameters if sut id not found from parameters
|
105
|
+
$parameters[ @id ] = {} unless $parameters.has_key?( @id )
|
106
|
+
|
107
|
+
@input = sut_parameters[ :input_type, 'key' ].to_sym
|
108
|
+
@refresh_tries = sut_parameters[ :ui_state_refresh_tries, '5' ].to_f
|
109
|
+
@refresh_interval = sut_parameters[ :refresh_interval, '0.5' ].to_f
|
110
|
+
|
111
|
+
# load verify blocks from defined sut configuration file
|
112
|
+
@verify_blocks = load_verify_blocks( sut_parameters[ :verify_blocks, nil ] )
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
public
|
117
|
+
|
71
118
|
# == description
|
72
119
|
# Connects selected SUT according to configuration in tdriver_parameters.xml.
|
73
120
|
# == arguments
|
@@ -81,7 +128,7 @@ module MobyBehaviour
|
|
81
128
|
# example: true
|
82
129
|
def connect( id )
|
83
130
|
|
84
|
-
@
|
131
|
+
@sut_controller.connect( id )
|
85
132
|
|
86
133
|
end
|
87
134
|
|
@@ -95,7 +142,7 @@ module MobyBehaviour
|
|
95
142
|
# @sut.disconnect
|
96
143
|
def disconnect
|
97
144
|
|
98
|
-
@
|
145
|
+
@sut_controller.disconnect
|
99
146
|
|
100
147
|
end
|
101
148
|
|
@@ -109,7 +156,7 @@ module MobyBehaviour
|
|
109
156
|
# @sut.disconnect
|
110
157
|
def received_data
|
111
158
|
|
112
|
-
@
|
159
|
+
@sut_controller.received_bytes
|
113
160
|
|
114
161
|
end
|
115
162
|
|
@@ -123,7 +170,7 @@ module MobyBehaviour
|
|
123
170
|
# @sut.sent_data
|
124
171
|
def sent_data
|
125
172
|
|
126
|
-
@
|
173
|
+
@sut_controller.sent_bytes
|
127
174
|
|
128
175
|
end
|
129
176
|
|
@@ -297,23 +344,23 @@ module MobyBehaviour
|
|
297
344
|
|
298
345
|
)
|
299
346
|
|
300
|
-
rescue MobyBase::MultipleTestObjectsIdentifiedError
|
347
|
+
rescue MobyBase::MultipleTestObjectsIdentifiedError
|
301
348
|
|
302
349
|
$logger.behaviour "FAIL;Multiple child objects matched criteria.;#{ id };sut;{};child;#{ attributes.inspect }"
|
303
350
|
|
304
|
-
|
351
|
+
raise
|
305
352
|
|
306
|
-
rescue MobyBase::TestObjectNotFoundError
|
353
|
+
rescue MobyBase::TestObjectNotFoundError
|
307
354
|
|
308
355
|
$logger.behaviour "FAIL;The child object could not be found.;#{ id };sut;{};child;#{ attributes.inspect }"
|
309
356
|
|
310
|
-
|
357
|
+
raise
|
311
358
|
|
312
|
-
rescue Exception
|
359
|
+
rescue Exception
|
313
360
|
|
314
361
|
$logger.behaviour "FAIL;Failed when trying to find child object.;#{ id };sut;{};child;#{ attributes.inspect }"
|
315
362
|
|
316
|
-
|
363
|
+
raise
|
317
364
|
|
318
365
|
ensure
|
319
366
|
|
@@ -370,7 +417,8 @@ module MobyBehaviour
|
|
370
417
|
else
|
371
418
|
$logger.behaviour "FAIL;No methods or parameters found for sut.setup"
|
372
419
|
|
373
|
-
|
420
|
+
raise MobyBase::BehaviourError.new("Setup", "Failed to load sut.setup method check the :sut_setup parameter")
|
421
|
+
|
374
422
|
end
|
375
423
|
|
376
424
|
|
@@ -419,7 +467,8 @@ module MobyBehaviour
|
|
419
467
|
else
|
420
468
|
$logger.behaviour "FAIL;No method or parameters found for sut.teardown"
|
421
469
|
|
422
|
-
|
470
|
+
raise MobyBase::BehaviourError.new("Teardown", "Failed to load sut.teardown method check the :sut_teardown parameter")
|
471
|
+
|
423
472
|
end
|
424
473
|
|
425
474
|
end
|
@@ -464,7 +513,7 @@ module MobyBehaviour
|
|
464
513
|
# refresh if xml data is empty
|
465
514
|
self.refresh if @xml_data.empty?
|
466
515
|
|
467
|
-
|
516
|
+
raise RuntimeError, "Can not create state object of SUT with id #{ @id.inspect }, no XML content or SUT not initialized properly." if @xml_data.empty?
|
468
517
|
|
469
518
|
source_data = @test_object_adapter.state_object_xml( @xml_data, @id )
|
470
519
|
|
@@ -532,7 +581,7 @@ module MobyBehaviour
|
|
532
581
|
)
|
533
582
|
|
534
583
|
# raise same exception
|
535
|
-
|
584
|
+
raise
|
536
585
|
|
537
586
|
ensure
|
538
587
|
|
@@ -611,7 +660,7 @@ module MobyBehaviour
|
|
611
660
|
|
612
661
|
$logger.behaviour "FAIL;Failed to capture screen.;#{ id.to_s };sut;{};capture_screen;#{ arguments.kind_of?( Hash ) ? arguments.inspect : arguments.class.to_s }"
|
613
662
|
|
614
|
-
|
663
|
+
raise
|
615
664
|
|
616
665
|
end
|
617
666
|
|
@@ -641,7 +690,7 @@ module MobyBehaviour
|
|
641
690
|
# |Key|Type|Description|Example|
|
642
691
|
# |:uid|String or Integer|Unique ID of the application|{ :uid => 268458181 }|
|
643
692
|
# |:name|String|Executable name of the application|{ :name => 'calculator' }|
|
644
|
-
# |:restart_if_running|Boolean|Restart application if already running
|
693
|
+
# |:restart_if_running|Boolean|Restart application if already running|{ :restart_if_running => true }|
|
645
694
|
# |:arguments|String|Comma separated list of arguments passed to the application when it is started|{ :arguments => '--nogui,-v' }|
|
646
695
|
# |:check_pid|Boolean|Overrides default value of SUT parameter :application_check_pid; When set to true, process id is used to test object identification|false|
|
647
696
|
# |:sleep_time|Integer|Number of seconds to sleep immediately after launching the process|{ :sleep_time => 10 }|
|
@@ -704,7 +753,7 @@ module MobyBehaviour
|
|
704
753
|
|
705
754
|
end
|
706
755
|
|
707
|
-
|
756
|
+
raise ArgumentError, "Sleep time need to be >= 0" unless sleep_time >= 0
|
708
757
|
|
709
758
|
# try to find an existing app with the current arguments
|
710
759
|
if target[ :try_attach ] || target[:restart_if_running]
|
@@ -751,7 +800,7 @@ module MobyBehaviour
|
|
751
800
|
|
752
801
|
if ( target[ :start_command ] != nil )
|
753
802
|
|
754
|
-
|
803
|
+
raise MobyBase::BehaviourError.new("Run", "Failed to load execute_shell_method") unless self.respond_to?("execute_shell_command")
|
755
804
|
|
756
805
|
execute_shell_command( target[ :start_command ], :detached => "true" )
|
757
806
|
|
@@ -879,11 +928,11 @@ module MobyBehaviour
|
|
879
928
|
|
880
929
|
rescue MobyBase::TestObjectNotFoundError
|
881
930
|
|
882
|
-
|
931
|
+
raise MobyBase::VerificationError, "No application type test object was found on the device after starting the application."
|
883
932
|
|
884
933
|
rescue MobyBase::SyncTimeoutError
|
885
934
|
|
886
|
-
|
935
|
+
raise MobyBase::VerificationError, "The application (#{ error_details }) was not found on the sut after being launched."
|
887
936
|
|
888
937
|
end
|
889
938
|
|
@@ -892,7 +941,7 @@ module MobyBehaviour
|
|
892
941
|
|
893
942
|
$logger.behaviour "FAIL;Failed to launch application.;#{ id.to_s };sut;{};run;#{ target.kind_of?( Hash ) ? target.inspect : target.class.to_s }"
|
894
943
|
|
895
|
-
|
944
|
+
raise MobyBase::BehaviourError.new("Run", "Failed to launch application")
|
896
945
|
|
897
946
|
end
|
898
947
|
|
@@ -968,7 +1017,7 @@ module MobyBehaviour
|
|
968
1017
|
|
969
1018
|
$logger.behaviour "FAIL;Failed to press key(s).;#{id.to_s};sut;{};press_key;#{ value }"
|
970
1019
|
|
971
|
-
|
1020
|
+
raise
|
972
1021
|
|
973
1022
|
end
|
974
1023
|
|
@@ -1086,7 +1135,7 @@ module MobyBehaviour
|
|
1086
1135
|
#
|
1087
1136
|
def translate( logical_name, file_name = nil, plurality = nil, numerus = nil, lengthvariant = nil )
|
1088
1137
|
|
1089
|
-
|
1138
|
+
raise LogicalNameNotFoundError, "Logical name is nil" if logical_name.nil?
|
1090
1139
|
|
1091
1140
|
translation_type = "localisation"
|
1092
1141
|
|
@@ -1140,7 +1189,7 @@ module MobyBehaviour
|
|
1140
1189
|
|
1141
1190
|
end
|
1142
1191
|
|
1143
|
-
|
1192
|
+
raise LanguageNotFoundError, "Language cannot be determind to perform translation" if ( language.nil? || language.empty? )
|
1144
1193
|
|
1145
1194
|
translation = MobyUtil::Localisation.translation(
|
1146
1195
|
logical_name,
|
@@ -1431,6 +1480,16 @@ module MobyBehaviour
|
|
1431
1480
|
end
|
1432
1481
|
|
1433
1482
|
end
|
1483
|
+
|
1484
|
+
# == nodoc
|
1485
|
+
# == description
|
1486
|
+
# == returns
|
1487
|
+
def agent
|
1488
|
+
|
1489
|
+
# pass agent command service object
|
1490
|
+
TDriver::AgentService.new( :sut => self )
|
1491
|
+
|
1492
|
+
end
|
1434
1493
|
|
1435
1494
|
private
|
1436
1495
|
|
@@ -1450,7 +1509,7 @@ module MobyBehaviour
|
|
1450
1509
|
|
1451
1510
|
current_time = Time.now
|
1452
1511
|
|
1453
|
-
|
1512
|
+
unless @frozen
|
1454
1513
|
|
1455
1514
|
# determine should FindObjects service be used
|
1456
1515
|
use_find_objects = sut_parameters[ :use_find_object, 'false' ] == 'true' and self.respond_to?( 'find_object' ) == true
|
@@ -1459,23 +1518,26 @@ module MobyBehaviour
|
|
1459
1518
|
refresh_arguments = refresh_args.clone
|
1460
1519
|
|
1461
1520
|
MobyUtil::Retryable.while(
|
1462
|
-
|
1463
|
-
:interval => @refresh_interval,
|
1464
|
-
|
1521
|
+
|
1522
|
+
:tries => @refresh_tries, :interval => @refresh_interval, :unless => [ MobyBase::ControllerNotFoundError, MobyBase::CommandNotFoundError, MobyBase::ApplicationNotAvailableError ]
|
1523
|
+
|
1465
1524
|
){
|
1466
1525
|
|
1526
|
+
# store as local variable for less AST lookups
|
1527
|
+
xml_data_checksum = @xml_data_checksum
|
1528
|
+
|
1467
1529
|
#use find_object if set on and the method exists
|
1468
1530
|
if use_find_objects
|
1469
1531
|
|
1470
|
-
# retrieve new ui dump xml and
|
1471
|
-
new_xml_data,
|
1532
|
+
# retrieve new ui dump xml and checksum
|
1533
|
+
new_xml_data, new_checksum = find_object( refresh_arguments, creation_attributes, xml_data_checksum )
|
1472
1534
|
|
1473
|
-
|
1535
|
+
new_checksum = xml_data_checksum if new_xml_data.empty?
|
1474
1536
|
|
1475
1537
|
else
|
1476
1538
|
|
1477
|
-
# retrieve new ui dump xml and
|
1478
|
-
new_xml_data,
|
1539
|
+
# retrieve new ui dump xml and checksum
|
1540
|
+
new_xml_data, new_checksum = execute_command(
|
1479
1541
|
|
1480
1542
|
MobyCommand::Application.new(
|
1481
1543
|
:State,
|
@@ -1484,30 +1546,30 @@ module MobyBehaviour
|
|
1484
1546
|
:application_uid => refresh_args[ :id ],
|
1485
1547
|
:sut => self,
|
1486
1548
|
:refresh_arguments => refresh_args,
|
1487
|
-
:checksum =>
|
1549
|
+
:checksum => xml_data_checksum
|
1488
1550
|
}
|
1489
1551
|
)
|
1490
1552
|
|
1491
1553
|
)
|
1492
1554
|
|
1493
|
-
|
1555
|
+
new_checksum = xml_data_checksum if new_xml_data.empty?
|
1494
1556
|
|
1495
1557
|
end
|
1496
1558
|
|
1497
|
-
# parse the xml if
|
1498
|
-
if (
|
1559
|
+
# parse the xml if checksum does not match with previously retrieved checksum
|
1560
|
+
if ( xml_data_checksum == 0 || new_checksum != xml_data_checksum || new_checksum.blank? )
|
1499
1561
|
|
1500
|
-
|
1501
|
-
|
1562
|
+
# parse new xml string, return cached object if one is found; checksum is used for caching and identifying the duplicate xml strings
|
1563
|
+
xml_data, from_cache = MobyUtil::XML.parse_string( new_xml_data, new_checksum )
|
1502
1564
|
|
1503
|
-
|
1504
|
-
|
1565
|
+
# store new xml data object
|
1566
|
+
@xml_data = xml_data.root
|
1505
1567
|
|
1506
|
-
|
1507
|
-
|
1568
|
+
# store xml checksum to be compared while next ui dump request; do not reparse xml if checksum values are equal
|
1569
|
+
@xml_data_checksum = new_checksum
|
1508
1570
|
|
1509
|
-
|
1510
|
-
|
1571
|
+
# mark that child objects needs to be updated
|
1572
|
+
@update_childs = true #unless from_cache
|
1511
1573
|
|
1512
1574
|
end
|
1513
1575
|
|
@@ -1673,17 +1735,6 @@ module MobyBehaviour
|
|
1673
1735
|
app_info
|
1674
1736
|
end
|
1675
1737
|
|
1676
|
-
# this method will be automatically invoked after module is extended to sut object
|
1677
|
-
def self.extended( target_object )
|
1678
|
-
|
1679
|
-
target_object.instance_exec{
|
1680
|
-
|
1681
|
-
initialize_settings
|
1682
|
-
|
1683
|
-
}
|
1684
|
-
|
1685
|
-
end
|
1686
|
-
|
1687
1738
|
def load_verify_blocks( filename )
|
1688
1739
|
|
1689
1740
|
# load verify blocks if filename not empty
|
@@ -1714,37 +1765,6 @@ module MobyBehaviour
|
|
1714
1765
|
|
1715
1766
|
end
|
1716
1767
|
|
1717
|
-
# TODO: document me
|
1718
|
-
def initialize_settings
|
1719
|
-
|
1720
|
-
# default values
|
1721
|
-
@x_path = '.'
|
1722
|
-
@xml_data = ""
|
1723
|
-
@dump_count = 0
|
1724
|
-
|
1725
|
-
# determines that should child test objects be updated
|
1726
|
-
@update_childs = true
|
1727
|
-
|
1728
|
-
@last_xml_data = nil
|
1729
|
-
@frozen = false
|
1730
|
-
|
1731
|
-
# initialize cache for sut children
|
1732
|
-
@child_object_cache = TDriver::TestObjectCache.new
|
1733
|
-
|
1734
|
-
@current_application_id = nil
|
1735
|
-
|
1736
|
-
# create empty hash for sut parameters if sut id not found from parameters
|
1737
|
-
$parameters[ @id ] = {} unless $parameters.has_key?( @id )
|
1738
|
-
|
1739
|
-
@input = sut_parameters[ :input_type, 'key' ].to_sym
|
1740
|
-
@refresh_tries = sut_parameters[ :ui_state_refresh_tries, '5' ].to_f
|
1741
|
-
@refresh_interval = sut_parameters[ :refresh_interval, '0.5' ].to_f
|
1742
|
-
|
1743
|
-
# load verify blocks from defined sut configuration file
|
1744
|
-
@verify_blocks = load_verify_blocks( sut_parameters[ :verify_blocks, nil ] )
|
1745
|
-
|
1746
|
-
end
|
1747
|
-
|
1748
1768
|
# accessor for sut parameters
|
1749
1769
|
def sut_parameters
|
1750
1770
|
|
@@ -1752,7 +1772,7 @@ module MobyBehaviour
|
|
1752
1772
|
|
1753
1773
|
end
|
1754
1774
|
|
1755
|
-
|
1775
|
+
public # deprecated
|
1756
1776
|
|
1757
1777
|
# == nodoc
|
1758
1778
|
# function to get TestObject
|