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,294 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ############################################################################
         
     | 
| 
      
 2 
     | 
    
         
            +
            ## 
         
     | 
| 
      
 3 
     | 
    
         
            +
            ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
         
     | 
| 
      
 4 
     | 
    
         
            +
            ## All rights reserved. 
         
     | 
| 
      
 5 
     | 
    
         
            +
            ## Contact: Nokia Corporation (testabilitydriver@nokia.com) 
         
     | 
| 
      
 6 
     | 
    
         
            +
            ## 
         
     | 
| 
      
 7 
     | 
    
         
            +
            ## This file is part of Testability Driver. 
         
     | 
| 
      
 8 
     | 
    
         
            +
            ## 
         
     | 
| 
      
 9 
     | 
    
         
            +
            ## If you have questions regarding the use of this file, please contact 
         
     | 
| 
      
 10 
     | 
    
         
            +
            ## Nokia at testabilitydriver@nokia.com . 
         
     | 
| 
      
 11 
     | 
    
         
            +
            ## 
         
     | 
| 
      
 12 
     | 
    
         
            +
            ## This library is free software; you can redistribute it and/or 
         
     | 
| 
      
 13 
     | 
    
         
            +
            ## modify it under the terms of the GNU Lesser General Public 
         
     | 
| 
      
 14 
     | 
    
         
            +
            ## License version 2.1 as published by the Free Software Foundation 
         
     | 
| 
      
 15 
     | 
    
         
            +
            ## and appearing in the file LICENSE.LGPL included in the packaging 
         
     | 
| 
      
 16 
     | 
    
         
            +
            ## of this file. 
         
     | 
| 
      
 17 
     | 
    
         
            +
            ## 
         
     | 
| 
      
 18 
     | 
    
         
            +
            ############################################################################
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            module MobyUtil
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              class Scripter
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def initialize(sut_id, object_identificators)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  @_object_identificators = object_identificators
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  @_tap_max_time = $parameters[sut_id][:record_tap_time_treshold].to_i
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @_tap_min_distance = $parameters[sut_id][:record_move_treshold].to_i
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def write_fragment(xml_as_object, app_name)
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
                  script =  "# Insert the script fragment below into your test \n"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  script << "# Add verification points if needed. \n \n"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  script << "# For testing the script! Do not include in your own test scripts. \n"
         
     | 
| 
      
 38 
     | 
    
         
            +
                  script << "@app = sut.application(:name =>'" << app_name << "') \n"  
         
     | 
| 
      
 39 
     | 
    
         
            +
                  script << "# To test the script make sure the application is in the same state as it was when recording was started. \n\n"
         
     | 
| 
      
 40 
     | 
    
         
            +
                  script << "#################################### \n"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  script << "# Begin recorded script              \n"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  script << "#################################### \n \n"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  event_list = xml_as_object.events
         
     | 
| 
      
 45 
     | 
    
         
            +
                  event_count = event_list.attribute('eventCount').to_i
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  mouse_down = false
         
     | 
| 
      
 48 
     | 
    
         
            +
                  points = Array.new
         
     | 
| 
      
 49 
     | 
    
         
            +
                  active_target = nil
         
     | 
| 
      
 50 
     | 
    
         
            +
                  scripting = false;
         
     | 
| 
      
 51 
     | 
    
         
            +
                  mouse_status = 0
         
     | 
| 
      
 52 
     | 
    
         
            +
                  previous_time = nil
         
     | 
| 
      
 53 
     | 
    
         
            +
                  event = nil
         
     | 
| 
      
 54 
     | 
    
         
            +
                  
         
     | 
| 
      
 55 
     | 
    
         
            +
                  # mouse_status: 
         
     | 
| 
      
 56 
     | 
    
         
            +
                  # 0 = no press or release
         
     | 
| 
      
 57 
     | 
    
         
            +
                  # 1 = press, no release     [ will only happen if recording stoped before mouse release]
         
     | 
| 
      
 58 
     | 
    
         
            +
                  # 2 = release, no press     [ will only happen if recording started after mouse press]
         
     | 
| 
      
 59 
     | 
    
         
            +
                  # 3 = press and release
         
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
      
 61 
     | 
    
         
            +
                  # COLLECT ALL MOUSE EVENTS
         
     | 
| 
      
 62 
     | 
    
         
            +
                  mouse_moves = []
         
     | 
| 
      
 63 
     | 
    
         
            +
                  mouse_press_events = []
         
     | 
| 
      
 64 
     | 
    
         
            +
                  mouse_release_events = []
         
     | 
| 
      
 65 
     | 
    
         
            +
                  
         
     | 
| 
      
 66 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 67 
     | 
    
         
            +
                    mouse_moves = xml_as_object.children(:type =>'event', :name=>'MouseMove')
         
     | 
| 
      
 68 
     | 
    
         
            +
                  rescue MobyBase::TestObjectNotFoundError
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  
         
     | 
| 
      
 71 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 72 
     | 
    
         
            +
                    mouse_press_events = xml_as_object.children(:type =>'event', :name=>'MouseButtonPress')
         
     | 
| 
      
 73 
     | 
    
         
            +
                  rescue MobyBase::TestObjectNotFoundError
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
                  
         
     | 
| 
      
 76 
     | 
    
         
            +
                  begin 
         
     | 
| 
      
 77 
     | 
    
         
            +
                    mouse_release_events = xml_as_object.children(:type =>'event', :name=>'MouseButtonRelease')
         
     | 
| 
      
 78 
     | 
    
         
            +
                  rescue MobyBase::TestObjectNotFoundError
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
                  
         
     | 
| 
      
 81 
     | 
    
         
            +
                  # STORE MOVE POINTS
         
     | 
| 
      
 82 
     | 
    
         
            +
                  move_points = []
         
     | 
| 
      
 83 
     | 
    
         
            +
                  mouse_moves.each do |point|
         
     | 
| 
      
 84 
     | 
    
         
            +
                    timestamp = point.attribute('timeStamp').to_i
         
     | 
| 
      
 85 
     | 
    
         
            +
                    previous_timestamp = ( move_points[-1].nil? ) ? timestamp : move_points[-1]['timestamp'].to_i
         
     | 
| 
      
 86 
     | 
    
         
            +
                    interval = get_duration(previous_timestamp, timestamp)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    move_points.push({'x' => point.attribute('windowX'), 'y' => point.attribute('windowY'), 'interval' => interval, 'timestamp' => timestamp, 'id' => point.id} )
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  
         
     | 
| 
      
 90 
     | 
    
         
            +
                  # STORE RELEASE EVENTS
         
     | 
| 
      
 91 
     | 
    
         
            +
                  release_events = []
         
     | 
| 
      
 92 
     | 
    
         
            +
                  mouse_release_events.each do |event|
         
     | 
| 
      
 93 
     | 
    
         
            +
                    release_events.push({'id' => event.id})
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  # FOREACH MouseButtonPress
         
     | 
| 
      
 97 
     | 
    
         
            +
                  mouse_press_events.each_index do |index|
         
     | 
| 
      
 98 
     | 
    
         
            +
                    active_target = get_target_details( mouse_press_events[index].child(:id => mouse_press_events[index].id) )  
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                    # COLLECT MouseMove points until MouseButtonRelease
         
     | 
| 
      
 101 
     | 
    
         
            +
                    # If no more MouseButtonRelease or MouseButtonPress then last MoveMouse point id
         
     | 
| 
      
 102 
     | 
    
         
            +
                    first_point_index = mouse_press_events[index].id.to_i
         
     | 
| 
      
 103 
     | 
    
         
            +
                    if ( !move_points.empty? )
         
     | 
| 
      
 104 
     | 
    
         
            +
                      next_mouse_press_index =  ( mouse_press_events[ index + 1 ].nil? ) ?  move_points.last['id'].to_i : mouse_press_events[ index + 1 ].id.to_i
         
     | 
| 
      
 105 
     | 
    
         
            +
                      next_mouse_release = release_events.select{ |event| event['id'].to_i < next_mouse_press_index }
         
     | 
| 
      
 106 
     | 
    
         
            +
                      next_mouse_release_index = next_mouse_release.first['id'].to_i unless next_mouse_release.empty?
         
     | 
| 
      
 107 
     | 
    
         
            +
                      last_point_index = ( next_mouse_release_index.nil? ) ? next_mouse_press_index : next_mouse_release_index
         
     | 
| 
      
 108 
     | 
    
         
            +
                    else
         
     | 
| 
      
 109 
     | 
    
         
            +
                      if ( !release_events.empty? )
         
     | 
| 
      
 110 
     | 
    
         
            +
                        next_mouse_press_index =  ( mouse_press_events[ index + 1 ].nil? ) ?  0 : mouse_press_events[ index + 1 ].id.to_i
         
     | 
| 
      
 111 
     | 
    
         
            +
                        next_mouse_release = ( next_mouse_press_index == 0 ) ? [ release_events.last ] : release_events.select{ |event| event['id'].to_i < next_mouse_press_index }
         
     | 
| 
      
 112 
     | 
    
         
            +
                        last_point_index =  next_mouse_release.first['id'].to_i unless ( next_mouse_release.nil? or next_mouse_release.empty? )
         
     | 
| 
      
 113 
     | 
    
         
            +
                      else
         
     | 
| 
      
 114 
     | 
    
         
            +
                        last_point_index = 0
         
     | 
| 
      
 115 
     | 
    
         
            +
                      end
         
     | 
| 
      
 116 
     | 
    
         
            +
                    end
         
     | 
| 
      
 117 
     | 
    
         
            +
                    
         
     | 
| 
      
 118 
     | 
    
         
            +
                    
         
     | 
| 
      
 119 
     | 
    
         
            +
                    points = move_points.select{ |point| point['id'].to_i > first_point_index and point['id'].to_i <= last_point_index }
         
     | 
| 
      
 120 
     | 
    
         
            +
                    points.first['interval'] = 0.to_f unless points.empty? # set first interval to 0
         
     | 
| 
      
 121 
     | 
    
         
            +
                    
         
     | 
| 
      
 122 
     | 
    
         
            +
                    # PROCESS gesture at MouseButtonRelease unless we hit last point and there is no release
         
     | 
| 
      
 123 
     | 
    
         
            +
                    last_processed_event_id = ( move_points.empty? ) ? 0 : move_points.last['id'].to_i
         
     | 
| 
      
 124 
     | 
    
         
            +
                    if ( last_point_index != last_processed_event_id )
         
     | 
| 
      
 125 
     | 
    
         
            +
                      script << generate_command(active_target, points, mouse_status = 3 ) << "\n"   
         
     | 
| 
      
 126 
     | 
    
         
            +
                      
         
     | 
| 
      
 127 
     | 
    
         
            +
                    # END EVENTS, MouseButtonRelease truncated or second press without release witch would not make sense
         
     | 
| 
      
 128 
     | 
    
         
            +
                    else
         
     | 
| 
      
 129 
     | 
    
         
            +
                      script << generate_command(active_target, points, mouse_status = 1 ) << "\n"  
         
     | 
| 
      
 130 
     | 
    
         
            +
                    end
         
     | 
| 
      
 131 
     | 
    
         
            +
                    
         
     | 
| 
      
 132 
     | 
    
         
            +
                  end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                  script << "\n"
         
     | 
| 
      
 135 
     | 
    
         
            +
                  script << "#################################### \n"
         
     | 
| 
      
 136 
     | 
    
         
            +
                  script << "# End recorded script                \n"
         
     | 
| 
      
 137 
     | 
    
         
            +
                  script << "#################################### \n"
         
     | 
| 
      
 138 
     | 
    
         
            +
                  script     
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
              private
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
                def add_command( mouse_status, active_target, points, duration )
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                  fragment << fragment
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                def get_target_details(test_object)
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                  target = test_object.type
         
     | 
| 
      
 153 
     | 
    
         
            +
                  params = Array.new
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                  params.push(":name=>'#{ test_object.name }'") 
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                  if test_object.name.empty?
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                    params.clear
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                    @_object_identificators.each do |attribute|
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                        value = test_object.attribute(attribute)
         
     | 
| 
      
 166 
     | 
    
         
            +
                        params.push(":#{ attribute } => '#{ value }'") unless value == "" 
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                      rescue MobyBase::AttributeNotFoundError
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                  end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                  if params.size > 0
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                    target << "( "
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    until params.size == 0
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                      target << params.pop
         
     | 
| 
      
 183 
     | 
    
         
            +
                      target << ", " if params.size > 0
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                    end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                    target << " )"
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                  end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                  target
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                def generate_command(target_details, points, mouse_status)
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                  command = "@app." 
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                  if valid_gesture?(points)
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                    command << target_details << ".gesture_points(\n\t[\n"
         
     | 
| 
      
 202 
     | 
    
         
            +
                    duration = 0 
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    for i in 0...points.size  
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                      value =  points[ i ]
         
     | 
| 
      
 207 
     | 
    
         
            +
                      command << "\t\t{'x' => " << value[ "x" ].to_s << ", 'y' => " << value[ "y" ].to_s << ", 'interval' => " << value[ "interval" ].to_s << " }"
         
     | 
| 
      
 208 
     | 
    
         
            +
                      command << ", \n" unless i == points.size - 1
         
     | 
| 
      
 209 
     | 
    
         
            +
                      duration = duration + value[ 'interval' ]
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                    end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                    command << "\n\t], \n\t" << duration.to_s << ", \n\t"
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                    case mouse_status
         
     | 
| 
      
 216 
     | 
    
         
            +
                      when 0
         
     | 
| 
      
 217 
     | 
    
         
            +
                        command << "{ :press => false, :release => false }"
         
     | 
| 
      
 218 
     | 
    
         
            +
                      when 1
         
     | 
| 
      
 219 
     | 
    
         
            +
                        command << "{ :press => true, :release => false }"
         
     | 
| 
      
 220 
     | 
    
         
            +
                      when 2
         
     | 
| 
      
 221 
     | 
    
         
            +
                        command << "{ :press => false, :release => true }"
         
     | 
| 
      
 222 
     | 
    
         
            +
                      when 3
         
     | 
| 
      
 223 
     | 
    
         
            +
                        command << "{ :press => true, :release => true }"
         
     | 
| 
      
 224 
     | 
    
         
            +
                    end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                    command << "\n)"
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                    command
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                  elsif mouse_status > 0
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
                    duration = 0
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                    points.each{|value| duration = duration + value['interval']}
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                    if mouse_status == 1
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                      command << target_details << ".tap_down" 
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
                    elsif duration < @_tap_max_time
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                      command << target_details << ".tap" 
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                    else
         
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
                      command << target_details << ".long_tap( " << duration.to_s << " )" 
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
      
 248 
     | 
    
         
            +
                    end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                  end
         
     | 
| 
      
 251 
     | 
    
         
            +
                end
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
                def valid_gesture?(points)
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                  return false if points.size < 2
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                  min_x = -1
         
     | 
| 
      
 258 
     | 
    
         
            +
                  max_x = -1
         
     | 
| 
      
 259 
     | 
    
         
            +
                  min_y = -1
         
     | 
| 
      
 260 
     | 
    
         
            +
                  max_y = -1
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                  for i in 0...points.size  
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                    value =  points[i]
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
                    x = value['x'].to_i
         
     | 
| 
      
 267 
     | 
    
         
            +
                    y = value['y'].to_i
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
                    min_x = x if x < min_x or min_x == -1
         
     | 
| 
      
 270 
     | 
    
         
            +
                    max_x = x if x > max_x or max_x == -1
         
     | 
| 
      
 271 
     | 
    
         
            +
                    min_y = y if y < min_y or min_y == -1
         
     | 
| 
      
 272 
     | 
    
         
            +
                    max_y = y if y > max_y or max_y == -1
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
                  end
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
                  return false if (max_x - min_x).abs < @_tap_min_distance and (max_y - min_y).abs < @_tap_min_distance
         
     | 
| 
      
 277 
     | 
    
         
            +
                  
         
     | 
| 
      
 278 
     | 
    
         
            +
                  true
         
     | 
| 
      
 279 
     | 
    
         
            +
                end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                def get_duration(start_time, end_time)
         
     | 
| 
      
 282 
     | 
    
         
            +
                  duration_millis = end_time - start_time
         
     | 
| 
      
 283 
     | 
    
         
            +
                  #we want this in second
         
     | 
| 
      
 284 
     | 
    
         
            +
                  duration_millis = duration_millis.to_f
         
     | 
| 
      
 285 
     | 
    
         
            +
                  duration_secs = duration_millis / 1000
         
     | 
| 
      
 286 
     | 
    
         
            +
                  duration_secs
         
     | 
| 
      
 287 
     | 
    
         
            +
                end
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 290 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
              end # Scripter
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
            end # MobyUtil
         
     | 
| 
         @@ -0,0 +1,89 @@ 
     | 
|
| 
      
 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 storing statistics regarding TDriver usage
         
     | 
| 
      
 21 
     | 
    
         
            +
            #
         
     | 
| 
      
 22 
     | 
    
         
            +
            #
         
     | 
| 
      
 23 
     | 
    
         
            +
            # Usage:
         
     | 
| 
      
 24 
     | 
    
         
            +
            # 
         
     | 
| 
      
 25 
     | 
    
         
            +
            # 1. report installation
         
     | 
| 
      
 26 
     | 
    
         
            +
            # MobyUtil::Stats.report('install', 'message')
         
     | 
| 
      
 27 
     | 
    
         
            +
            # will report installation event, message is optional
         
     | 
| 
      
 28 
     | 
    
         
            +
            #
         
     | 
| 
      
 29 
     | 
    
         
            +
            # 2. report activation of TDriver
         
     | 
| 
      
 30 
     | 
    
         
            +
            # MobyUtil::Stats.report('install', 'message')
         
     | 
| 
      
 31 
     | 
    
         
            +
            # will report TDriver activation event, message is optional
         
     | 
| 
      
 32 
     | 
    
         
            +
            #
         
     | 
| 
      
 33 
     | 
    
         
            +
            # 3. report exception raised by TDriver
         
     | 
| 
      
 34 
     | 
    
         
            +
            # MobyUtil::Stats.report('exception', 'message describing the exception')
         
     | 
| 
      
 35 
     | 
    
         
            +
            # will report exception thrown by TDriver, message describes the the exception
         
     | 
| 
      
 36 
     | 
    
         
            +
            #
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            module MobyUtil  
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            	class Stats
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            		def self.report( action, message )
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            			return nil if defined?( $_TDRIVER_DISABLE_STATS_REPORTING )
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  require 'rubygems'
         
     | 
| 
      
 47 
     | 
    
         
            +
                  require 'uri'
         
     | 
| 
      
 48 
     | 
    
         
            +
                  require 'socket'
         
     | 
| 
      
 49 
     | 
    
         
            +
                  require 'net/http'
         
     | 
| 
      
 50 
     | 
    
         
            +
                  require 'date'
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            			report_thread = Thread.new{
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            				begin
         
     | 
| 
      
 55 
     | 
    
         
            +
            					# TODO: override possibility for the url using parameters?
         
     | 
| 
      
 56 
     | 
    
         
            +
            					url = URI.parse('http://127.0.0.1/tdriver/stats/create/new_stat')
         
     | 
| 
      
 57 
     | 
    
         
            +
            					
         
     | 
| 
      
 58 
     | 
    
         
            +
            					resp, data = Net::HTTP.new( url.host, url.port ).post( 
         
     | 
| 
      
 59 
     | 
    
         
            +
            						url.path, 
         
     | 
| 
      
 60 
     | 
    
         
            +
            						"stat[action]=#{ action }" <<
         
     | 
| 
      
 61 
     | 
    
         
            +
            						"&stat[host]=#{ Socket.gethostname }" <<
         
     | 
| 
      
 62 
     | 
    
         
            +
            						"&stat[time_stamp]=#{ DateTime.now.strftime( "%Y%m%d%H%M%S" ) }" <<
         
     | 
| 
      
 63 
     | 
    
         
            +
            						"&stat[message]=#{ message }" <<
         
     | 
| 
      
 64 
     | 
    
         
            +
            						"&stat[user]=#{ 'NO' }" << 
         
     | 
| 
      
 65 
     | 
    
         
            +
            						"&stat[ip]=#{ 'NO' }" << 
         
     | 
| 
      
 66 
     | 
    
         
            +
            						"&stat[mac]=#{ 'NO' }" << 
         
     | 
| 
      
 67 
     | 
    
         
            +
            						"&stat[platform]=#{ RUBY_PLATFORM.to_s }" <<
         
     | 
| 
      
 68 
     | 
    
         
            +
            						"&stat[version]=#{ ENV['TDRIVER_VERSION'] }" <<
         
     | 
| 
      
 69 
     | 
    
         
            +
            						"&commit=#{ 'Create' }",
         
     | 
| 
      
 70 
     | 
    
         
            +
            						{ 'Content-Type' => 'application/x-www-form-urlencoded' }
         
     | 
| 
      
 71 
     | 
    
         
            +
            					)
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            				rescue Exception => e
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            					#puts "Exception:#{e.message} trace:#{e.backtrace.inspect}"             
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            				end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            			}
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            			report_thread
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            		end	    
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            		TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            	end # Stats
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            end # MobyUtil
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            	# This error should be raised when the desired user data is not found
         
     | 
| 
      
 23 
     | 
    
         
            +
            	class UserDataNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
         
     | 
| 
      
 24 
     | 
    
         
            +
            	
         
     | 
| 
      
 25 
     | 
    
         
            +
            	# This error should be raised when the desired data column name to be used for the output is not found
         
     | 
| 
      
 26 
     | 
    
         
            +
            	class UserDataColumnNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
         
     | 
| 
      
 27 
     | 
    
         
            +
            	
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            # user data inputs related errors
         
     | 
| 
      
 21 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'error.rb' ) )
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            # user data inputs module implementation
         
     | 
| 
      
 24 
     | 
    
         
            +
            require File.expand_path( File.join( File.dirname( __FILE__ ), 'user_data.rb' ) )
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,104 @@ 
     | 
|
| 
      
 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: Optional string containing the name of table to be used when user information, if empty the parameter user_data_server_database_tablename will be used
         
     | 
| 
      
 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 = nil )
         
     | 
| 
      
 63 
     | 
    
         
            +
            			
         
     | 
| 
      
 64 
     | 
    
         
            +
            			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 =  $parameters[ :user_data_db_type, nil ].to_s.downcase
         
     | 
| 
      
 68 
     | 
    
         
            +
            			host =  $parameters[ :user_data_server_ip ]
         
     | 
| 
      
 69 
     | 
    
         
            +
            			username = $parameters[ :user_data_server_username ]
         
     | 
| 
      
 70 
     | 
    
         
            +
            			password = $parameters[ :user_data_server_password ]
         
     | 
| 
      
 71 
     | 
    
         
            +
            			database_name = $parameters[ :user_data_server_database_name ]
         
     | 
| 
      
 72 
     | 
    
         
            +
                  table_name = $parameters[:user_data_server_database_tablename] if table_name.nil? or table_name.empty?
         
     | 
| 
      
 73 
     | 
    
         
            +
            			
         
     | 
| 
      
 74 
     | 
    
         
            +
            			db_connection = DBConnection.new(  db_type, host, database_name, username, password )
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            			query_string = "select `#{ language }` from #{ table_name } where lname = \'#{ user_data_lname }' and `#{ language }` <>\'#MISSING\'"
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            			begin
         
     | 
| 
      
 79 
     | 
    
         
            +
            				result = MobyUtil::DBAccess.query( db_connection, query_string )
         
     | 
| 
      
 80 
     | 
    
         
            +
            			rescue
         
     | 
| 
      
 81 
     | 
    
         
            +
            				# if column referring to language is not found then raise error for language not found
         
     | 
| 
      
 82 
     | 
    
         
            +
            				raise UserDataColumnNotFoundError.new( "User data language column '#{ language }' was not found" ) unless $!.message.index( "Unknown column" ) == nil
         
     | 
| 
      
 83 
     | 
    
         
            +
            				raise SqlError.new( $!.message )
         
     | 
| 
      
 84 
     | 
    
         
            +
            			end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            			# Return only the first column of the row or and array of the values of the first column if multiple rows have been found
         
     | 
| 
      
 87 
     | 
    
         
            +
            			raise UserDataNotFoundError.new( "No user data for '#{ user_data_lname }' found for language '#{ language }'" ) if ( result.empty?)
         
     | 
| 
      
 88 
     | 
    
         
            +
            			if result.length > 1
         
     | 
| 
      
 89 
     | 
    
         
            +
            				result_array = Array.new # array of rows! We want the first column of the first row
         
     | 
| 
      
 90 
     | 
    
         
            +
            				result.each do |row|
         
     | 
| 
      
 91 
     | 
    
         
            +
            					result_array << row[0]
         
     | 
| 
      
 92 
     | 
    
         
            +
            				end
         
     | 
| 
      
 93 
     | 
    
         
            +
            				return result_array
         
     | 
| 
      
 94 
     | 
    
         
            +
            			else
         
     | 
| 
      
 95 
     | 
    
         
            +
            				# Result is an Array of rows (Array<String>)! We want the first column of the first row.
         
     | 
| 
      
 96 
     | 
    
         
            +
            				return result[0][0]
         
     | 
| 
      
 97 
     | 
    
         
            +
            			end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            		end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            	end # class
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            end # module
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     |