testability-driver 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/bin/start_app_perf +199 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +39 -0
- data/ext/extconf.rb +67 -0
- data/ext/native_extensions.c +70 -0
- data/lib/matti.rb +30 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
- data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
- data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
- data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/generate.rb +892 -0
- data/lib/tdriver-devtools/doc/update +1 -0
- data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
- data/lib/tdriver-devtools/doc/xslt/update +3 -0
- data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
- data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
- data/lib/tdriver.rb +26 -0
- data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
- data/lib/tdriver/base/behaviour/factory.rb +380 -0
- data/lib/tdriver/base/behaviour/loader.rb +28 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +25 -0
- data/lib/tdriver/base/errors.rb +131 -0
- data/lib/tdriver/base/loader.rb +38 -0
- data/lib/tdriver/base/state_object.rb +270 -0
- data/lib/tdriver/base/sut/adapter.rb +28 -0
- data/lib/tdriver/base/sut/controller.rb +119 -0
- data/lib/tdriver/base/sut/factory.rb +287 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +67 -0
- data/lib/tdriver/base/test_object/abstract.rb +179 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
- data/lib/tdriver/base/test_object/factory.rb +618 -0
- data/lib/tdriver/base/test_object/identificator.rb +511 -0
- data/lib/tdriver/base/test_object/loader.rb +37 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +36 -0
- data/lib/tdriver/matti.rb +35 -0
- data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
- data/lib/tdriver/report/report.rb +47 -0
- data/lib/tdriver/report/report_api.rb +207 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
- data/lib/tdriver/report/report_creator.rb +571 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
- data/lib/tdriver/report/report_data_presentation.rb +152 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +284 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_grouping.rb +539 -0
- data/lib/tdriver/report/report_junit_xml.rb +147 -0
- data/lib/tdriver/report/report_rspec.rb +108 -0
- data/lib/tdriver/report/report_test_case_run.rb +621 -0
- data/lib/tdriver/report/report_test_run.rb +1286 -0
- data/lib/tdriver/report/report_test_unit.rb +175 -0
- data/lib/tdriver/report/report_writer.rb +1405 -0
- data/lib/tdriver/tdriver.rb +158 -0
- data/lib/tdriver/util/common.rb +24 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/crc16.rb +100 -0
- data/lib/tdriver/util/common/environment.rb +153 -0
- data/lib/tdriver/util/common/error.rb +39 -0
- data/lib/tdriver/util/common/file.rb +315 -0
- data/lib/tdriver/util/common/gem.rb +108 -0
- data/lib/tdriver/util/common/kernel.rb +189 -0
- data/lib/tdriver/util/common/loader.rb +39 -0
- data/lib/tdriver/util/common/retryable.rb +98 -0
- data/lib/tdriver/util/common/string.rb +77 -0
- data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
- data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
- data/lib/tdriver/util/dbaccess/error.rb +35 -0
- data/lib/tdriver/util/dbaccess/loader.rb +29 -0
- data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
- data/lib/tdriver/util/hooking.rb +434 -0
- data/lib/tdriver/util/loader.rb +65 -0
- data/lib/tdriver/util/localisation.rb +24 -0
- data/lib/tdriver/util/localisation/error.rb +32 -0
- data/lib/tdriver/util/localisation/loader.rb +28 -0
- data/lib/tdriver/util/localisation/localisation.rb +479 -0
- data/lib/tdriver/util/logger.rb +377 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +26 -0
- data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
- data/lib/tdriver/util/other/config.rb +221 -0
- data/lib/tdriver/util/parameter.rb +24 -0
- data/lib/tdriver/util/parameter/error.rb +45 -0
- data/lib/tdriver/util/parameter/loader.rb +37 -0
- data/lib/tdriver/util/parameter/parameter.rb +285 -0
- data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
- data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
- data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
- data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
- data/lib/tdriver/util/plugin/abstract.rb +60 -0
- data/lib/tdriver/util/plugin/error.rb +25 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +200 -0
- data/lib/tdriver/util/recorder.rb +292 -0
- data/lib/tdriver/util/stats.rb +90 -0
- data/lib/tdriver/util/user_data/error.rb +29 -0
- data/lib/tdriver/util/user_data/loader.rb +26 -0
- data/lib/tdriver/util/user_data/user_data.rb +103 -0
- data/lib/tdriver/util/video_rec.rb +264 -0
- data/lib/tdriver/util/xml/abstraction.rb +47 -0
- data/lib/tdriver/util/xml/builder.rb +54 -0
- data/lib/tdriver/util/xml/document.rb +32 -0
- data/lib/tdriver/util/xml/element.rb +32 -0
- data/lib/tdriver/util/xml/error.rb +46 -0
- data/lib/tdriver/util/xml/loader.rb +46 -0
- data/lib/tdriver/util/xml/nil_element.rb +89 -0
- data/lib/tdriver/util/xml/nodeset.rb +32 -0
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
- data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
- data/lib/tdriver/util/xml/xml.rb +170 -0
- data/lib/tdriver/verify/verify.rb +687 -0
- data/lib/tdriver/verify/verify.rb_org +630 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +495 -0
- data/xml/defaults/generic.xml +97 -0
- data/xml/defaults/sut_generic.xml +36 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +227 -0
- metadata +327 -0
@@ -0,0 +1,90 @@
|
|
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
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'net/http'
|
23
|
+
require 'socket'
|
24
|
+
require 'uri'
|
25
|
+
require 'date'
|
26
|
+
|
27
|
+
# Utility for storing statistics regarding TDriver usage
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# Usage:
|
31
|
+
#
|
32
|
+
# 1. report installation
|
33
|
+
# MobyUtil::Stats.report('install', 'message')
|
34
|
+
# will report installation event, message is optional
|
35
|
+
#
|
36
|
+
# 2. report activation of TDriver
|
37
|
+
# MobyUtil::Stats.report('install', 'message')
|
38
|
+
# will report TDriver activation event, message is optional
|
39
|
+
#
|
40
|
+
# 3. report exception raised by TDriver
|
41
|
+
# MobyUtil::Stats.report('exception', 'message describing the exception')
|
42
|
+
# will report exception thrown by TDriver, message describes the the exception
|
43
|
+
#
|
44
|
+
|
45
|
+
module MobyUtil
|
46
|
+
|
47
|
+
class Stats
|
48
|
+
|
49
|
+
def self.report( action, message )
|
50
|
+
|
51
|
+
return nil if defined?( $_TDRIVER_DISABLE_STATS_REPORTING )
|
52
|
+
|
53
|
+
report_thread = Thread.new{
|
54
|
+
|
55
|
+
begin
|
56
|
+
# TODO: override possibility for the url using parameters?
|
57
|
+
url = URI.parse('http://127.0.0.1/tdriver/stats/create/new_stat')
|
58
|
+
|
59
|
+
resp, data = Net::HTTP.new( url.host, url.port ).post(
|
60
|
+
url.path,
|
61
|
+
"stat[action]=#{ action }" <<
|
62
|
+
"&stat[host]=#{ Socket.gethostname }" <<
|
63
|
+
"&stat[time_stamp]=#{ DateTime.now.strftime( "%Y%m%d%H%M%S" ) }" <<
|
64
|
+
"&stat[message]=#{ message }" <<
|
65
|
+
"&stat[user]=#{ 'NO' }" <<
|
66
|
+
"&stat[ip]=#{ 'NO' }" <<
|
67
|
+
"&stat[mac]=#{ 'NO' }" <<
|
68
|
+
"&stat[platform]=#{ RUBY_PLATFORM.to_s }" <<
|
69
|
+
"&stat[version]=#{ ENV['TDRIVER_VERSION'] }" <<
|
70
|
+
"&commit=#{ 'Create' }",
|
71
|
+
{ 'Content-Type' => 'application/x-www-form-urlencoded' }
|
72
|
+
)
|
73
|
+
|
74
|
+
rescue Exception => e
|
75
|
+
|
76
|
+
#puts "Exception:#{e.message} trace:#{e.backtrace.inspect}"
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
report_thread
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
87
|
+
|
88
|
+
end # Stats
|
89
|
+
|
90
|
+
end # MobyUtil
|
@@ -0,0 +1,29 @@
|
|
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
|
+
|
21
|
+
module MobyUtil
|
22
|
+
|
23
|
+
# This error should be raised when the desired user data is not found
|
24
|
+
class UserDataNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
|
25
|
+
|
26
|
+
# This error should be raised when the desired data column name to be used for the output is not found
|
27
|
+
class UserDataColumnNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
|
21
|
+
# user data inputs related errors
|
22
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'error.rb' ) )
|
23
|
+
|
24
|
+
# user data inputs module implementation
|
25
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'user_data.rb' ) )
|
26
|
+
|
@@ -0,0 +1,103 @@
|
|
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
|
+
# Utility for handling user data database
|
21
|
+
|
22
|
+
module MobyUtil
|
23
|
+
|
24
|
+
class UserData
|
25
|
+
|
26
|
+
# == description
|
27
|
+
# Function for fetching user data from the user data DB
|
28
|
+
#
|
29
|
+
# == arguments
|
30
|
+
# user_data_lname
|
31
|
+
# String
|
32
|
+
# description: String containing user_data_lname to be used in fetching the translation
|
33
|
+
# example: "uif_first_name"
|
34
|
+
#
|
35
|
+
# language
|
36
|
+
# String
|
37
|
+
# description: Scring containing language to be used in fetching user information
|
38
|
+
# example: "en"
|
39
|
+
#
|
40
|
+
# table_name
|
41
|
+
# String
|
42
|
+
# description: String containing the name of table to be used when user information
|
43
|
+
# example: "user_data_week201042"
|
44
|
+
#
|
45
|
+
# == returns
|
46
|
+
# String
|
47
|
+
# description: User data string
|
48
|
+
#
|
49
|
+
# Array
|
50
|
+
# description: Array of values when multiple user data strings found
|
51
|
+
#
|
52
|
+
# == throws
|
53
|
+
# UserDataNotFoundError
|
54
|
+
# description: If the desired user data is not found
|
55
|
+
#
|
56
|
+
# UserDataColumnNotFoundError
|
57
|
+
# description: If the desired data column name to be used for the output is not found
|
58
|
+
#
|
59
|
+
# SqlError
|
60
|
+
# description: If there is and sql error while executing the query
|
61
|
+
#
|
62
|
+
def self.retrieve( user_data_lname, language, table_name )
|
63
|
+
|
64
|
+
Kernel::raise UserDataNotFoundError.new( "User data logical name can't be empty" ) if user_data_lname == nil
|
65
|
+
|
66
|
+
# Get Localization parameters for DB Connection
|
67
|
+
db_type = MobyUtil::Parameter[ :user_data_db_type, nil ].to_s.downcase
|
68
|
+
host = MobyUtil::Parameter[ :user_data_server_ip ]
|
69
|
+
username = MobyUtil::Parameter[ :user_data_server_username ]
|
70
|
+
password = MobyUtil::Parameter[ :user_data_server_password ]
|
71
|
+
database_name = MobyUtil::Parameter[ :user_data_server_database_name ]
|
72
|
+
|
73
|
+
db_connection = DBConnection.new( db_type, host, database_name, username, password )
|
74
|
+
|
75
|
+
query_string = "select `#{ language }` from #{ table_name } where lname = \'#{ user_data_lname }' and `#{ language }` <>\'#MISSING\'"
|
76
|
+
|
77
|
+
begin
|
78
|
+
result = MobyUtil::DBAccess.query( db_connection, query_string )
|
79
|
+
rescue
|
80
|
+
# if column referring to language is not found then Kernel::raise error for language not found
|
81
|
+
Kernel::raise UserDataColumnNotFoundError.new( "User data language column '#{ language }' was not found" ) unless $!.message.index( "Unknown column" ) == nil
|
82
|
+
Kernel::raise SqlError.new( $!.message )
|
83
|
+
end
|
84
|
+
|
85
|
+
# Return only the first column of the row or and array of the values of the first column if multiple rows have been found
|
86
|
+
Kernel::raise UserDataNotFoundError.new( "No user data for '#{ user_data_lname }' found for language '#{ language }'" ) if ( result.empty?)
|
87
|
+
if result.length > 1
|
88
|
+
result_array = Array.new # array of rows! We want the first column of the first row
|
89
|
+
result.each do |row|
|
90
|
+
result_array << row[0]
|
91
|
+
end
|
92
|
+
return result_array
|
93
|
+
else
|
94
|
+
# Result is an Array of rows (Array<String>)! We want the first column of the first row.
|
95
|
+
return result[0][0]
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end # class
|
101
|
+
|
102
|
+
end # module
|
103
|
+
|
@@ -0,0 +1,264 @@
|
|
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
|
+
|
21
|
+
module MobyUtil
|
22
|
+
|
23
|
+
# Base class and interface for camera recorders in TDriver
|
24
|
+
class TDriverCam
|
25
|
+
|
26
|
+
# Automatically select the right kind of camera implementation for the detected platform.
|
27
|
+
def self.new_cam( *args )
|
28
|
+
|
29
|
+
if EnvironmentHelper.windows?
|
30
|
+
|
31
|
+
return TDriverWinCam.new( *args )
|
32
|
+
|
33
|
+
elsif EnvironmentHelper.linux?
|
34
|
+
|
35
|
+
return TDriverLinuxCam.new( *args )
|
36
|
+
|
37
|
+
else
|
38
|
+
raise RuntimeError.new("Unidentified platform type, unable to select platform specific camera. Supported platform types: Linux, Windows.")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize
|
44
|
+
raise RuntimeError.new("TDriverCam abstract class")
|
45
|
+
end
|
46
|
+
|
47
|
+
def start_recording
|
48
|
+
raise RuntimeError.new("TDriverCam abstract class")
|
49
|
+
end
|
50
|
+
|
51
|
+
def stop_recording
|
52
|
+
raise RuntimeError.new("TDriverCam abstract class")
|
53
|
+
end
|
54
|
+
|
55
|
+
end # TDriverCam
|
56
|
+
|
57
|
+
# Windows DirectShow webcam implementation
|
58
|
+
class TDriverWinCam < TDriverCam
|
59
|
+
|
60
|
+
@_device = nil
|
61
|
+
@_video_file = nil
|
62
|
+
@_recording = false
|
63
|
+
@_rec_options = nil
|
64
|
+
@_owcc_startex = nil
|
65
|
+
@_owcc_stop = nil
|
66
|
+
STARTUP_TIMEOUT = 60
|
67
|
+
DEFAULT_OPTIONS = { :device => nil, :width => 640, :height => 480, :fps => 30 }
|
68
|
+
|
69
|
+
# Creates a new recroding object witdh the given recording options
|
70
|
+
# === params
|
71
|
+
# video_file: String, path and name of file where the recorded video is stored
|
72
|
+
# user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
|
73
|
+
def initialize( video_file, user_options = {} )
|
74
|
+
|
75
|
+
begin
|
76
|
+
require 'Win32API'
|
77
|
+
#OSCARWEBCAMCONTROL_API long OscarWebCamControlStartEx(char* captureFile, double compQuality, DWORD dwBitsPerSec, long lFramesPerSec, long lCapWidth, long lCapHeight, bool bFlipV, bool bFlipH)
|
78
|
+
@_owcc_startex = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I' ], 'L' )
|
79
|
+
#OSCARWEBCAMCONTROL_API void OscarWebCamControlStop(long pTargetMediaControl)
|
80
|
+
@_owcc_stop = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
|
81
|
+
rescue Exception => e
|
82
|
+
raise RuntimeError.new( "Failed to connect to video recording DLL file (OscarWebCamControl.dll). Details:\n" + e.message )
|
83
|
+
end
|
84
|
+
|
85
|
+
if user_options.has_key? :device
|
86
|
+
puts "WARNING: TDriverWinCam does not support the :device option. This setting is ignored."
|
87
|
+
end
|
88
|
+
|
89
|
+
@_control_id = nil
|
90
|
+
@_video_file = video_file
|
91
|
+
@_rec_options = DEFAULT_OPTIONS.merge user_options
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
# Starts recording based on options given during initialization
|
96
|
+
# === raises
|
97
|
+
# RuntimeError: No filename has been defined or recording initialization failed due to timeout.
|
98
|
+
def start_recording
|
99
|
+
|
100
|
+
raise RuntimeError.new("No video file defined, unable to start recording.") unless !@_video_file.nil?
|
101
|
+
|
102
|
+
if File.exists?( @_video_file )
|
103
|
+
begin
|
104
|
+
File.delete( @_video_file )
|
105
|
+
rescue
|
106
|
+
# no reaction to failed file ops, unless recording fails
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
@_control_id = @_owcc_startex.call( @_video_file, 0, 0, 0, @_rec_options[ :fps ].to_i, @_rec_options[ :width ].to_i, @_rec_options[ :height ].to_i, 0, 0 )
|
111
|
+
|
112
|
+
if @_control_id == 0
|
113
|
+
Kernel::raise RuntimeError.new( "Failed to start video recording.\nFile: " + @_video_file + "\nFPS: " + @_rec_options[ :fps ].to_s + "\nWidth: " + @_rec_options[ :width ].to_s + "\nHeight: " + @_rec_options[ :height ].to_s )
|
114
|
+
end
|
115
|
+
|
116
|
+
file_timed_out = false
|
117
|
+
file_timeout = Time.now + STARTUP_TIMEOUT
|
118
|
+
|
119
|
+
while File.size?( @_video_file ).nil? && !file_timed_out do
|
120
|
+
#wait for recording to start, ie. filesize > 0
|
121
|
+
sleep 1
|
122
|
+
# force refresh file size
|
123
|
+
begin
|
124
|
+
if File.exists?( @_video_file )
|
125
|
+
File.open( @_video_file, 'r' ) do
|
126
|
+
end
|
127
|
+
end
|
128
|
+
rescue
|
129
|
+
end
|
130
|
+
|
131
|
+
if Time.now > file_timeout
|
132
|
+
file_timed_out = true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
if file_timed_out
|
137
|
+
# make sure recording is not initializing, clean up any failed file
|
138
|
+
begin
|
139
|
+
@_owcc_stop.call( @_control_id )
|
140
|
+
rescue
|
141
|
+
end
|
142
|
+
|
143
|
+
if File.exists?( @_video_file )
|
144
|
+
begin
|
145
|
+
File.delete( @_video_file )
|
146
|
+
rescue
|
147
|
+
end
|
148
|
+
end
|
149
|
+
raise RuntimeError.new( "Failed to start recording. Timeout: #{STARTUP_TIMEOUT} File: \"#{@_video_file}\" " )
|
150
|
+
end
|
151
|
+
|
152
|
+
@_recording = true
|
153
|
+
|
154
|
+
return nil
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
# Stops ongoing recording
|
159
|
+
def stop_recording
|
160
|
+
if @_recording
|
161
|
+
@_recording = false
|
162
|
+
@_owcc_stop.call( @_control_id )
|
163
|
+
end
|
164
|
+
return nil
|
165
|
+
end
|
166
|
+
|
167
|
+
end #TDriverWinCam
|
168
|
+
|
169
|
+
|
170
|
+
# Linux streamer webcam implementation
|
171
|
+
# Requires that the streamer application is installed
|
172
|
+
class TDriverLinuxCam < TDriverCam
|
173
|
+
|
174
|
+
@_device = nil
|
175
|
+
@_video_file = nil
|
176
|
+
@_recording = false
|
177
|
+
@_rec_options = nil
|
178
|
+
@_owcc_startex = nil
|
179
|
+
@_owcc_stop = nil
|
180
|
+
STARTUP_TIMEOUT = 60
|
181
|
+
DEFAULT_OPTIONS = { :device => '/dev/video0', :width => 320, :height => 240, :fps => 5 }
|
182
|
+
|
183
|
+
# Creates a new recroding object witdh the given recording options
|
184
|
+
# === params
|
185
|
+
# video_file: String, path and name of file where the recorded video is stored
|
186
|
+
# user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
|
187
|
+
def initialize( video_file, user_options = {} )
|
188
|
+
|
189
|
+
@_control_id = nil
|
190
|
+
@_video_file = video_file
|
191
|
+
@_rec_options = DEFAULT_OPTIONS.merge user_options
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
# Starts recording based on options given during initialization
|
196
|
+
# === raises
|
197
|
+
# RuntimeError: No filename has been defined or recording initialization failed due to timeout.
|
198
|
+
def start_recording
|
199
|
+
|
200
|
+
raise RuntimeError.new( "No video file defined, unable to start recording." ) unless !@_video_file.nil?
|
201
|
+
|
202
|
+
if File.exists?( @_video_file )
|
203
|
+
begin
|
204
|
+
File.delete( @_video_file )
|
205
|
+
rescue
|
206
|
+
# no reaction to failed file ops, unless recording fails
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
rec_command = 'streamer -q -c ' + @_rec_options[ :device ].to_s + ' -f rgb24 -r ' + @_rec_options[ :fps ].to_s + ' -t 99:00:00 -o ' + @_video_file.to_s + ' -s ' + @_rec_options[ :width ].to_s + 'x' + @_rec_options[ :height ].to_s
|
211
|
+
|
212
|
+
@_streamer_pid = fork do
|
213
|
+
begin
|
214
|
+
Kernel::exec( rec_command )
|
215
|
+
rescue Exception => e
|
216
|
+
raise RuntimeError.new( "An error was encountered while launching streamer:\n" << e.inspect )
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
file_timed_out = false
|
221
|
+
file_timeout = Time.now + STARTUP_TIMEOUT
|
222
|
+
|
223
|
+
while File.size?( @_video_file ).nil? && !file_timed_out do
|
224
|
+
#wait for recording to start, ie. filesize > 0
|
225
|
+
sleep 0.1
|
226
|
+
|
227
|
+
if Time.now > file_timeout
|
228
|
+
file_timed_out = true
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
if file_timed_out
|
233
|
+
# make sure recording is not initializing, clean up any failed file
|
234
|
+
begin
|
235
|
+
Process.kill( 9, @_streamer_pid.to_i )
|
236
|
+
rescue
|
237
|
+
end
|
238
|
+
|
239
|
+
if File.exists?( @_video_file )
|
240
|
+
begin
|
241
|
+
File.delete( @_video_file )
|
242
|
+
rescue
|
243
|
+
end
|
244
|
+
end
|
245
|
+
raise RuntimeError.new( "Failed to start recording. Timeout: #{STARTUP_TIMEOUT} second(s). File: \"#{@_video_file}\" " )
|
246
|
+
end
|
247
|
+
|
248
|
+
@_recording = true
|
249
|
+
|
250
|
+
return nil
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
# Stops ongoing recording
|
255
|
+
def stop_recording
|
256
|
+
if @_recording
|
257
|
+
@_recording = false
|
258
|
+
Process.kill( 9, @_streamer_pid.to_i )
|
259
|
+
end
|
260
|
+
return nil
|
261
|
+
end
|
262
|
+
|
263
|
+
end #TDriverLinuxCam
|
264
|
+
end
|