cutedriver-driver 2.0.0.20210120164037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/README.md +16 -0
 - data/bin/start_app_perf +200 -0
 - data/bin/tdriver-devtools +3 -0
 - data/config/sut_parameters.rb +52 -0
 - data/config/sut_setup.rb +32 -0
 - data/config/sut_teardown.rb +32 -0
 - data/config/tdriver_custom_error_recovery.rb +83 -0
 - data/ext/extconf.rb +70 -0
 - data/ext/native_extensions.c +315 -0
 - data/lib/matti.rb +25 -0
 - data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -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 +1945 -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/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 +917 -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 +2170 -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/behaviour_example.rb +100 -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 +23 -0
 - data/lib/tdriver/base/behaviour/abstract.rb +29 -0
 - data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
 - data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
 - data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
 - data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
 - data/lib/tdriver/base/behaviour/factory.rb +495 -0
 - data/lib/tdriver/base/behaviour/loader.rb +46 -0
 - data/lib/tdriver/base/command_data/command_data.rb +51 -0
 - data/lib/tdriver/base/command_data/loader.rb +29 -0
 - data/lib/tdriver/base/controller/abstraction.rb +56 -0
 - data/lib/tdriver/base/controller/loader.rb +21 -0
 - data/lib/tdriver/base/errors.rb +134 -0
 - data/lib/tdriver/base/loader.rb +47 -0
 - data/lib/tdriver/base/state_object.rb +373 -0
 - data/lib/tdriver/base/sut/adapter.rb +54 -0
 - data/lib/tdriver/base/sut/controller.rb +151 -0
 - data/lib/tdriver/base/sut/factory.rb +339 -0
 - data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
 - data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
 - data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
 - data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
 - data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
 - data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
 - data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
 - data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
 - data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
 - data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
 - data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
 - data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
 - data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
 - data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
 - data/lib/tdriver/base/sut/loader.rb +35 -0
 - data/lib/tdriver/base/sut/sut.rb +98 -0
 - data/lib/tdriver/base/test_object/abstract.rb +208 -0
 - data/lib/tdriver/base/test_object/adapter.rb +740 -0
 - data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
 - data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
 - data/lib/tdriver/base/test_object/cache.rb +134 -0
 - data/lib/tdriver/base/test_object/factory.rb +684 -0
 - data/lib/tdriver/base/test_object/loader.rb +51 -0
 - data/lib/tdriver/base/test_object/verification.rb +178 -0
 - data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
 - data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
 - data/lib/tdriver/env.rb +21 -0
 - data/lib/tdriver/loader.rb +57 -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 +168 -0
 - data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
 - data/lib/tdriver/report/report.rb +61 -0
 - data/lib/tdriver/report/report_api.rb +348 -0
 - data/lib/tdriver/report/report_combine.rb +86 -0
 - data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
 - data/lib/tdriver/report/report_creator.rb +665 -0
 - data/lib/tdriver/report/report_cucumber.rb +158 -0
 - data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
 - data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
 - data/lib/tdriver/report/report_data_presentation.rb +156 -0
 - data/lib/tdriver/report/report_data_table.rb +64 -0
 - data/lib/tdriver/report/report_execution_statistics.rb +400 -0
 - data/lib/tdriver/report/report_file_capture.rb +159 -0
 - data/lib/tdriver/report/report_graph_generator.rb +59 -0
 - data/lib/tdriver/report/report_grouping.rb +541 -0
 - data/lib/tdriver/report/report_javascript.rb +199 -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 +725 -0
 - data/lib/tdriver/report/report_test_run.rb +1476 -0
 - data/lib/tdriver/report/report_test_unit.rb +223 -0
 - data/lib/tdriver/report/report_writer.rb +1621 -0
 - data/lib/tdriver/tdriver.rb +209 -0
 - data/lib/tdriver/util/agent/loader.rb +22 -0
 - data/lib/tdriver/util/agent/service.rb +107 -0
 - data/lib/tdriver/util/common/array.rb +39 -0
 - data/lib/tdriver/util/common/boolean.rb +48 -0
 - data/lib/tdriver/util/common/crc16.rb +149 -0
 - data/lib/tdriver/util/common/environment.rb +154 -0
 - data/lib/tdriver/util/common/error.rb +40 -0
 - data/lib/tdriver/util/common/exception.rb +53 -0
 - data/lib/tdriver/util/common/exceptions.rb +12 -0
 - data/lib/tdriver/util/common/file.rb +328 -0
 - data/lib/tdriver/util/common/gem.rb +109 -0
 - data/lib/tdriver/util/common/hash.rb +288 -0
 - data/lib/tdriver/util/common/kernel.rb +253 -0
 - data/lib/tdriver/util/common/loader.rb +47 -0
 - data/lib/tdriver/util/common/numeric.rb +159 -0
 - data/lib/tdriver/util/common/object.rb +159 -0
 - data/lib/tdriver/util/common/retryable.rb +179 -0
 - data/lib/tdriver/util/common/stackable.rb +185 -0
 - data/lib/tdriver/util/common/string.rb +174 -0
 - data/lib/tdriver/util/database/access.rb +240 -0
 - data/lib/tdriver/util/database/connection.rb +44 -0
 - data/lib/tdriver/util/database/error.rb +34 -0
 - data/lib/tdriver/util/database/loader.rb +28 -0
 - 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 +211 -0
 - data/lib/tdriver/util/hooking/hooking.rb +477 -0
 - data/lib/tdriver/util/keymap/keymap.rb +81 -0
 - data/lib/tdriver/util/loader.rb +80 -0
 - data/lib/tdriver/util/localisation/error.rb +31 -0
 - data/lib/tdriver/util/localisation/loader.rb +25 -0
 - data/lib/tdriver/util/localisation/localisation.rb +762 -0
 - data/lib/tdriver/util/logger/loader.rb +22 -0
 - data/lib/tdriver/util/logger/logger.rb +591 -0
 - data/lib/tdriver/util/operator_data/error.rb +29 -0
 - data/lib/tdriver/util/operator_data/loader.rb +27 -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/error.rb +48 -0
 - data/lib/tdriver/util/parameter/loader.rb +25 -0
 - data/lib/tdriver/util/parameter/parameter.rb +1161 -0
 - data/lib/tdriver/util/plugin/abstract.rb +61 -0
 - data/lib/tdriver/util/plugin/error.rb +0 -0
 - data/lib/tdriver/util/plugin/loader.rb +28 -0
 - data/lib/tdriver/util/plugin/service.rb +319 -0
 - data/lib/tdriver/util/recorder/loader.rb +25 -0
 - data/lib/tdriver/util/recorder/recorder.rb +72 -0
 - data/lib/tdriver/util/recorder/scripter.rb +294 -0
 - data/lib/tdriver/util/statistics/statistics.rb +89 -0
 - data/lib/tdriver/util/user_data/error.rb +28 -0
 - data/lib/tdriver/util/user_data/loader.rb +25 -0
 - data/lib/tdriver/util/user_data/user_data.rb +104 -0
 - data/lib/tdriver/util/video/camera.rb +67 -0
 - data/lib/tdriver/util/video/camera_linux.rb +153 -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 +117 -0
 - data/lib/tdriver/util/xml/attribute.rb +32 -0
 - data/lib/tdriver/util/xml/builder.rb +53 -0
 - data/lib/tdriver/util/xml/comment.rb +32 -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 +62 -0
 - data/lib/tdriver/util/xml/nil_node.rb +95 -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 +21 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
 - data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
 - data/lib/tdriver/util/xml/text.rb +32 -0
 - data/lib/tdriver/util/xml/xml.rb +332 -0
 - data/lib/tdriver/verify/verify.rb +2398 -0
 - data/lib/tdriver/version.rb +21 -0
 - data/xml/behaviours/generic.xml +530 -0
 - data/xml/defaults/generic.xml +11 -0
 - data/xml/defaults/sut_generic.xml +8 -0
 - data/xml/parameters/tdriver_parameters.xml +23 -0
 - data/xml/templates/generic.xml +292 -0
 - metadata +324 -0
 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
              # Base class and interface for camera recorders in TDriver
         
     | 
| 
      
 23 
     | 
    
         
            +
              class TDriverCam
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                # Automatically select the right kind of camera implementation for the detected platform.
         
     | 
| 
      
 26 
     | 
    
         
            +
                def self.new_cam( *args )
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  if EnvironmentHelper.windows?
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    MobyUtil::TDriverWinCam.new( *args )
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  elsif EnvironmentHelper.linux?
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    MobyUtil::TDriverLinuxCam.new( *args )
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    raise RuntimeError.new("Unidentified platform type, unable to select platform specific camera. Supported platform types: Linux, Windows.")
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  raise RuntimeError.new("TDriverCam abstract class")
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                def start_recording
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  raise RuntimeError.new("TDriverCam abstract class")
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def stop_recording
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  raise RuntimeError.new("TDriverCam abstract class")
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 63 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              end # TDriverCam
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            end # MobyUtil
         
     | 
| 
         @@ -0,0 +1,153 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            require 'open3'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            module MobyUtil
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              # Linux streamer webcam implementation
         
     | 
| 
      
 25 
     | 
    
         
            +
              # Requires that the streamer application is installed
         
     | 
| 
      
 26 
     | 
    
         
            +
              class TDriverLinuxCam
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                STARTUP_TIMEOUT = 60
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                DEFAULT_OPTIONS = { :device => '/dev/video0', :width => 320, :height => 240, :fps => 5, :max_time => '99:00:00' }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 33 
     | 
    
         
            +
                def self.new_cam( *args )
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  MobyUtil::TDriverLinuxCam.new( *args )
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                # Creates a new recroding object witdh the given recording options    
         
     | 
| 
      
 40 
     | 
    
         
            +
                # === params
         
     | 
| 
      
 41 
     | 
    
         
            +
                # video_file: String, path and name of file where the recorded video is stored
         
     | 
| 
      
 42 
     | 
    
         
            +
                # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
         
     | 
| 
      
 43 
     | 
    
         
            +
                def initialize( video_file, user_options = {} )      
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  @_device = nil
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @_video_file = nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @_recording = false
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @_rec_options = nil
         
     | 
| 
      
 49 
     | 
    
         
            +
                  @_owcc_startex = nil
         
     | 
| 
      
 50 
     | 
    
         
            +
                  @_owcc_stop = nil
         
     | 
| 
      
 51 
     | 
    
         
            +
                  
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @_control_id = nil
         
     | 
| 
      
 53 
     | 
    
         
            +
                  @_video_file = video_file
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @_rec_options = DEFAULT_OPTIONS.merge user_options
         
     | 
| 
      
 55 
     | 
    
         
            +
                      
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @rec_app = 'streamer'
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
                
         
     | 
| 
      
 59 
     | 
    
         
            +
                # Starts recording based on options given during initialization
         
     | 
| 
      
 60 
     | 
    
         
            +
                # === raises
         
     | 
| 
      
 61 
     | 
    
         
            +
                # RuntimeError: No filename has been defined or recording initialization failed due to timeout.
         
     | 
| 
      
 62 
     | 
    
         
            +
                def start_recording
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  raise RuntimeError.new( "No video file defined, unable to start recording." ) if @_video_file.nil?
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  if File.exists?( @_video_file )        
         
     | 
| 
      
 67 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 68 
     | 
    
         
            +
                      File.delete( @_video_file )
         
     | 
| 
      
 69 
     | 
    
         
            +
                        rescue
         
     | 
| 
      
 70 
     | 
    
         
            +
                      # no reaction to failed file ops, unless recording fails
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end  
         
     | 
| 
      
 73 
     | 
    
         
            +
                  
         
     | 
| 
      
 74 
     | 
    
         
            +
                  rec_opts = ' -q -c ' + @_rec_options[ :device ].to_s + ' -f rgb24 -r ' + @_rec_options[ :fps ].to_s + ' -t ' + 
         
     | 
| 
      
 75 
     | 
    
         
            +
                    @_rec_options[:max_time] + ' -o ' +  @_video_file.to_s + ' -s ' + @_rec_options[ :width ].to_s + 'x' + @_rec_options[ :height ].to_s 
         
     | 
| 
      
 76 
     | 
    
         
            +
                  begin         
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @stdin, @stdout, @stderr = Open3.popen3(@rec_app + rec_opts)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
      
 79 
     | 
    
         
            +
                    raise RuntimeError.new( "An error was encountered while launching streamer:\n" << e.inspect )
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  file_timed_out = false
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  file_timeout = Time.now + STARTUP_TIMEOUT
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  while File.size?( @_video_file ).nil? && !file_timed_out do
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                    #wait for recording to start, ie. filesize > 0
         
     | 
| 
      
 89 
     | 
    
         
            +
                    sleep 0.1
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    file_timed_out = true if Time.now > file_timeout
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
                  
         
     | 
| 
      
 95 
     | 
    
         
            +
                  if file_timed_out
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                    # make sure recording is not initializing, clean up any failed file        
         
     | 
| 
      
 98 
     | 
    
         
            +
                    stop_recording
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                    if File.exists?( @_video_file )
         
     | 
| 
      
 101 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 102 
     | 
    
         
            +
                        File.delete( @_video_file )
         
     | 
| 
      
 103 
     | 
    
         
            +
                      rescue
         
     | 
| 
      
 104 
     | 
    
         
            +
                      end
         
     | 
| 
      
 105 
     | 
    
         
            +
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                    raise RuntimeError.new( "Failed to start recording. Timeout: #{STARTUP_TIMEOUT} second(s). File: \"#{@_video_file}\" " )
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
                
         
     | 
| 
      
 111 
     | 
    
         
            +
                  @_recording = true
         
     | 
| 
      
 112 
     | 
    
         
            +
                  
         
     | 
| 
      
 113 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                    
         
     | 
| 
      
 118 
     | 
    
         
            +
                # Stops ongoing recording    
         
     | 
| 
      
 119 
     | 
    
         
            +
                def stop_recording 
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                  if @_recording      
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                    @_recording = false            
         
     | 
| 
      
 124 
     | 
    
         
            +
                    
         
     | 
| 
      
 125 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 126 
     | 
    
         
            +
                      @stdin.close unless @stdin.closed?
         
     | 
| 
      
 127 
     | 
    
         
            +
                      @stdout.close unless @stdout.closed?
         
     | 
| 
      
 128 
     | 
    
         
            +
                      @stderr.close unless @stderr.closed?
         
     | 
| 
      
 129 
     | 
    
         
            +
                      
         
     | 
| 
      
 130 
     | 
    
         
            +
                      sleep 10 # allow some time to close (yes, it can take up to 10 seconds)
         
     | 
| 
      
 131 
     | 
    
         
            +
                      pid = `pidof #{@rec_app}`.to_i
         
     | 
| 
      
 132 
     | 
    
         
            +
                      begin 
         
     | 
| 
      
 133 
     | 
    
         
            +
                        if pid != 0
         
     | 
| 
      
 134 
     | 
    
         
            +
                          Process.kill(9,pid)
         
     | 
| 
      
 135 
     | 
    
         
            +
                        end
         
     | 
| 
      
 136 
     | 
    
         
            +
                      rescue => e
         
     | 
| 
      
 137 
     | 
    
         
            +
                        puts "Got error " + e.inspect
         
     | 
| 
      
 138 
     | 
    
         
            +
                      end
         
     | 
| 
      
 139 
     | 
    
         
            +
                    rescue => e
         
     | 
| 
      
 140 
     | 
    
         
            +
                      raise RuntimeError.new( "Failed to end recording. Errror:\n " << e.inspect)
         
     | 
| 
      
 141 
     | 
    
         
            +
                    end
         
     | 
| 
      
 142 
     | 
    
         
            +
                  end
         
     | 
| 
      
 143 
     | 
    
         
            +
                  
         
     | 
| 
      
 144 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 145 
     | 
    
         
            +
                  
         
     | 
| 
      
 146 
     | 
    
         
            +
                end
         
     | 
| 
      
 147 
     | 
    
         
            +
                
         
     | 
| 
      
 148 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 149 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
              end #TDriverLinuxCam
         
     | 
| 
      
 152 
     | 
    
         
            +
                
         
     | 
| 
      
 153 
     | 
    
         
            +
            end # MobyUtil
         
     | 
| 
         @@ -0,0 +1,174 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
              # Windows DirectShow webcam implementation
         
     | 
| 
      
 23 
     | 
    
         
            +
              class TDriverWinCam
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                STARTUP_TIMEOUT = 60
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                DEFAULT_OPTIONS = { :device => nil, :width => 640, :height => 480, :fps => 30 }
         
     | 
| 
      
 28 
     | 
    
         
            +
                
         
     | 
| 
      
 29 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 30 
     | 
    
         
            +
                def self.new_cam( *args )
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  MobyUtil::TDriverWinCam.new( *args )
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                # Creates a new recroding object witdh the given recording options    
         
     | 
| 
      
 37 
     | 
    
         
            +
                # === params
         
     | 
| 
      
 38 
     | 
    
         
            +
                # video_file: String, path and name of file where the recorded video is stored
         
     | 
| 
      
 39 
     | 
    
         
            +
                # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
         
     | 
| 
      
 40 
     | 
    
         
            +
                def initialize( video_file, user_options = {} )
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  @_device = nil
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @_video_file = nil
         
     | 
| 
      
 44 
     | 
    
         
            +
                  @_recording = false
         
     | 
| 
      
 45 
     | 
    
         
            +
                  @_rec_options = nil
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @_owcc_startex = nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @_owcc_stop = nil
         
     | 
| 
      
 48 
     | 
    
         
            +
                    
         
     | 
| 
      
 49 
     | 
    
         
            +
                  require 'Win32API'      
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  begin     
         
     | 
| 
      
 52 
     | 
    
         
            +
                  
         
     | 
| 
      
 53 
     | 
    
         
            +
                    @_owcc_startex = Win32API.new( 'TDriverWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I'  ], 'L' )
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @_owcc_stop = Win32API.new( 'TDriverWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
         
     | 
| 
      
 55 
     | 
    
         
            +
               
         
     | 
| 
      
 56 
     | 
    
         
            +
                  rescue Exception => e
         
     | 
| 
      
 57 
     | 
    
         
            +
                  
         
     | 
| 
      
 58 
     | 
    
         
            +
                    begin 
         
     | 
| 
      
 59 
     | 
    
         
            +
                        
         
     | 
| 
      
 60 
     | 
    
         
            +
                      #OSCARWEBCAMCONTROL_API long OscarWebCamControlStartEx(char* captureFile, double compQuality, DWORD dwBitsPerSec, long lFramesPerSec, long lCapWidth, long lCapHeight, bool bFlipV, bool bFlipH)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      @_owcc_startex = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I'  ], 'L' )
         
     | 
| 
      
 62 
     | 
    
         
            +
                      #OSCARWEBCAMCONTROL_API void OscarWebCamControlStop(long pTargetMediaControl)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      @_owcc_stop = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
         
     | 
| 
      
 64 
     | 
    
         
            +
                      
         
     | 
| 
      
 65 
     | 
    
         
            +
                    rescue Exception => ee
         
     | 
| 
      
 66 
     | 
    
         
            +
                      raise RuntimeError.new( "Failed to connect to video recording DLL file (TDriverWebCamControl.dll or OscarWebCamControl.dll). Details:\n" + ee.message )
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
                    
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                  if user_options.has_key? :device
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    puts "WARNING: TDriverWinCam does not support the :device option. This setting is ignored."
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
              
         
     | 
| 
      
 77 
     | 
    
         
            +
                  @_control_id = nil
         
     | 
| 
      
 78 
     | 
    
         
            +
                  @_video_file = video_file
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @_rec_options = DEFAULT_OPTIONS.merge user_options
         
     | 
| 
      
 80 
     | 
    
         
            +
                      
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
                
         
     | 
| 
      
 83 
     | 
    
         
            +
                # Starts recording based on options given during initialization
         
     | 
| 
      
 84 
     | 
    
         
            +
                # === raises
         
     | 
| 
      
 85 
     | 
    
         
            +
                # RuntimeError: No filename has been defined or recording initialization failed due to timeout.
         
     | 
| 
      
 86 
     | 
    
         
            +
                def start_recording
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                  raise RuntimeError.new("No video file defined, unable to start recording.") if @_video_file.nil?
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  if File.exists?( @_video_file )        
         
     | 
| 
      
 91 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 92 
     | 
    
         
            +
                      File.delete( @_video_file )
         
     | 
| 
      
 93 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 94 
     | 
    
         
            +
                      # no reaction to failed file ops, unless recording fails
         
     | 
| 
      
 95 
     | 
    
         
            +
                    end
         
     | 
| 
      
 96 
     | 
    
         
            +
                  end
         
     | 
| 
      
 97 
     | 
    
         
            +
                
         
     | 
| 
      
 98 
     | 
    
         
            +
                  @_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 )
         
     | 
| 
      
 99 
     | 
    
         
            +
                  
         
     | 
| 
      
 100 
     | 
    
         
            +
                  if @_control_id == 0
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                    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 )
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  file_timed_out = false
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  file_timeout = Time.now + STARTUP_TIMEOUT
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  while File.size?( @_video_file ).nil? && !file_timed_out do
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    #wait for recording to start, ie. filesize > 0
         
     | 
| 
      
 113 
     | 
    
         
            +
                    sleep 1
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                    # force refresh file size
         
     | 
| 
      
 116 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                      if File.exists?( @_video_file ) 
         
     | 
| 
      
 119 
     | 
    
         
            +
                        File.open( @_video_file, 'r' ) do 
         
     | 
| 
      
 120 
     | 
    
         
            +
                        end      
         
     | 
| 
      
 121 
     | 
    
         
            +
                      end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                    end      
         
     | 
| 
      
 126 
     | 
    
         
            +
                    
         
     | 
| 
      
 127 
     | 
    
         
            +
                    if Time.now > file_timeout
         
     | 
| 
      
 128 
     | 
    
         
            +
                      file_timed_out = true
         
     | 
| 
      
 129 
     | 
    
         
            +
                    end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  end
         
     | 
| 
      
 132 
     | 
    
         
            +
                  
         
     | 
| 
      
 133 
     | 
    
         
            +
                  if file_timed_out
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                    # make sure recording is not initializing, clean up any failed file        
         
     | 
| 
      
 136 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 137 
     | 
    
         
            +
                      @_owcc_stop.call( @_control_id )
         
     | 
| 
      
 138 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 139 
     | 
    
         
            +
                    end
         
     | 
| 
      
 140 
     | 
    
         
            +
                    
         
     | 
| 
      
 141 
     | 
    
         
            +
                    if File.exists?( @_video_file )
         
     | 
| 
      
 142 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 143 
     | 
    
         
            +
                        File.delete( @_video_file )
         
     | 
| 
      
 144 
     | 
    
         
            +
                      rescue
         
     | 
| 
      
 145 
     | 
    
         
            +
                      end
         
     | 
| 
      
 146 
     | 
    
         
            +
                    end      
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                    raise RuntimeError.new( "Failed to start recording. Timeout: #{STARTUP_TIMEOUT} File: \"#{@_video_file}\" " )
         
     | 
| 
      
 149 
     | 
    
         
            +
                  end
         
     | 
| 
      
 150 
     | 
    
         
            +
                  
         
     | 
| 
      
 151 
     | 
    
         
            +
                  @_recording = true
         
     | 
| 
      
 152 
     | 
    
         
            +
                  
         
     | 
| 
      
 153 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 154 
     | 
    
         
            +
                  
         
     | 
| 
      
 155 
     | 
    
         
            +
                end
         
     | 
| 
      
 156 
     | 
    
         
            +
                    
         
     | 
| 
      
 157 
     | 
    
         
            +
                # Stops ongoing recording    
         
     | 
| 
      
 158 
     | 
    
         
            +
                def stop_recording 
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                  if @_recording      
         
     | 
| 
      
 161 
     | 
    
         
            +
                    @_recording = false            
         
     | 
| 
      
 162 
     | 
    
         
            +
                    @_owcc_stop.call( @_control_id )
         
     | 
| 
      
 163 
     | 
    
         
            +
                  end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 170 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 171 
     | 
    
         
            +
                
         
     | 
| 
      
 172 
     | 
    
         
            +
              end #TDriverWinCam
         
     | 
| 
      
 173 
     | 
    
         
            +
                
         
     | 
| 
      
 174 
     | 
    
         
            +
            end # MobyUtil
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            # video utils module
         
     | 
| 
      
 21 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'video_utils.rb' ) )
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            # camera implementation
         
     | 
| 
      
 24 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'camera.rb' ) )
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            # camera windows implementation
         
     | 
| 
      
 27 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'camera_windows.rb' ) )
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            # camera linux implementation
         
     | 
| 
      
 30 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'camera_linux.rb' ) )
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,139 @@ 
     | 
|
| 
      
 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 VideoUtil ???
         
     | 
| 
      
 23 
     | 
    
         
            +
               
         
     | 
| 
      
 24 
     | 
    
         
            +
                # Checks if the target video contains enough activity to be considered active or static.
         
     | 
| 
      
 25 
     | 
    
         
            +
                #
         
     | 
| 
      
 26 
     | 
    
         
            +
                # === params
         
     | 
| 
      
 27 
     | 
    
         
            +
                # in_target_video: String, Name and path of video file to analyze
         
     | 
| 
      
 28 
     | 
    
         
            +
                # in_fps: (optional) Numeric, frames to be analyzed per second
         
     | 
| 
      
 29 
     | 
    
         
            +
                # in_image_treshold: (optional) Numeric, minimum change between two frames for them to be considered different
         
     | 
| 
      
 30 
     | 
    
         
            +
                # in_video_treshold: (optional) Numeric, Minimum percentage of frames with changes for the video to be considered alive.
         
     | 
| 
      
 31 
     | 
    
         
            +
                # in_verbose: (optional) Boolean, True for verbose output including target video statistics
         
     | 
| 
      
 32 
     | 
    
         
            +
                def self.video_alive?( in_target_video, in_fps = 1, in_image_treshold = 4, in_video_treshold = 35, in_verbose = false )
         
     | 
| 
      
 33 
     | 
    
         
            +
                
         
     | 
| 
      
 34 
     | 
    
         
            +
                  puts "Arguments fps: " << in_fps.inspect << " frame: " << in_image_treshold.inspect << " video: "  << in_video_treshold.inspect if in_verbose
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  in_change = in_image_treshold / 100.0
         
     | 
| 
      
 37 
     | 
    
         
            +
                  
         
     | 
| 
      
 38 
     | 
    
         
            +
                  alive_temp_folder = "temp_target_alive"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  
         
     | 
| 
      
 40 
     | 
    
         
            +
                  require 'RMagick'
         
     | 
| 
      
 41 
     | 
    
         
            +
                  
         
     | 
| 
      
 42 
     | 
    
         
            +
                  raise ArgumentError.new( "The FPS argument must be an Interger or a Float, it was a #{ in_fps.class }." ) unless in_fps.kind_of? Numeric
         
     | 
| 
      
 43 
     | 
    
         
            +
                  raise ArgumentError.new( "The frame treshold argument must be an Interger or a Float, it was a #{ in_image_treshold.class }." ) unless in_image_treshold.kind_of? Numeric
         
     | 
| 
      
 44 
     | 
    
         
            +
                  raise ArgumentError.new( "The video treshold argument must be an Interger or a Float, it was a #{ in_video_treshold.class }." ) unless in_video_treshold.kind_of? Numeric
         
     | 
| 
      
 45 
     | 
    
         
            +
                   
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ts = Time.now if in_verbose
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 49 
     | 
    
         
            +
                    FileUtils.remove_dir alive_temp_folder
         
     | 
| 
      
 50 
     | 
    
         
            +
                  rescue 
         
     | 
| 
      
 51 
     | 
    
         
            +
                    # failed to remove dir, do nothing
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  
         
     | 
| 
      
 54 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 55 
     | 
    
         
            +
                    FileUtils.mkdir_p alive_temp_folder  
         
     | 
| 
      
 56 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 57 
     | 
    
         
            +
                  
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  
         
     | 
| 
      
 60 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 61 
     | 
    
         
            +
                    File.delete 'video_split.log' if File.exist? 'video_split.log'
         
     | 
| 
      
 62 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
                      
         
     | 
| 
      
 65 
     | 
    
         
            +
                  if in_verbose
         
     | 
| 
      
 66 
     | 
    
         
            +
                    system('ffmpeg -v 0 -i '+in_target_video.to_s+' -y -f image2 -r '+in_fps.to_s+' '+alive_temp_folder+'/frame-%05d.png')
         
     | 
| 
      
 67 
     | 
    
         
            +
                  else
         
     | 
| 
      
 68 
     | 
    
         
            +
                    system('ffmpeg 2>video_split.log -v 0 -i '+in_target_video.to_s+' -y -f image2 -r '+in_fps.to_s+' '+alive_temp_folder+'/frame-%05d.png')
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                  puts "Video processing duration: " << (Time.now - ts).to_s if in_verbose
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  t_start = Time.now
         
     | 
| 
      
 74 
     | 
    
         
            +
                  
         
     | 
| 
      
 75 
     | 
    
         
            +
                  im_files = Dir.glob( alive_temp_folder + '/frame-*.png' )
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  raise RuntimeError.new( "No video frames found for analysis." ) if im_files.size == 0
         
     | 
| 
      
 78 
     | 
    
         
            +
                  
         
     | 
| 
      
 79 
     | 
    
         
            +
                  d_max = 0.0
         
     | 
| 
      
 80 
     | 
    
         
            +
                  d_min = 1.0
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  d_sum = 0.0
         
     | 
| 
      
 83 
     | 
    
         
            +
                  
         
     | 
| 
      
 84 
     | 
    
         
            +
                  dif_count = 0
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  pre_obj = Magick::ImageList.new(im_files[0])
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                  (im_files.size-1).times do | im_index |
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    im_file = Magick::ImageList.new(im_files[ im_index ])
         
     | 
| 
      
 91 
     | 
    
         
            +
                    pre_file = pre_obj
         
     | 
| 
      
 92 
     | 
    
         
            +
                     
         
     | 
| 
      
 93 
     | 
    
         
            +
                    dif = pre_file.compare_channel(im_file, Magick::RootMeanSquaredErrorMetric)[1]
         
     | 
| 
      
 94 
     | 
    
         
            +
                     if in_verbose
         
     | 
| 
      
 95 
     | 
    
         
            +
                      d_min = dif unless dif >= d_min
         
     | 
| 
      
 96 
     | 
    
         
            +
                      d_max = dif unless dif <= d_max
         
     | 
| 
      
 97 
     | 
    
         
            +
                      d_sum += dif
         
     | 
| 
      
 98 
     | 
    
         
            +
                    end
         
     | 
| 
      
 99 
     | 
    
         
            +
                    dif_count += 1 if dif > in_change
         
     | 
| 
      
 100 
     | 
    
         
            +
                    puts "Processing image: " << im_file.to_s << " I: " << (im_index+1).to_s  << " C: " << dif.to_s if in_verbose
         
     | 
| 
      
 101 
     | 
    
         
            +
                    
         
     | 
| 
      
 102 
     | 
    
         
            +
                    pre_obj = im_file
         
     | 
| 
      
 103 
     | 
    
         
            +
                         
         
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  if in_verbose
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                    time_now = Time.now
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                    puts "Max difference: " << d_max.to_s << "\nMin difference: " << d_min.to_s << "\n"
         
     | 
| 
      
 111 
     | 
    
         
            +
                    puts "Mean difference: " << (d_sum/im_files.size).to_s unless im_files.size == 0
         
     | 
| 
      
 112 
     | 
    
         
            +
                    puts "Count of images exceeding difference tolerance: " << dif_count.to_s
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                    puts "Fraction of images exceeding difference tolerance: " << (dif_count.to_f/im_files.size).to_s unless im_files.size == 0
         
     | 
| 
      
 115 
     | 
    
         
            +
                    puts "Analysis duration: " << (time_now - t_start).to_s
         
     | 
| 
      
 116 
     | 
    
         
            +
                    puts "Total duration: " << (time_now - ts).to_s
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 120 
     | 
    
         
            +
                    FileUtils.remove_dir alive_temp_folder
         
     | 
| 
      
 121 
     | 
    
         
            +
                  rescue 
         
     | 
| 
      
 122 
     | 
    
         
            +
                  end
         
     | 
| 
      
 123 
     | 
    
         
            +
                  
         
     | 
| 
      
 124 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 125 
     | 
    
         
            +
                    File.delete 'video_split.log' if File.exist? 'video_split.log'
         
     | 
| 
      
 126 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
                  
         
     | 
| 
      
 129 
     | 
    
         
            +
                  # Check if enough frames had changes
         
     | 
| 
      
 130 
     | 
    
         
            +
                  return (dif_count.to_f/im_files.size)*100 >= in_video_treshold
         
     | 
| 
      
 131 
     | 
    
         
            +
                    
         
     | 
| 
      
 132 
     | 
    
         
            +
                end  
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 135 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              # end # VideoUtil ???
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            end
         
     |