Class: MobyPlugin::QT::SUT

Inherits:
MobyUtil::Plugin
  • Object
show all
Defined in:
lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb

Class Method Summary collapse

Class Method Details

.make_sut(sut_id) ⇒ Object

returns SUT object - this method will be called from TDriver::SUTFactory



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 104

def self.make_sut( sut_id )

     # retrieve sut specific parameters
     sut_parameters = $parameters[ sut_id ]

     # create sut adapter
     adapter = MobyController::QT::SutAdapter.new( 

       # sut id
       sut_id,

       # tcp/ip read timeouts, default: 15 (seconds) 
       $parameters[ sut_id ][ :socket_read_timeout,  "15" ].to_i,

       # tcp/ip write timeouts, default: 15 (seconds)
       $parameters[ sut_id ][ :socket_write_timeout, "25" ].to_i,

       # tcp/ip connection timeouts, default: 15 (seconds)
       $parameters[ sut_id ][ :socket_connect_timeout, "15" ].to_i


     )

       # create controller for sut
	sut_controller = MobyBase::SutController.new( 

       # controller id
       "QT", 

       adapter

     )

     # create sut object
	sut = MobyBase::SUT.new(

       sut_controller,

       # pass test object factory class
		TDriver::TestObjectFactory,

       # pass sut id
		sut_id 
	)

     # hook connect method
     adapter.add_hook( 'before_connect' ){}

     # hook connect method
     adapter.add_hook( 'after_connect' ){

       begin

         # send service request for agent version number
         agent_version = sut_controller.__send__( :execute_command, MobyCommand::VersionCommand.new )

         # agent version 1.3 or later supports new smaller xml format
         if agent_version >= "1.3"
         
           # use optimized XML format; if adapter is not found we're going through rescue block
           adapter = TDriver::OptimizedXML::TestObjectAdapter

         else

           # didn't recognize the version number use old TDriver::TestObjectAdapter
           raise
         
         end

       rescue

         # in case of any exceptions use TDriver::TestObjectAdapter with old XML format
         adapter = TDriver::TestObjectAdapter

       end

       #sut_controller.test_object_adapter = adapter
       sut.instance_variable_set( :@test_object_adapter, adapter )

     }

     # return sut object as result
     sut

end

.plugin_nameObject

plugin configuration, constructor and deconstructor methods



38
39
40
41
42
43
44
45
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 38

def self.plugin_name

	#File.basename( __FILE__, '.rb' ).downcase # => "tdriver-qt-sut-plugin" 

	# return plugin name as string
	"testability-driver-qt-sut-plugin"

end

.plugin_typeObject



47
48
49
50
51
52
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 47

def self.plugin_type

	# return plugin type as symbol
	:sut

end

.register_pluginObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 54

def self.register_plugin

	# load plugin specific implementation or other initialization etc.
	MobyUtil::FileHelper.load_modules( 

		# load utility modules
		'util/*.rb', 

		# sut communication class
		'sut/communication.rb', 

		# sut adapter class
		'sut/adapter.rb', 

		# sut controller
		'sut/controller.rb', 

		# qt behaviour abstraction class
		'behaviours/behaviour.rb', 

		# load behaviour(s)
		'behaviours/*.rb', 

		# load command(s)
		'commands/*.rb',

		# load command controller(s)
		'controllers/*.rb'

	)

end

.sut_typeObject

return sut type that plugin implements



96
97
98
99
100
101
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 96

def self.sut_type

	# return sut type as string
	"QT"

end

.unregister_pluginObject



87
88
89
90
91
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb', line 87

def self.unregister_plugin

	# unregister plugin

end