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,134 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            # TODO: document me  
         
     | 
| 
      
 21 
     | 
    
         
            +
            module TDriver
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # TODO: document me  
         
     | 
| 
      
 24 
     | 
    
         
            +
              class TestObjectCache
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 27 
     | 
    
         
            +
                def initialize()
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  @objects = {}
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
                
         
     | 
| 
      
 33 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 34 
     | 
    
         
            +
                def each_object( &block )
         
     | 
| 
      
 35 
     | 
    
         
            +
                
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @objects.each_value{ | object | yield( object ) }
         
     | 
| 
      
 37 
     | 
    
         
            +
                
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
                
         
     | 
| 
      
 40 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 41 
     | 
    
         
            +
                def objects
         
     | 
| 
      
 42 
     | 
    
         
            +
                
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @objects
         
     | 
| 
      
 44 
     | 
    
         
            +
                
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                    
         
     | 
| 
      
 47 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 48 
     | 
    
         
            +
                def has_object?( test_object )
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  if test_object.kind_of?( Numeric )
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    @objects.has_key?( test_object )
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  else
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    @objects.has_key?( test_object.hash )
         
     | 
| 
      
 57 
     | 
    
         
            +
                  
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                
         
     | 
| 
      
 60 
     | 
    
         
            +
                
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
                
         
     | 
| 
      
 63 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 64 
     | 
    
         
            +
                def object_keys
         
     | 
| 
      
 65 
     | 
    
         
            +
                
         
     | 
| 
      
 66 
     | 
    
         
            +
                  @objects.keys
         
     | 
| 
      
 67 
     | 
    
         
            +
                
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
                
         
     | 
| 
      
 70 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 71 
     | 
    
         
            +
                def object_values
         
     | 
| 
      
 72 
     | 
    
         
            +
                
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @objects.values
         
     | 
| 
      
 74 
     | 
    
         
            +
                    
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
                
         
     | 
| 
      
 77 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 78 
     | 
    
         
            +
                def []( value )
         
     | 
| 
      
 79 
     | 
    
         
            +
                    
         
     | 
| 
      
 80 
     | 
    
         
            +
                  if value.kind_of?( Numeric )
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    @objects.fetch( value ){ raise ArgumentError, "Test object (#{ value }) not found from cache" }
         
     | 
| 
      
 83 
     | 
    
         
            +
                  
         
     | 
| 
      
 84 
     | 
    
         
            +
                  else
         
     | 
| 
      
 85 
     | 
    
         
            +
                  
         
     | 
| 
      
 86 
     | 
    
         
            +
                    @objects.fetch( value.hash ){ raise ArgumentError, "Test object (#{ value.hash }) not found from cache" }
         
     | 
| 
      
 87 
     | 
    
         
            +
                  
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
                
         
     | 
| 
      
 92 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 93 
     | 
    
         
            +
                def add_object( test_object )
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                  test_object_hash = test_object.hash
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  if @objects.has_key?( test_object_hash )
         
     | 
| 
      
 98 
     | 
    
         
            +
                  
         
     | 
| 
      
 99 
     | 
    
         
            +
                    warn( "warning: Test object (#{ test_object_hash }) already exists in cache" )
         
     | 
| 
      
 100 
     | 
    
         
            +
                    
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                
         
     | 
| 
      
 103 
     | 
    
         
            +
                  @objects[ test_object_hash ] = test_object
         
     | 
| 
      
 104 
     | 
    
         
            +
                        
         
     | 
| 
      
 105 
     | 
    
         
            +
                  test_object
         
     | 
| 
      
 106 
     | 
    
         
            +
                
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 110 
     | 
    
         
            +
                def remove_object( test_object )
         
     | 
| 
      
 111 
     | 
    
         
            +
                    
         
     | 
| 
      
 112 
     | 
    
         
            +
                  test_object_hash = test_object.hash
         
     | 
| 
      
 113 
     | 
    
         
            +
                
         
     | 
| 
      
 114 
     | 
    
         
            +
                  @objects.delete( test_object_hash )
         
     | 
| 
      
 115 
     | 
    
         
            +
                    
         
     | 
| 
      
 116 
     | 
    
         
            +
                  #raise ArgumentError, "Test object (#{ test_object_hash }) not found from cache" unless @objects.has_key?( test_object_hash )
         
     | 
| 
      
 117 
     | 
    
         
            +
                  
         
     | 
| 
      
 118 
     | 
    
         
            +
                  self
         
     | 
| 
      
 119 
     | 
    
         
            +
                
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                # TODO: document me  
         
     | 
| 
      
 123 
     | 
    
         
            +
                def remove_objects
         
     | 
| 
      
 124 
     | 
    
         
            +
                
         
     | 
| 
      
 125 
     | 
    
         
            +
                  @objects.clear
         
     | 
| 
      
 126 
     | 
    
         
            +
                
         
     | 
| 
      
 127 
     | 
    
         
            +
                end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            		# enable hooking for performance measurement & debug logging
         
     | 
| 
      
 130 
     | 
    
         
            +
            		TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              end # TestObjectCache
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            end # TDriver
         
     | 
| 
         @@ -0,0 +1,684 @@ 
     | 
|
| 
      
 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 TDriver
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              module TestObjectFactory
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
                # private methods and variables
         
     | 
| 
      
 25 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                private
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  # TODO: document me
         
     | 
| 
      
 30 
     | 
    
         
            +
                  def initialize_class
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    reset
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  # TODO: document me
         
     | 
| 
      
 37 
     | 
    
         
            +
                  def get_object_params( creation_attributes )
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    if creation_attributes[ :type ] != 'application'
         
     | 
| 
      
 40 
     | 
    
         
            +
                      
         
     | 
| 
      
 41 
     | 
    
         
            +
                      object_search_params = creation_attributes.clone
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                      # see below lines how to do following easier
         
     | 
| 
      
 44 
     | 
    
         
            +
                      #object_search_params[ :className  ] = object_search_params.delete( :type ) if creation_attributes.has_key?( :type )
         
     | 
| 
      
 45 
     | 
    
         
            +
                      #object_search_params[ :objectName ] = object_search_params.delete( :name ) if creation_attributes.has_key?( :name )
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      object_search_params.rename_key!( :type, :className ){} 
         
     | 
| 
      
 48 
     | 
    
         
            +
                      object_search_params.rename_key!( :name, :objectName ){}
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                      object_search_params
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    else
         
     | 
| 
      
 53 
     | 
    
         
            +
                    
         
     | 
| 
      
 54 
     | 
    
         
            +
                      {}
         
     | 
| 
      
 55 
     | 
    
         
            +
                    
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end    
         
     | 
| 
      
 57 
     | 
    
         
            +
                  
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  # TODO: document me
         
     | 
| 
      
 61 
     | 
    
         
            +
                  def get_parent_params( test_object )
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                    unless [ 'application', 'sut' ].include?( test_object.type ) 
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                      search_params = []
         
     | 
| 
      
 66 
     | 
    
         
            +
                    
         
     | 
| 
      
 67 
     | 
    
         
            +
                      search_params.concat( get_parent_params( test_object.parent ) ) if test_object.parent
         
     | 
| 
      
 68 
     | 
    
         
            +
                      search_params.concat( [ :className => test_object.type, :tasId => test_object.id ] ) #if test_object
         
     | 
| 
      
 69 
     | 
    
         
            +
                      
         
     | 
| 
      
 70 
     | 
    
         
            +
                      search_params
         
     | 
| 
      
 71 
     | 
    
         
            +
                      
         
     | 
| 
      
 72 
     | 
    
         
            +
                    else
         
     | 
| 
      
 73 
     | 
    
         
            +
                    
         
     | 
| 
      
 74 
     | 
    
         
            +
                      []
         
     | 
| 
      
 75 
     | 
    
         
            +
                    
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                  # TODO: document me
         
     | 
| 
      
 81 
     | 
    
         
            +
                  def list_matching_test_objects_as_list( test_object_adapter, matches )
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                    test_object_adapter.list_test_objects_as_string( matches ).each_with_index.collect{ | object, object_index | 
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                      "#{ ( object_index + 1 ).to_s.rjust( 3, '0' ) }) #{ object.to_s }"
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                    }.join( "\n" )
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                end # self 
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 94 
     | 
    
         
            +
                def self.reset
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  # get timeout from parameters, use default value if parameter not found
         
     | 
| 
      
 97 
     | 
    
         
            +
                  @timeout = $parameters[ :application_synchronization_timeout, "20" ].to_f
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  # get timeout retry interval from parameters, use default value if parameter not found
         
     | 
| 
      
 100 
     | 
    
         
            +
                  @_retry_interval = $parameters[ :application_synchronization_retry_interval, "1" ].to_f
         
     | 
| 
      
 101 
     | 
    
         
            +
                
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                # function to get timeout for TestObjectFactory
         
     | 
| 
      
 105 
     | 
    
         
            +
                def self.timeout
         
     | 
| 
      
 106 
     | 
    
         
            +
                
         
     | 
| 
      
 107 
     | 
    
         
            +
                  @timeout
         
     | 
| 
      
 108 
     | 
    
         
            +
                  
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                # Function to set timeout for TestObjectFactory
         
     | 
| 
      
 112 
     | 
    
         
            +
                # This should be used only in unit testing, otherwise should not be used
         
     | 
| 
      
 113 
     | 
    
         
            +
                # sets timeout used in identifying TestObjects to new timeout
         
     | 
| 
      
 114 
     | 
    
         
            +
                #
         
     | 
| 
      
 115 
     | 
    
         
            +
                # == params
         
     | 
| 
      
 116 
     | 
    
         
            +
                # new_timeout:: Fixnum which defines the new timeout
         
     | 
| 
      
 117 
     | 
    
         
            +
                # == raises
         
     | 
| 
      
 118 
     | 
    
         
            +
                # ArgumentError:: if parameter is not kind of Fixnum
         
     | 
| 
      
 119 
     | 
    
         
            +
                def self.timeout=( value )
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                  value.check_type( Numeric, "Wrong argument type $1 for timeout value (expected $2)" )
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                  @timeout = value
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 128 
     | 
    
         
            +
                def self.identify_object( rules )
         
     | 
| 
      
 129 
     | 
    
         
            +
              
         
     | 
| 
      
 130 
     | 
    
         
            +
                  # retrieve test object identification directives; e.g. :__index, :__xy_sorting etc 
         
     | 
| 
      
 131 
     | 
    
         
            +
                  directives = rules[ :identification_directives ]
         
     | 
| 
      
 132 
     | 
    
         
            +
                  
         
     | 
| 
      
 133 
     | 
    
         
            +
                  # retrieve sut object
         
     | 
| 
      
 134 
     | 
    
         
            +
                  sut = rules[ :parent ].instance_variable_get( :@sut )
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                  # retrieve sut objects test object adapter
         
     | 
| 
      
 137 
     | 
    
         
            +
                  test_object_adapter = sut.instance_variable_get( :@test_object_adapter )
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  # add object identification attribute keys to dynamic attributes white list
         
     | 
| 
      
 140 
     | 
    
         
            +
                  TDriver::AttributeFilter.add_attributes( rules[ :object_attributes_hash ].keys )
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                  # search parameters for find_objects feature    
         
     | 
| 
      
 143 
     | 
    
         
            +
                  search_parameters = make_object_search_params( rules[ :parent ], rules[ :object_attributes_hash ] )
         
     | 
| 
      
 144 
     | 
    
         
            +
                  
         
     | 
| 
      
 145 
     | 
    
         
            +
                  # default rules
         
     | 
| 
      
 146 
     | 
    
         
            +
                  directives.default_values(
         
     | 
| 
      
 147 
     | 
    
         
            +
                        
         
     | 
| 
      
 148 
     | 
    
         
            +
                    # get timeout from rules hash or TestObjectFactory
         
     | 
| 
      
 149 
     | 
    
         
            +
                    :__timeout => @timeout,
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                    # get retry interval from rules hash or TestObjectFactory
         
     | 
| 
      
 152 
     | 
    
         
            +
                    :__retry_interval => @_retry_interval,
         
     | 
| 
      
 153 
     | 
    
         
            +
                     
         
     | 
| 
      
 154 
     | 
    
         
            +
                    # determine that are we going to retrieve multiple test objects or just one
         
     | 
| 
      
 155 
     | 
    
         
            +
                    :__multiple_objects => false,
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                    # determine that should all child objects childrens be retrieved
         
     | 
| 
      
 158 
     | 
    
         
            +
                    :__find_all_children => true,
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                    # determine that did user give index value
         
     | 
| 
      
 161 
     | 
    
         
            +
                    :__index_given => directives.has_key?( :__index ),
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                    # use sorting if index given
         
     | 
| 
      
 164 
     | 
    
         
            +
                    :__xy_sorting => directives.has_key?( :__index ),
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                    # determine index of test object to be retrieved
         
     | 
| 
      
 167 
     | 
    
         
            +
                    :__index => 0,
         
     | 
| 
      
 168 
     | 
    
         
            +
                    
         
     | 
| 
      
 169 
     | 
    
         
            +
                    :__retriable_allowed_exceptions => [ MobyBase::TestObjectNotFoundError, MobyBase::MultipleTestObjectsIdentifiedError ]
         
     | 
| 
      
 170 
     | 
    
         
            +
                             
         
     | 
| 
      
 171 
     | 
    
         
            +
                  )
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                  # if sorting enabled; retrieve application layout direction first
         
     | 
| 
      
 174 
     | 
    
         
            +
                  if directives[ :__xy_sorting ] == true
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                    parent_application = directives[ :__parent_application ] || rules[ :parent_application ]
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                    # application could be retrieved also like this...
         
     | 
| 
      
 179 
     | 
    
         
            +
                    # rules[ :parent ].instance_variable_get( :@parent_application )
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                    # when e.g. wait_child is called to SUT, TDriver is unable to determine layout direction used for sorting/indexing
         
     | 
| 
      
 182 
     | 
    
         
            +
                    if rules[ :parent ].sut?
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                      application_layout_direction = directives[ :__layout_direction ]
         
     | 
| 
      
 185 
     | 
    
         
            +
                    
         
     | 
| 
      
 186 
     | 
    
         
            +
                      raise RuntimeError, 'layout direction is not available for indexing/xy_sorting; please use e.g. :__layout_direction => "LeftToRight"' if application_layout_direction.blank?
         
     | 
| 
      
 187 
     | 
    
         
            +
                            
         
     | 
| 
      
 188 
     | 
    
         
            +
                    else
         
     | 
| 
      
 189 
     | 
    
         
            +
                    
         
     | 
| 
      
 190 
     | 
    
         
            +
                      # retrieve layout direction from application object if available
         
     | 
| 
      
 191 
     | 
    
         
            +
                      unless parent_application.nil?
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                          application_layout_direction = ""
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                          if directives[ :__layout_direction ].blank?
         
     | 
| 
      
 198 
     | 
    
         
            +
                          
         
     | 
| 
      
 199 
     | 
    
         
            +
                            application_layout_direction = parent_application.attribute( 'layoutDirection' ).to_s 
         
     | 
| 
      
 200 
     | 
    
         
            +
                          
         
     | 
| 
      
 201 
     | 
    
         
            +
                          end
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                          raise if application_layout_direction.empty?
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                        rescue
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                          application_layout_direction = directives[ :__layout_direction ]
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                          # parent application not defined/available, use default value
         
     | 
| 
      
 210 
     | 
    
         
            +
                          application_layout_direction = 'LeftToRight' if application_layout_direction.blank?
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                        end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                      else
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
                        raise RuntimeError, 'parent application not given; unable to retrieve layoutDirection attribute'
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                      end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                    end
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                  end
         
     | 
| 
      
 224 
     | 
    
         
            +
                  
         
     | 
| 
      
 225 
     | 
    
         
            +
                  # identify objects until desired matches found or timeout exceeds
         
     | 
| 
      
 226 
     | 
    
         
            +
                  MobyUtil::Retryable.until( 
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                    # maximum time used for retrying, if timeout exceeds pass last raised exception
         
     | 
| 
      
 229 
     | 
    
         
            +
                    :timeout => directives[ :__timeout ], 
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                    # interval used before retrying
         
     | 
| 
      
 232 
     | 
    
         
            +
                    :interval => directives[ :__retry_interval ],
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                    # following exceptions are allowed; Retry until timeout exceeds or other exception type is raised
         
     | 
| 
      
 235 
     | 
    
         
            +
                    :exception => directives[ :__retriable_allowed_exceptions ]
         
     | 
| 
      
 236 
     | 
    
         
            +
                    
         
     | 
| 
      
 237 
     | 
    
         
            +
                  ){
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                    # refresh sut
         
     | 
| 
      
 240 
     | 
    
         
            +
                    sut.refresh( directives[ :__refresh_arguments ], search_parameters )
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                    # in case of test object adapter was change during the refresh (if connected the SUT first time, see possible 'connect_after' hook from sut plugin)
         
     | 
| 
      
 243 
     | 
    
         
            +
                    test_object_adapter = sut.instance_variable_get( :@test_object_adapter )
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                    # retrieve objects from xml
         
     | 
| 
      
 246 
     | 
    
         
            +
                    matches, rule = test_object_adapter.get_objects(
         
     | 
| 
      
 247 
     | 
    
         
            +
                    
         
     | 
| 
      
 248 
     | 
    
         
            +
                     rules[ :parent ].xml_data, 
         
     | 
| 
      
 249 
     | 
    
         
            +
                     rules[ :object_attributes_hash ], 
         
     | 
| 
      
 250 
     | 
    
         
            +
                     directives[ :__find_all_children ] 
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                    )
         
     | 
| 
      
 253 
     | 
    
         
            +
                              
         
     | 
| 
      
 254 
     | 
    
         
            +
                    # Temporary prevent users misleading :Text with :text (as they are different)
         
     | 
| 
      
 255 
     | 
    
         
            +
                    if ( rules[ :object_attributes_hash ].has_key?(:Text) )
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                      rules[ :object_attributes_hash ][:text] = rules[ :object_attributes_hash ][:Text]
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                    end
         
     | 
| 
      
 260 
     | 
    
         
            +
                    
         
     | 
| 
      
 261 
     | 
    
         
            +
                    # If retrying and regexp search is turned on then update the rules for text search converting it to a regex 
         
     | 
| 
      
 262 
     | 
    
         
            +
                    if ( 
         
     | 
| 
      
 263 
     | 
    
         
            +
                          matches.empty? and 
         
     | 
| 
      
 264 
     | 
    
         
            +
                          $parameters[ sut.id ][:elided_search, 'false'] == 'true' and 
         
     | 
| 
      
 265 
     | 
    
         
            +
                          rules[ :object_attributes_hash ].has_key?(:text) and
         
     | 
| 
      
 266 
     | 
    
         
            +
                          rules[ :object_attributes_hash ][ :text ].kind_of? String
         
     | 
| 
      
 267 
     | 
    
         
            +
                      )
         
     | 
| 
      
 268 
     | 
    
         
            +
                        text_string = rules[ :object_attributes_hash ][ :text ]
         
     | 
| 
      
 269 
     | 
    
         
            +
                        if ( $parameters[ sut.id ][:elided_search_with_ellipsis , 'false'] == 'true' )
         
     | 
| 
      
 270 
     | 
    
         
            +
                          ellipsis_char = ".*\xE2\x80\xA6"  # unicode \u2026 the ... character \xE2\x80\xA6
         
     | 
| 
      
 271 
     | 
    
         
            +
                        else
         
     | 
| 
      
 272 
     | 
    
         
            +
                          ellipsis_char = ""
         
     | 
| 
      
 273 
     | 
    
         
            +
                        end
         
     | 
| 
      
 274 
     | 
    
         
            +
                        elided_regex = Regexp.new( text_string[0..3] + ellipsis_char )
         
     | 
| 
      
 275 
     | 
    
         
            +
                        rules[ :object_attributes_hash ][ :text ] = elided_regex
         
     | 
| 
      
 276 
     | 
    
         
            +
                    end
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
                    # raise exception if no matching object(s) found
         
     | 
| 
      
 279 
     | 
    
         
            +
                    raise MobyBase::TestObjectNotFoundError, "Cannot find object with rule:\n#{ rules[ :object_attributes_hash ].inspect }" if matches.empty?
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                    # raise exception if multiple matches found and only one expected 
         
     | 
| 
      
 282 
     | 
    
         
            +
                    if ( !directives[ :__multiple_objects ] ) && ( matches.count > 1 && !directives[ :__index_given ] )
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
      
 284 
     | 
    
         
            +
                      message = "Multiple test objects found with rule: #{ rules[ :object_attributes_hash ].inspect }\nMatching objects:\n#{ list_matching_test_objects_as_list( test_object_adapter, matches ) }\n"
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
                      # raise exception (with list of paths to all matching objects) if multiple objects flag is false and more than one match found
         
     | 
| 
      
 287 
     | 
    
         
            +
                      raise MobyBase::MultipleTestObjectsIdentifiedError, message
         
     | 
| 
      
 288 
     | 
    
         
            +
                        
         
     | 
| 
      
 289 
     | 
    
         
            +
                    end
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
                    # sort matches if enabled
         
     | 
| 
      
 292 
     | 
    
         
            +
                    if directives[ :__xy_sorting ] == true
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                      # sort elements
         
     | 
| 
      
 295 
     | 
    
         
            +
                      test_object_adapter.sort_elements( matches, application_layout_direction )
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
                    end
         
     | 
| 
      
 298 
     | 
    
         
            +
             
     | 
| 
      
 299 
     | 
    
         
            +
                    # return result; one or multiple xml elements
         
     | 
| 
      
 300 
     | 
    
         
            +
                    if directives[ :__multiple_objects ] && !directives[ :__index_given ]
         
     | 
| 
      
 301 
     | 
    
         
            +
                    
         
     | 
| 
      
 302 
     | 
    
         
            +
                      # return multiple test objects
         
     | 
| 
      
 303 
     | 
    
         
            +
                      matches.to_a
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
                    else
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
                      # return only one test object  
         
     | 
| 
      
 308 
     | 
    
         
            +
                      [ matches[ directives[ :__index ] ] ]
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
                    end
         
     | 
| 
      
 311 
     | 
    
         
            +
             
     | 
| 
      
 312 
     | 
    
         
            +
                  }
         
     | 
| 
      
 313 
     | 
    
         
            +
                    
         
     | 
| 
      
 314 
     | 
    
         
            +
                end
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 317 
     | 
    
         
            +
                def self.get_test_objects( rules )
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
      
 319 
     | 
    
         
            +
                  # retrieve sut object
         
     | 
| 
      
 320 
     | 
    
         
            +
                  sut = rules[ :parent ].instance_variable_get( :@sut )
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                  # retrieve sut objects test object adapter
         
     | 
| 
      
 323 
     | 
    
         
            +
                  test_object_adapter = sut.instance_variable_get( :@test_object_adapter )
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
                  # store rules hash to variable
         
     | 
| 
      
 326 
     | 
    
         
            +
                  object_attributes_hash = rules[ :object_attributes_hash ].clone
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
                  # remove test object identification directives for object identification attributes hash (e.g. :__index, :__multiple_objects etc.)
         
     | 
| 
      
 329 
     | 
    
         
            +
                  identification_directives = rules[ :identification_directives ]
         
     | 
| 
      
 330 
     | 
    
         
            +
                   
         
     | 
| 
      
 331 
     | 
    
         
            +
                  # verify given identification directives, only documented end-user directives is checked
         
     | 
| 
      
 332 
     | 
    
         
            +
                  identification_directives.each{ | key, value |
         
     | 
| 
      
 333 
     | 
    
         
            +
                  
         
     | 
| 
      
 334 
     | 
    
         
            +
                    # do not verify type by default
         
     | 
| 
      
 335 
     | 
    
         
            +
                    type = nil
         
     | 
| 
      
 336 
     | 
    
         
            +
                  
         
     | 
| 
      
 337 
     | 
    
         
            +
                    case key
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
                      # Fixnum          
         
     | 
| 
      
 340 
     | 
    
         
            +
                      when :__index, :__timeout
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
                        # for backward compatibility          
         
     | 
| 
      
 343 
     | 
    
         
            +
                        if value.kind_of?( String )
         
     | 
| 
      
 344 
     | 
    
         
            +
                        
         
     | 
| 
      
 345 
     | 
    
         
            +
                          warn "warning: deprecated variable type String for #{ key.inspect } test object identification directive (expected TrueClass or FalseClass)"          
         
     | 
| 
      
 346 
     | 
    
         
            +
                      
         
     | 
| 
      
 347 
     | 
    
         
            +
                          raise ArgumentError, "deprecated and wrong variable content format for #{ key.inspect } test object identification directive (expected Numeric string)" unless value.numeric?
         
     | 
| 
      
 348 
     | 
    
         
            +
                      
         
     | 
| 
      
 349 
     | 
    
         
            +
                          value = value.to_i
         
     | 
| 
      
 350 
     | 
    
         
            +
                          
         
     | 
| 
      
 351 
     | 
    
         
            +
                        end
         
     | 
| 
      
 352 
     | 
    
         
            +
                      
         
     | 
| 
      
 353 
     | 
    
         
            +
                        type = Fixnum
         
     | 
| 
      
 354 
     | 
    
         
            +
                                
         
     | 
| 
      
 355 
     | 
    
         
            +
                      when :__logging, :__xy_sorting
         
     | 
| 
      
 356 
     | 
    
         
            +
             
     | 
| 
      
 357 
     | 
    
         
            +
                        # for backward compatibility          
         
     | 
| 
      
 358 
     | 
    
         
            +
                        if value.kind_of?( String )
         
     | 
| 
      
 359 
     | 
    
         
            +
                          
         
     | 
| 
      
 360 
     | 
    
         
            +
                          warn "warning: deprecated variable type String for #{ key.inspect } test object identification directive (expected TrueClass or FalseClass)"          
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
                          value = value.to_boolean 
         
     | 
| 
      
 363 
     | 
    
         
            +
                          
         
     | 
| 
      
 364 
     | 
    
         
            +
                        end
         
     | 
| 
      
 365 
     | 
    
         
            +
                      
         
     | 
| 
      
 366 
     | 
    
         
            +
                        type = [ TrueClass, FalseClass ]
         
     | 
| 
      
 367 
     | 
    
         
            +
                      
         
     | 
| 
      
 368 
     | 
    
         
            +
                    end
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
      
 370 
     | 
    
         
            +
                    # verify hash value if type defined 
         
     | 
| 
      
 371 
     | 
    
         
            +
                    value.check_type( type, "wrong variable type $1 for #{ key.inspect } test object identification directive (expected $2)" ) unless type.nil?
         
     | 
| 
      
 372 
     | 
    
         
            +
             
     | 
| 
      
 373 
     | 
    
         
            +
                  }
         
     | 
| 
      
 374 
     | 
    
         
            +
                        
         
     | 
| 
      
 375 
     | 
    
         
            +
                  # do not create refresh arguments hash if already exists
         
     | 
| 
      
 376 
     | 
    
         
            +
                  unless identification_directives.has_key?( :__refresh_arguments )
         
     | 
| 
      
 377 
     | 
    
         
            +
                        
         
     | 
| 
      
 378 
     | 
    
         
            +
                    # create application refresh attributes hash
         
     | 
| 
      
 379 
     | 
    
         
            +
                    if object_attributes_hash[ :type ] == 'application'
         
     | 
| 
      
 380 
     | 
    
         
            +
             
     | 
| 
      
 381 
     | 
    
         
            +
                      # collect :name, :id and :applicationUid from object_attributes_hash if found
         
     | 
| 
      
 382 
     | 
    
         
            +
                      identification_directives[ :__refresh_arguments ] = object_attributes_hash.collect_keys( :name, :id, :applicationUid )
         
     | 
| 
      
 383 
     | 
    
         
            +
             
     | 
| 
      
 384 
     | 
    
         
            +
                    else
         
     | 
| 
      
 385 
     | 
    
         
            +
                                        
         
     | 
| 
      
 386 
     | 
    
         
            +
                      if rules[ :parent ].kind_of?( MobyBase::TestObject )
         
     | 
| 
      
 387 
     | 
    
         
            +
             
     | 
| 
      
 388 
     | 
    
         
            +
                        # get current application for test object
         
     | 
| 
      
 389 
     | 
    
         
            +
                        identification_directives[ :__refresh_arguments ] = { :id => rules[ :parent ].get_application_id }
         
     | 
| 
      
 390 
     | 
    
         
            +
             
     | 
| 
      
 391 
     | 
    
         
            +
                      elsif rules[ :parent ].kind_of?( MobyBase::SUT )
         
     | 
| 
      
 392 
     | 
    
         
            +
                      
         
     | 
| 
      
 393 
     | 
    
         
            +
                        # get current application for sut
         
     | 
| 
      
 394 
     | 
    
         
            +
                        identification_directives[ :__refresh_arguments ] = { :id => rules[ :parent ].current_application_id }
         
     | 
| 
      
 395 
     | 
    
         
            +
             
     | 
| 
      
 396 
     | 
    
         
            +
                      end
         
     | 
| 
      
 397 
     | 
    
         
            +
                      
         
     | 
| 
      
 398 
     | 
    
         
            +
                    end
         
     | 
| 
      
 399 
     | 
    
         
            +
             
     | 
| 
      
 400 
     | 
    
         
            +
                  end
         
     | 
| 
      
 401 
     | 
    
         
            +
                  
         
     | 
| 
      
 402 
     | 
    
         
            +
                  # add object identification attribute keys to dynamic attributes white list
         
     | 
| 
      
 403 
     | 
    
         
            +
                  #TDriver::AttributeFilter.add_attributes( object_attributes_hash.keys )
         
     | 
| 
      
 404 
     | 
    
         
            +
             
     | 
| 
      
 405 
     | 
    
         
            +
                  child_objects = identify_object( rules ).collect{ | test_object_xml |
         
     | 
| 
      
 406 
     | 
    
         
            +
             
     | 
| 
      
 407 
     | 
    
         
            +
                    # in case of test object adapter was change during the refresh (if connected the SUT first time, see possible 'connect_after' hook from sut plugin)
         
     | 
| 
      
 408 
     | 
    
         
            +
                    test_object_adapter = sut.instance_variable_get( :@test_object_adapter )
         
     | 
| 
      
 409 
     | 
    
         
            +
                            
         
     | 
| 
      
 410 
     | 
    
         
            +
                    # create parent application test object if none defined in rules; most likely the call is originated from SUT#child, but not by using SUT#application
         
     | 
| 
      
 411 
     | 
    
         
            +
                    unless identification_directives.has_key?( :__parent_application ) || rules.has_key?( :parent_application )
         
     | 
| 
      
 412 
     | 
    
         
            +
                          
         
     | 
| 
      
 413 
     | 
    
         
            +
                      # retrieve application test object xml element
         
     | 
| 
      
 414 
     | 
    
         
            +
                      application_test_object_xml = test_object_adapter.retrieve_parent_application( test_object_xml )
         
     | 
| 
      
 415 
     | 
    
         
            +
             
     | 
| 
      
 416 
     | 
    
         
            +
                      unless application_test_object_xml.nil?
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
                        # retrieve test object id from xml
         
     | 
| 
      
 419 
     | 
    
         
            +
                        object_id = test_object_adapter.test_object_element_attribute( application_test_object_xml, 'id', nil ).to_i
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
                        # retrieve test object name from xml
         
     | 
| 
      
 422 
     | 
    
         
            +
                        object_name = test_object_adapter.test_object_element_attribute( application_test_object_xml, 'name', nil ).to_s
         
     | 
| 
      
 423 
     | 
    
         
            +
             
     | 
| 
      
 424 
     | 
    
         
            +
                        # retrieve test object type from xml
         
     | 
| 
      
 425 
     | 
    
         
            +
                        object_type = test_object_adapter.test_object_element_attribute( application_test_object_xml, 'type', nil ).to_s 
         
     | 
| 
      
 426 
     | 
    
         
            +
                          
         
     | 
| 
      
 427 
     | 
    
         
            +
                        # calculate object cache hash key
         
     | 
| 
      
 428 
     | 
    
         
            +
                        hash_key = test_object_adapter.test_object_hash( object_id, object_type, object_name )
         
     | 
| 
      
 429 
     | 
    
         
            +
                          
         
     | 
| 
      
 430 
     | 
    
         
            +
                        parent_cache = sut.instance_variable_get( :@child_object_cache )                       
         
     | 
| 
      
 431 
     | 
    
         
            +
                        
         
     | 
| 
      
 432 
     | 
    
         
            +
                        # get cached test object from parents child objects cache if found; if not found from cache pass newly created object as is
         
     | 
| 
      
 433 
     | 
    
         
            +
                        if parent_cache.has_object?( hash_key )
         
     | 
| 
      
 434 
     | 
    
         
            +
             
     | 
| 
      
 435 
     | 
    
         
            +
                          rules[ :parent_application ] = parent_cache[ hash_key ]
         
     | 
| 
      
 436 
     | 
    
         
            +
                          
         
     | 
| 
      
 437 
     | 
    
         
            +
                        else
         
     | 
| 
      
 438 
     | 
    
         
            +
                          
         
     | 
| 
      
 439 
     | 
    
         
            +
                          # create application test object            
         
     | 
| 
      
 440 
     | 
    
         
            +
                          rules[ :parent_application ] = make_test_object( 
         
     | 
| 
      
 441 
     | 
    
         
            +
                        
         
     | 
| 
      
 442 
     | 
    
         
            +
                            :parent => sut,          
         
     | 
| 
      
 443 
     | 
    
         
            +
                            :parent_application => nil,
         
     | 
| 
      
 444 
     | 
    
         
            +
                            :xml_object => application_test_object_xml,
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
                            # object identification attributes
         
     | 
| 
      
 447 
     | 
    
         
            +
                            :object_attributes_hash => { :name => object_name, :type => object_type }
         
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
      
 449 
     | 
    
         
            +
                          )
         
     | 
| 
      
 450 
     | 
    
         
            +
                          
         
     | 
| 
      
 451 
     | 
    
         
            +
                        end
         
     | 
| 
      
 452 
     | 
    
         
            +
             
     | 
| 
      
 453 
     | 
    
         
            +
                      else
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
      
 455 
     | 
    
         
            +
                        # could not retrieve parent application object
         
     | 
| 
      
 456 
     | 
    
         
            +
                        rules[ :parent_application ] = nil
         
     | 
| 
      
 457 
     | 
    
         
            +
                      
         
     | 
| 
      
 458 
     | 
    
         
            +
                      end
         
     | 
| 
      
 459 
     | 
    
         
            +
             
     | 
| 
      
 460 
     | 
    
         
            +
                      # store application test object to new test object 
         
     | 
| 
      
 461 
     | 
    
         
            +
                      rules[ :parent_application ].instance_variable_set( :@parent_application, rules[ :parent_application ] )
         
     | 
| 
      
 462 
     | 
    
         
            +
                      
         
     | 
| 
      
 463 
     | 
    
         
            +
                    end
         
     | 
| 
      
 464 
     | 
    
         
            +
                    
         
     | 
| 
      
 465 
     | 
    
         
            +
                    # create new test object
         
     | 
| 
      
 466 
     | 
    
         
            +
                    make_test_object( 
         
     | 
| 
      
 467 
     | 
    
         
            +
                    
         
     | 
| 
      
 468 
     | 
    
         
            +
                      # test objects parent test object
         
     | 
| 
      
 469 
     | 
    
         
            +
                      :parent => rules[ :parent ],
         
     | 
| 
      
 470 
     | 
    
         
            +
             
     | 
| 
      
 471 
     | 
    
         
            +
                      # test objects parent application 
         
     | 
| 
      
 472 
     | 
    
         
            +
                      :parent_application => rules[ :parent_application ],
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
                      # xml element to test object
         
     | 
| 
      
 475 
     | 
    
         
            +
                      :xml_object => test_object_xml,
         
     | 
| 
      
 476 
     | 
    
         
            +
             
     | 
| 
      
 477 
     | 
    
         
            +
                      # object identification attributes
         
     | 
| 
      
 478 
     | 
    
         
            +
                      :object_attributes_hash => object_attributes_hash,
         
     | 
| 
      
 479 
     | 
    
         
            +
             
     | 
| 
      
 480 
     | 
    
         
            +
                      :identification_directives => identification_directives
         
     | 
| 
      
 481 
     | 
    
         
            +
             
     | 
| 
      
 482 
     | 
    
         
            +
                    )
         
     | 
| 
      
 483 
     | 
    
         
            +
                             
         
     | 
| 
      
 484 
     | 
    
         
            +
                  }
         
     | 
| 
      
 485 
     | 
    
         
            +
             
     | 
| 
      
 486 
     | 
    
         
            +
                  # return test object(s); either one or multiple objects
         
     | 
| 
      
 487 
     | 
    
         
            +
                  identification_directives[ :__multiple_objects ] ? child_objects : child_objects.first
         
     | 
| 
      
 488 
     | 
    
         
            +
             
     | 
| 
      
 489 
     | 
    
         
            +
                end
         
     | 
| 
      
 490 
     | 
    
         
            +
             
     | 
| 
      
 491 
     | 
    
         
            +
                # TODO: document me
         
     | 
| 
      
 492 
     | 
    
         
            +
                def self.make_test_object( rules )
         
     | 
| 
      
 493 
     | 
    
         
            +
             
     | 
| 
      
 494 
     | 
    
         
            +
                  # get parent object from hash
         
     | 
| 
      
 495 
     | 
    
         
            +
                  parent = rules[ :parent ]
         
     | 
| 
      
 496 
     | 
    
         
            +
             
     | 
| 
      
 497 
     | 
    
         
            +
                  # retrieve sut object
         
     | 
| 
      
 498 
     | 
    
         
            +
                  sut = parent.instance_variable_get( :@sut )
         
     | 
| 
      
 499 
     | 
    
         
            +
             
     | 
| 
      
 500 
     | 
    
         
            +
                  # retrieve sut objects test object adapter
         
     | 
| 
      
 501 
     | 
    
         
            +
                  #test_object_adapter = sut.instance_variable_get( :@sut_controller ).test_object_adapter
         
     | 
| 
      
 502 
     | 
    
         
            +
                  test_object_adapter = sut.instance_variable_get( :@test_object_adapter )
         
     | 
| 
      
 503 
     | 
    
         
            +
             
     | 
| 
      
 504 
     | 
    
         
            +
                  # retrieve sut objects test object factory
         
     | 
| 
      
 505 
     | 
    
         
            +
                  #test_object_factory = sut.instance_variable_get( :@sut_controller ).test_object_factory
         
     | 
| 
      
 506 
     | 
    
         
            +
                  test_object_factory = sut.instance_variable_get( :@test_object_factory )
         
     | 
| 
      
 507 
     | 
    
         
            +
                  
         
     | 
| 
      
 508 
     | 
    
         
            +
                  # xml object element      
         
     | 
| 
      
 509 
     | 
    
         
            +
                  xml_object = rules[ :xml_object ]
         
     | 
| 
      
 510 
     | 
    
         
            +
             
     | 
| 
      
 511 
     | 
    
         
            +
                  # additional rules, e.g. :__no_caching
         
     | 
| 
      
 512 
     | 
    
         
            +
                  identification_directives = rules[ :identification_directives ] || {}
         
     | 
| 
      
 513 
     | 
    
         
            +
             
     | 
| 
      
 514 
     | 
    
         
            +
                  # retrieve attributes
         
     | 
| 
      
 515 
     | 
    
         
            +
                  #@test_object_adapter.fetch_attributes( xml_object, [ 'id', 'name', 'type', 'env' ], false )
         
     | 
| 
      
 516 
     | 
    
         
            +
             
     | 
| 
      
 517 
     | 
    
         
            +
                  if xml_object.kind_of?( MobyUtil::XML::Element )
         
     | 
| 
      
 518 
     | 
    
         
            +
             
     | 
| 
      
 519 
     | 
    
         
            +
                    # retrieve test object id from xml
         
     | 
| 
      
 520 
     | 
    
         
            +
                    object_id = test_object_adapter.test_object_element_attribute( xml_object, 'id', nil ).to_i
         
     | 
| 
      
 521 
     | 
    
         
            +
             
     | 
| 
      
 522 
     | 
    
         
            +
                    # retrieve test object name from xml
         
     | 
| 
      
 523 
     | 
    
         
            +
                    object_name = test_object_adapter.test_object_element_attribute( xml_object, 'name', nil ).to_s
         
     | 
| 
      
 524 
     | 
    
         
            +
             
     | 
| 
      
 525 
     | 
    
         
            +
                    # retrieve test object type from xml
         
     | 
| 
      
 526 
     | 
    
         
            +
                    object_type = test_object_adapter.test_object_element_attribute( xml_object, 'type', nil ).to_s 
         
     | 
| 
      
 527 
     | 
    
         
            +
             
     | 
| 
      
 528 
     | 
    
         
            +
                    # retrieve test object type from xml
         
     | 
| 
      
 529 
     | 
    
         
            +
                    env = test_object_adapter.test_object_element_attribute( xml_object, 'env' ){ $parameters[ sut.id ][ :env ] }.to_s
         
     | 
| 
      
 530 
     | 
    
         
            +
                    
         
     | 
| 
      
 531 
     | 
    
         
            +
                  else
         
     | 
| 
      
 532 
     | 
    
         
            +
                  
         
     | 
| 
      
 533 
     | 
    
         
            +
                    # defaults - refactor this
         
     | 
| 
      
 534 
     | 
    
         
            +
                    object_type = ""
         
     | 
| 
      
 535 
     | 
    
         
            +
                    
         
     | 
| 
      
 536 
     | 
    
         
            +
                    object_name = ""
         
     | 
| 
      
 537 
     | 
    
         
            +
                    
         
     | 
| 
      
 538 
     | 
    
         
            +
                    object_id = 0
         
     | 
| 
      
 539 
     | 
    
         
            +
             
     | 
| 
      
 540 
     | 
    
         
            +
                    env = $parameters[ sut.id ][ :env ].to_s
         
     | 
| 
      
 541 
     | 
    
         
            +
             
     | 
| 
      
 542 
     | 
    
         
            +
                  end
         
     | 
| 
      
 543 
     | 
    
         
            +
                  
         
     | 
| 
      
 544 
     | 
    
         
            +
                  # calculate object cache hash key
         
     | 
| 
      
 545 
     | 
    
         
            +
                  hash_key = test_object_adapter.test_object_hash( object_id, object_type, object_name )
         
     | 
| 
      
 546 
     | 
    
         
            +
                  
         
     | 
| 
      
 547 
     | 
    
         
            +
                  # get reference to parent objects child objects cache
         
     | 
| 
      
 548 
     | 
    
         
            +
                  parent_cache = rules[ :parent ].instance_variable_get( :@child_object_cache )
         
     | 
| 
      
 549 
     | 
    
         
            +
             
     | 
| 
      
 550 
     | 
    
         
            +
                  # get cached test object from parents child objects cache if found; if not found from cache pass newly created object as is
         
     | 
| 
      
 551 
     | 
    
         
            +
                  if parent_cache.has_object?( hash_key )
         
     | 
| 
      
 552 
     | 
    
         
            +
             
     | 
| 
      
 553 
     | 
    
         
            +
                    # get test object from cache
         
     | 
| 
      
 554 
     | 
    
         
            +
                    test_object = parent_cache[ hash_key ]
         
     | 
| 
      
 555 
     | 
    
         
            +
             
     | 
| 
      
 556 
     | 
    
         
            +
                    # store xml_object to test object
         
     | 
| 
      
 557 
     | 
    
         
            +
                    test_object.xml_data = xml_object
         
     | 
| 
      
 558 
     | 
    
         
            +
             
     | 
| 
      
 559 
     | 
    
         
            +
                    # update test objects creation attributes (either cached object or just newly created child object)
         
     | 
| 
      
 560 
     | 
    
         
            +
                    test_object.instance_variable_get( :@creation_attributes ).merge!( rules[ :object_attributes_hash ] )
         
     | 
| 
      
 561 
     | 
    
         
            +
             
     | 
| 
      
 562 
     | 
    
         
            +
                  else
         
     | 
| 
      
 563 
     | 
    
         
            +
                    
         
     | 
| 
      
 564 
     | 
    
         
            +
                    #trick
         
     | 
| 
      
 565 
     | 
    
         
            +
                    #rules[ :parent_application ] = parent if parent.type == 'vkb'
         
     | 
| 
      
 566 
     | 
    
         
            +
             
     | 
| 
      
 567 
     | 
    
         
            +
                    # create test object
         
     | 
| 
      
 568 
     | 
    
         
            +
                    test_object = MobyBase::TestObject.new( 
         
     | 
| 
      
 569 
     | 
    
         
            +
                    
         
     | 
| 
      
 570 
     | 
    
         
            +
                      :test_object_factory => test_object_factory, #self,
         
     | 
| 
      
 571 
     | 
    
         
            +
                      :test_object_adapter => test_object_adapter, #@test_object_adapter,
         
     | 
| 
      
 572 
     | 
    
         
            +
                      :creation_attributes => rules[ :object_attributes_hash ],
         
     | 
| 
      
 573 
     | 
    
         
            +
                      :xml_object => xml_object,
         
     | 
| 
      
 574 
     | 
    
         
            +
                      :sut => sut, 
         
     | 
| 
      
 575 
     | 
    
         
            +
             
     | 
| 
      
 576 
     | 
    
         
            +
                      # set given parent in rules hash as parent object for new child test object    
         
     | 
| 
      
 577 
     | 
    
         
            +
                      :parent => parent,
         
     | 
| 
      
 578 
     | 
    
         
            +
             
     | 
| 
      
 579 
     | 
    
         
            +
                      # set given application test object in rules hash as parent application for new child test object
         
     | 
| 
      
 580 
     | 
    
         
            +
                      :parent_application => rules[ :parent_application ]
         
     | 
| 
      
 581 
     | 
    
         
            +
             
     | 
| 
      
 582 
     | 
    
         
            +
                    )
         
     | 
| 
      
 583 
     | 
    
         
            +
             
     | 
| 
      
 584 
     | 
    
         
            +
                    # temp. variable for object type
         
     | 
| 
      
 585 
     | 
    
         
            +
                    obj_type = object_type.clone
         
     | 
| 
      
 586 
     | 
    
         
            +
             
     | 
| 
      
 587 
     | 
    
         
            +
                    # apply all test object related behaviours unless object type is 'application'
         
     | 
| 
      
 588 
     | 
    
         
            +
                    obj_type << ';*' unless obj_type == 'application'
         
     | 
| 
      
 589 
     | 
    
         
            +
             
     | 
| 
      
 590 
     | 
    
         
            +
                    # apply behaviours to test object
         
     | 
| 
      
 591 
     | 
    
         
            +
                    TDriver::BehaviourFactory.apply_behaviour(
         
     | 
| 
      
 592 
     | 
    
         
            +
             
     | 
| 
      
 593 
     | 
    
         
            +
                      :object       => test_object,
         
     | 
| 
      
 594 
     | 
    
         
            +
                      :object_type  => [ *obj_type.split(';')       ], 
         
     | 
| 
      
 595 
     | 
    
         
            +
                      :input_type   => [ '*', sut.input.to_s        ],
         
     | 
| 
      
 596 
     | 
    
         
            +
                      :env          => [ '*', *env.to_s.split(";")  ],
         
     | 
| 
      
 597 
     | 
    
         
            +
                      :version      => [ '*', sut.ui_version.to_s   ]
         
     | 
| 
      
 598 
     | 
    
         
            +
             
     | 
| 
      
 599 
     | 
    
         
            +
                    )
         
     | 
| 
      
 600 
     | 
    
         
            +
             
     | 
| 
      
 601 
     | 
    
         
            +
                    # create child accessors
         
     | 
| 
      
 602 
     | 
    
         
            +
                    #test_object_adapter.create_child_accessors!( xml_object, test_object )
         
     | 
| 
      
 603 
     | 
    
         
            +
             
     | 
| 
      
 604 
     | 
    
         
            +
                    # add created test object to parents child objects cache, unless explicitly disabled
         
     | 
| 
      
 605 
     | 
    
         
            +
                    parent_cache.add_object( test_object ) unless identification_directives[ :__no_caching ] == true
         
     | 
| 
      
 606 
     | 
    
         
            +
             
     | 
| 
      
 607 
     | 
    
         
            +
                  end
         
     | 
| 
      
 608 
     | 
    
         
            +
             
     | 
| 
      
 609 
     | 
    
         
            +
                  # NOTE: Do not remove object_type from object attributes hash_rule due to it is used in find_objects service!
         
     | 
| 
      
 610 
     | 
    
         
            +
                  #rules[ :object_attributes_hash ].delete( :type )
         
     | 
| 
      
 611 
     | 
    
         
            +
              
         
     | 
| 
      
 612 
     | 
    
         
            +
                  # do not make test object verifications if we are operating on the sut itself (allow run to pass)
         
     | 
| 
      
 613 
     | 
    
         
            +
                  unless parent.kind_of?( MobyBase::SUT )
         
     | 
| 
      
 614 
     | 
    
         
            +
             
     | 
| 
      
 615 
     | 
    
         
            +
                    # verify ui state if any verifycation blocks given
         
     | 
| 
      
 616 
     | 
    
         
            +
                    TDriver::TestObjectVerification.verify_ui_dump( sut ) unless sut.verify_blocks.empty?
         
     | 
| 
      
 617 
     | 
    
         
            +
             
     | 
| 
      
 618 
     | 
    
         
            +
                  end
         
     | 
| 
      
 619 
     | 
    
         
            +
             
     | 
| 
      
 620 
     | 
    
         
            +
                  # return test object
         
     | 
| 
      
 621 
     | 
    
         
            +
                  test_object
         
     | 
| 
      
 622 
     | 
    
         
            +
             
     | 
| 
      
 623 
     | 
    
         
            +
                end
         
     | 
| 
      
 624 
     | 
    
         
            +
             
     | 
| 
      
 625 
     | 
    
         
            +
                # create test object search parameters for find_objects service
         
     | 
| 
      
 626 
     | 
    
         
            +
                def self.make_object_search_params( test_object, creation_attributes )
         
     | 
| 
      
 627 
     | 
    
         
            +
             
     | 
| 
      
 628 
     | 
    
         
            +
                  result = get_parent_params( test_object ).push( get_object_params( creation_attributes ) )
         
     | 
| 
      
 629 
     | 
    
         
            +
             
     | 
| 
      
 630 
     | 
    
         
            +
                  # TODO: review find_objects controller
         
     | 
| 
      
 631 
     | 
    
         
            +
                  # workaround? return empty hash if no search params were 
         
     | 
| 
      
 632 
     | 
    
         
            +
                  result == [{}] ? {} : result
         
     | 
| 
      
 633 
     | 
    
         
            +
             
     | 
| 
      
 634 
     | 
    
         
            +
                end
         
     | 
| 
      
 635 
     | 
    
         
            +
             
     | 
| 
      
 636 
     | 
    
         
            +
                def self.set_timeout( value )
         
     | 
| 
      
 637 
     | 
    
         
            +
             
     | 
| 
      
 638 
     | 
    
         
            +
                  warn "warning: deprecated method TDriver::TestObjectFactory#set_timeout( value ); please use TDriver::TestObjectFactory#timeout=( value ) instead"
         
     | 
| 
      
 639 
     | 
    
         
            +
             
     | 
| 
      
 640 
     | 
    
         
            +
                  value.check_type( Numeric, "Wrong argument type $1 for timeout value (expected $2)" )
         
     | 
| 
      
 641 
     | 
    
         
            +
             
     | 
| 
      
 642 
     | 
    
         
            +
                  @timeout = value
         
     | 
| 
      
 643 
     | 
    
         
            +
             
     | 
| 
      
 644 
     | 
    
         
            +
                end
         
     | 
| 
      
 645 
     | 
    
         
            +
             
     | 
| 
      
 646 
     | 
    
         
            +
                # Function gets the timeout used in TestObjectFactory
         
     | 
| 
      
 647 
     | 
    
         
            +
                #
         
     | 
| 
      
 648 
     | 
    
         
            +
                # === returns
         
     | 
| 
      
 649 
     | 
    
         
            +
                # Numeric:: Timeout
         
     | 
| 
      
 650 
     | 
    
         
            +
                def self.get_timeout
         
     | 
| 
      
 651 
     | 
    
         
            +
             
     | 
| 
      
 652 
     | 
    
         
            +
                  warn "warning: deprecated method TDriver::TestObjectFactory#get_timeout; please use TDriver::TestObjectFactory#timeout instead"
         
     | 
| 
      
 653 
     | 
    
         
            +
             
     | 
| 
      
 654 
     | 
    
         
            +
                  @timeout
         
     | 
| 
      
 655 
     | 
    
         
            +
             
     | 
| 
      
 656 
     | 
    
         
            +
                end
         
     | 
| 
      
 657 
     | 
    
         
            +
             
     | 
| 
      
 658 
     | 
    
         
            +
                # enable hooking for performance measurement & debug logging
         
     | 
| 
      
 659 
     | 
    
         
            +
                TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
         
     | 
| 
      
 660 
     | 
    
         
            +
             
     | 
| 
      
 661 
     | 
    
         
            +
                # initialize plugin service 
         
     | 
| 
      
 662 
     | 
    
         
            +
                initialize_class
         
     | 
| 
      
 663 
     | 
    
         
            +
              
         
     | 
| 
      
 664 
     | 
    
         
            +
                
         
     | 
| 
      
 665 
     | 
    
         
            +
              end # TestObjectFactory
         
     | 
| 
      
 666 
     | 
    
         
            +
             
     | 
| 
      
 667 
     | 
    
         
            +
            end # TDriver
         
     | 
| 
      
 668 
     | 
    
         
            +
             
     | 
| 
      
 669 
     | 
    
         
            +
            # for backwards compatibility
         
     | 
| 
      
 670 
     | 
    
         
            +
            module MobyBase
         
     | 
| 
      
 671 
     | 
    
         
            +
             
     | 
| 
      
 672 
     | 
    
         
            +
              class TestObjectFactory
         
     | 
| 
      
 673 
     | 
    
         
            +
             
     | 
| 
      
 674 
     | 
    
         
            +
                def self.instance
         
     | 
| 
      
 675 
     | 
    
         
            +
                
         
     | 
| 
      
 676 
     | 
    
         
            +
                  warn_caller '$1:$2 deprecated class MobyBase::TestObjectFactory, please use static class TDriver::TestObjectFactory instead'
         
     | 
| 
      
 677 
     | 
    
         
            +
                
         
     | 
| 
      
 678 
     | 
    
         
            +
                  TDriver::TestObjectFactory
         
     | 
| 
      
 679 
     | 
    
         
            +
                
         
     | 
| 
      
 680 
     | 
    
         
            +
                end
         
     | 
| 
      
 681 
     | 
    
         
            +
             
     | 
| 
      
 682 
     | 
    
         
            +
              end # SUTFactory
         
     | 
| 
      
 683 
     | 
    
         
            +
              
         
     | 
| 
      
 684 
     | 
    
         
            +
            end # MobyBase
         
     |