示例#1
0
 /// -------------------------------------------------------------------
 /// <summary>Call this to initialize the class so that one can call the
 /// entry points depending on which framework is used</summary>
 /// -------------------------------------------------------------------
 public StressScenarioTests(UIA.AutomationElement element, bool testEvents, bool testChildren, int numThreads, TestLab testLab, IApplicationCommands commands)
     :
     base(element, null, TestPriorities.PriAll, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
     _testChildren = testChildren;
     _numThreads   = numThreads;
     _testLab      = testLab;
     //PopulateAutomationElementProperties(ref _automationProperties, ref _automationPatterns);
 }
示例#2
0
        private void BuildElementTable(UIA.AutomationElement _originalElement)
        {
            Assembly assembly    = Assembly.GetAssembly(typeof(UIA.AutomationElement));
            Assembly curAssembly = Assembly.GetCallingAssembly();

            // Get all patterns currently supported by UIA
            if (_patterns == null)
            {
                _patterns = GetPatternList();
            }

            try
            {
                // Use refelction to build up the list of elements
                foreach (UIA.AutomationElement element in _originalElement.FindAll(UIA.TreeScope.Subtree, UIA.Condition.TrueCondition))
                {
                    // Everything supports the AutomationElement "pattern" so add them
                    // as AutomationStressTests.AutomationElement
                    _contextElements.Add(new AutomationElement(element));

                    // If the AutomationElement supports a specific pattern, then
                    // create an UIAutomationTestTypes based on the specific
                    // pattern that is supported.  If the AutomationElement
                    // supports more than one pattern, then create another
                    // UIAutomationTestTypes of the other patterns and store them
                    // for later retrieval using the GetRandomObjectByType()
                    foreach (string patternName in _patterns)
                    {
                        // Get the particular Is<Pattern>Supported property such as IsScrollPatternSupported
                        FieldInfo fi = assembly.GetType("System.Windows.Automation.AutomationElement").GetField("Is" + patternName + "AvailableProperty");

                        // Use the property to get the actual value of the Is<Pattern>Supported
                        // associated with the specific AutomationElement
                        if ((bool)element.GetCurrentPropertyValue((UIA.AutomationProperty)fi.GetValue(element)))
                        {
                            // If it's not the close button, create the AutomationStressTests.<Pattern> and store
                            // it in the context for later retrieval using GetRandomObjectByType()
                            if (patternName != UIA.InvokePattern.Pattern.ProgrammaticName && element.Current.Name != "Close")
                            {
                                _appCommands.TraceMethod("Creating UIAStressHelpers." + patternName);
                                _contextElements.Add(Activator.CreateInstance(curAssembly.GetType("UIAStressHelpers." + patternName), new object[] { element }));
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException e)
            {
                System.Diagnostics.Debug.Assert(false);
                Console.WriteLine(e.ToString());
            }
        }
示例#3
0
 /// -------------------------------------------------------------------
 /// <summary>Constructor of object to pass to the thread</summary>
 /// -------------------------------------------------------------------
 public PacketInfo(
     UIA.AutomationElement applicationElement,
     UIA.AutomationElement element,
     IApplicationCommands appCommands,
     TestLab testLab,
     int actionCount,
     ArrayList automationProperties,
     ArrayList automationPatterns,
     Scenario scenario)
 {
     _applicationElement   = applicationElement;
     _element              = element;
     _appCommands          = appCommands;
     _testLab              = testLab;
     _actionCount          = actionCount;
     _automationProperties = automationProperties;
     _automationPatterns   = automationPatterns;
     _scenario             = scenario;
     _testLab              = testLab;
 }
示例#4
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TransformPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#5
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TogglePattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#6
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TextPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#7
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public SelectionPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#8
0
 /// -------------------------------------------------------------------
 /// <summary>Constructor of object to pass to the thread</summary>
 /// -------------------------------------------------------------------
 public PacketInfo(
     UIA.AutomationElement applicationElement,
     UIA.AutomationElement element,
     IApplicationCommands appCommands,
     TestLab testLab,
     int actionCount,
     ArrayList automationProperties,
     ArrayList automationPatterns,
     Scenario scenario)
 {
     _applicationElement = applicationElement;
     _element = element;
     _appCommands = appCommands;
     _testLab = testLab;
     _actionCount = actionCount;
     _automationProperties = automationProperties;
     _automationPatterns = automationPatterns;
     _scenario = scenario;
     _testLab = testLab;
 }
示例#9
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public GridPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#10
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ExpandCollapsePattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#11
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public DockPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#12
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public AutomationElement(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#13
0
 public UIAutomationTestTypes(UIA.AutomationElement element)
 {
     _automationElement = element;
 }
示例#14
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ValuePattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#15
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public InvokePattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#16
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public WindowPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#17
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public MultipleViewPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#18
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Main driver code that calls the actual tests.  This method will 
        /// continue call the tests until either the test application has gone 
        /// away, or the thread is aborted.
        /// </summary>
        /// -------------------------------------------------------------------
        StressTestsDrivers(PacketInfo threadInfo)
        {
            //AutomationPattern[] patterns = null;
            PacketInfo ti = (PacketInfo)threadInfo;
            _originalElement = ti.AutomationElement;
            _appCommands = ti.AppCommands;
            _actionCount = ti.ActionCount;
            _applicationElement = ti.ApplicationElement;
            _curElement = _originalElement;
            _automationProperties = ti.AutomationProperties;
            _automationPatterns = ti.AutomationPatterns;
            UIA.AutomationElement element = null;
            MethodInfo method = null;
            ArrayList methodList = null;
            
            // Build the table that will reference all the methods in this assembly 
            // that has a StressBuckets custom attribute defined.
            BuildMethodsTable(ti.TestLab, TestWorks.Stable, ti.Scenario);

            BuildElementTable(_originalElement);

            // Loop and run actions
            for (int actionCount = 0; ; actionCount++)
            {
                try
                {
                    string patternName = string.Empty;

                    // TODO: How to set wieghts?  Currently it is uniform.  Need to make AE run more often.
                    if (_rnd.Next(_patterns.Count + 1) == _patterns.Count)
                    {
                        patternName = "AutomationElement";
                    }
                    else
                    {
                        patternName = (string)_patterns[_rnd.Next(_patterns.Count)];
                    }

                    // Is there a ArrayList of methods associated with the pattern?
                    if (null != (methodList = (ArrayList)(_testMethods[patternName])))
                    {
                        // Find a specific test in the patterns collection...
                        if (null != (method = (MethodInfo)methodList[_rnd.Next(methodList.Count)]))
                        {
                            // If the test has set it;s 
                            if (Stable(method.Name, ti.TestLab))
                            {
                                element = GetRandomObjectByType(patternName);

                                // If we found an element that supports the pattern, then run the test
                                if (null != (element = GetRandomObjectByType(patternName)))
                                {
                                    ti.AppCommands.TraceMethod(method.Name);
#if PENTEST
                                    try
                                    {
#endif
                                        method.Invoke(this, new object[] { element });
#if PENTEST
                                    }
                                    catch (Exception)
                                    {
                                    }
#endif

                                }
                            }
                        }
                    }
                }
                // High level exceptions that can occur everywhere
                catch (ThreadAbortException)
                {
                    return;
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    // Hot key already registered
                }

            }
        }
示例#19
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ScrollPattern(UIA.AutomationElement automationElement) : base(automationElement)
 {
 }
示例#20
0
 public UIAutomationTestTypes(UIA.AutomationElement element)
 {
     _automationElement = element;
 }
示例#21
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Main driver code that calls the actual tests.  This method will
        /// continue call the tests until either the test application has gone
        /// away, or the thread is aborted.
        /// </summary>
        /// -------------------------------------------------------------------
        StressTestsDrivers(PacketInfo threadInfo)
        {
            //AutomationPattern[] patterns = null;
            PacketInfo ti = (PacketInfo)threadInfo;

            _originalElement      = ti.AutomationElement;
            _appCommands          = ti.AppCommands;
            _actionCount          = ti.ActionCount;
            _applicationElement   = ti.ApplicationElement;
            _curElement           = _originalElement;
            _automationProperties = ti.AutomationProperties;
            _automationPatterns   = ti.AutomationPatterns;
            UIA.AutomationElement element    = null;
            MethodInfo            method     = null;
            ArrayList             methodList = null;

            // Build the table that will reference all the methods in this assembly
            // that has a StressBuckets custom attribute defined.
            BuildMethodsTable(ti.TestLab, TestWorks.Stable, ti.Scenario);

            BuildElementTable(_originalElement);

            // Loop and run actions
            for (int actionCount = 0; ; actionCount++)
            {
                try
                {
                    string patternName = string.Empty;

                    // TODO: How to set wieghts?  Currently it is uniform.  Need to make AE run more often.
                    if (_rnd.Next(_patterns.Count + 1) == _patterns.Count)
                    {
                        patternName = "AutomationElement";
                    }
                    else
                    {
                        patternName = (string)_patterns[_rnd.Next(_patterns.Count)];
                    }

                    // Is there a ArrayList of methods associated with the pattern?
                    if (null != (methodList = (ArrayList)(_testMethods[patternName])))
                    {
                        // Find a specific test in the patterns collection...
                        if (null != (method = (MethodInfo)methodList[_rnd.Next(methodList.Count)]))
                        {
                            // If the test has set it;s
                            if (Stable(method.Name, ti.TestLab))
                            {
                                element = GetRandomObjectByType(patternName);

                                // If we found an element that supports the pattern, then run the test
                                if (null != (element = GetRandomObjectByType(patternName)))
                                {
                                    ti.AppCommands.TraceMethod(method.Name);
#if PENTEST
                                    try
                                    {
#endif
                                    method.Invoke(this, new object[] { element });
#if PENTEST
                                }
                                catch (Exception)
                                {
                                }
#endif
                                }
                            }
                        }
                    }
                }
                // High level exceptions that can occur everywhere
                catch (ThreadAbortException)
                {
                    return;
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    // Hot key already registered
                }
            }
        }