/// <summary>
        /// returns user friendly name for testPriority
        /// </summary>
        /// <param name="testPriority"></param>
        /// <returns></returns>
        private string GetPriorityName(TestPriorities testPriority)
        {
            string name;

            switch (testPriority)
            {
            case TestPriorities.BuildVerificationTests: name = "Build Verification Tests"; break;

            case TestPriorities.Priority0Tests: name = "Priority 0 Tests"; break;

            case TestPriorities.Priority1Tests: name = "Priority 1 Tests"; break;

            case TestPriorities.Priority2Tests: name = "Priority 2 Tests"; break;

            case TestPriorities.Priority3Tests: name = "Priority 3 Tests"; break;

            case TestPriorities.OnlyPriorityAllTests: name = "Priority All Tests"; break;

            default:
            {
                Debug.Fail("unexpected TestPriorities value");
                name = Enum.GetName(typeof(TestPriorities), testPriority);
            }
            break;
            }

            return(name);
        }
        /// <summary>
        /// create subtree for parentNode according to the testPriority, testType and testFilter
        /// </summary>
        private void CreateTestPrioritySubtree(TestPriorities testPriority, TestTypes testType, TreeNode parentNode, AutomationTestsFilter testFilter)
        {
            //create node for the priority
            TreeNode priorityNode = new TreeNode(GetPriorityName(testPriority));

            parentNode.Nodes.Add(priorityNode);
            TreeNode currentRootNode = priorityNode;

            //create filter for the priority
            AndFilter priorityFilter = new AndFilter(new TestFilterPriority(testPriority), testFilter);

            //for all filtered available automation tests lets create tree node
            foreach (AutomationTest test in AutomationTestCollection.Filter(priorityFilter))
            {
                //lets make copy ot the test with only TestType and TestPriority belonging to this
                //branch

                AutomationTest testClone = new AutomationTest(test, testPriority, testType);

                TreeNode testNode = new TreeNode(testClone.Name);
                testNode.Tag = testClone;

                currentRootNode.Nodes.Add(testNode);
            }

            //if no child currentTestTypeRootNode was added then remove priority currentTestTypeRootNode
            if (currentRootNode.Nodes.Count == 0)
            {
                currentRootNode.Remove();
            }
        }
Exemple #3
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 internal InvokePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
 {
     Comment("Calling GetPattern(InvokePattern) on " + Library.GetUISpyLook(element));
     m_pattern = (InvokePattern)GetPattern(m_le, m_useCurrent, InvokePattern.Pattern);
 }
Exemple #4
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 internal InvokePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
 {
     Comment("Calling GetPattern(InvokePattern) on " + Library.GetUISpyLook(element));
     m_pattern = (InvokePattern)GetPattern(m_le, m_useCurrent, InvokePattern.Pattern);
 }
Exemple #5
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal ScrollItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            Comment("Creating ScrollItemTests");

            _pattern = (ScrollItemPattern)GetPattern(m_le, m_useCurrent, ScrollItemPattern.Pattern);
            if (_pattern == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.PatternNotSupported + ": ScrollItemPattern");

            // Find the ScrollPattern
            _container = m_le;

            while (_container != null && !(bool)_container.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty))
                _container = TreeWalker.ControlViewWalker.GetParent(_container);

            // Check to see if we actual found the container of the scrollitem
            if (_container == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, "Element does not have a container with ScrollPattern");

            Comment("Found scroll container: " + Library.GetUISpyLook(_container));

            _scrollPattern = (ScrollPattern)_container.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

        }
Exemple #6
0
        /// <summary>
        /// initializes new instance with the testPriority and testType
        /// </summary>
        public AutomationTest(AutomationTest originalTest, TestPriorities testPriority, TestTypes testType)
        {
            this.TestCaseAttribute = originalTest.TestCaseAttribute;
            this.Method            = originalTest.Method;

            this._testPriority = testPriority;
            this._testType     = testType;
        }
        /// <summary>
        /// initializes new instance with the testPriority and testType
        /// </summary>
        public AutomationTest(AutomationTest originalTest, TestPriorities testPriority, TestTypes testType)
        {
            this.TestCaseAttribute = originalTest.TestCaseAttribute;
            this.Method = originalTest.Method;

            this._testPriority = testPriority;
            this._testType = testType;
        }
		/// -------------------------------------------------------------------
		/// <summary></summary>
		/// -------------------------------------------------------------------
		public MultipleViewTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
            :
            base(element, TestSuite, priority, typeOfControl, TypeOfPattern.MultipleView, dirResults, testEvents, commands)
        {
            m_pattern = (MultipleViewPattern)element.GetCurrentPattern(MultipleViewPattern.Pattern);
            if (m_pattern == null)
                throw new Exception(Helpers.PatternNotSupported);
        }
Exemple #9
0
		/// -------------------------------------------------------------------
		/// <summary>
        /// Get the TableItemPattern on the element
        /// </summary>
		/// -------------------------------------------------------------------
		public TableItemTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
            :
            base(element, TestSuite, priority, typeOfControl, TypeOfPattern.TableItem, dirResults, testEvents, commands)
        {
            m_pattern = (TableItemPattern)GetPattern(m_le, m_useCurrent, TableItemPattern.Pattern);
            if (m_pattern == null)
                throw new Exception(Helpers.PatternNotSupported);
        }
Exemple #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="TestName"></param>
 /// <param name="priority"></param>
 /// <param name="TestStatus"></param>
 /// <param name="Author"></param>
 /// <param name="Description"></param>
 public TestCaseAttribute(string TestName, TestPriorities priority, TestStatus TestStatus, string Author, string[] Description)
 {
     _testName    = TestName;
     status       = TestStatus;
     _description = Description;
     priority     = Priority;
     _author      = Author;
 }
Exemple #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="TestSummary"></param>
 /// <param name="TestName"></param>
 /// <param name="priority"></param>
 /// <param name="TestStatus"></param>
 /// <param name="Author"></param>
 /// <param name="Description"></param>
 public TestCaseAttribute(string testSummary, string testName, TestPriorities _priority, TestStatus TestStatus, string Author, string[] Description)
 {
     _testSummary = testSummary;
     _testName    = testName;
     Status       = TestStatus;
     _description = Description;
     _priority    = Priority;
     _author      = Author;
 }
Exemple #12
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        protected TogglePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (TogglePattern)element.GetCurrentPattern(TogglePattern.Pattern);

            if (_pattern == null)
                throw new Exception("TogglePattern: " + Helpers.PatternNotSupported);
        }
Exemple #13
0
        bool _Contiguous; //calendar only accept contigious selection

        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal SelectionPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (SelectionPattern)GetPattern(m_le, m_useCurrent, SelectionPattern.Pattern);

            ControlType ct = m_le.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType;
            _Contiguous = ct == ControlType.Calendar;
        }
Exemple #14
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public InvokeTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Invoke, dirResults, testEvents, commands)
 {
     if (m_pattern == null)
     {
         throw new Exception(Helpers.PatternNotSupported);
     }
 }
Exemple #15
0
 public Test(MyDictionary dictionary, TestTimings timing, TestPriorities priority, int WordCount)
 {
     this._dictionary = dictionary;
     this.timing = timing;
     this.priority = priority;
     this.wordCount = WordCount;
     this.selectedWords = new List<Word>();
     this.wrongWords = new List<Word>();
     this.CurrentPart = null;
 }
Exemple #16
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public MultipleViewTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.MultipleView, dirResults, testEvents, commands)
 {
     m_pattern = (MultipleViewPattern)element.GetCurrentPattern(MultipleViewPattern.Pattern);
     if (m_pattern == null)
     {
         throw new Exception(Helpers.PatternNotSupported);
     }
 }
Exemple #17
0
 /// -------------------------------------------------------------------
 /// <summary>
 /// Get the tablepattern on the element
 /// </summary>
 /// -------------------------------------------------------------------
 public TableTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Table, dirResults, testEvents, commands)
 {
     m_pattern = (TablePattern)GetPattern(m_le, m_useCurrent, TablePattern.Pattern);
     if (m_pattern == null)
     {
         throw new Exception(Helpers.PatternNotSupported);
     }
 }
Exemple #18
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        protected TogglePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (TogglePattern)element.GetCurrentPattern(TogglePattern.Pattern);

            if (_pattern == null)
            {
                throw new Exception("TogglePattern: " + Helpers.PatternNotSupported);
            }
        }
Exemple #19
0
 public TextScenarioTests(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
     try
     {
         _tth = new TextTestsHelper(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);
     }
     catch( Exception ex )
     {
         supportsText = false;
         Comment("Unknown exception raised: " + ex.ToString() );
     }
     _NotifiedEvent = new System.Threading.ManualResetEvent(false);
 }
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal SelectionItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (SelectionItemPattern)GetPattern(m_le, m_useCurrent, SelectionItemPattern.Pattern);
            if (_pattern == null)
                throw new Exception(Helpers.PatternNotSupported + ": SelectionItemPattern");

            _selectionContainer = _pattern.Current.SelectionContainer;

            if (_selectionContainer != null)
            {
                _selectionPattern = _selectionContainer.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
                if (_selectionPattern == null)
                    throw new ArgumentException("Could not find the SelectionContainer's SelectionPattern");
            }

        }
Exemple #21
0
        ///  ------------------------------------------------------------------
        /// <summary>
        /// Run all the tests for patterns, control type, and AutomationElement that meet the criteria as supplied as arguments
        /// </summary>
        /// <returns></returns>
        ///  ------------------------------------------------------------------
        public static bool RunAllTests(AutomationElement element, bool testEvents, TestPriorities priority, TestCaseType testCaseType, bool testChildren, bool normalize, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    passed &= RunAllControlTests(element, testEvents, priority, testCaseType, testChildren, normalize, commands);
                    passed &= RunAutomationElementTests(element, testEvents, priority, testCaseType, testChildren, normalize, commands);
                    passed &= RunAllPatternTests(element, testEvents, priority, testCaseType, testChildren, normalize, commands);
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }
            return(passed);
        }
Exemple #22
0
        internal TextWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            if (m_le == null)
                throw new ArgumentException("m_le cannot be null");

            _pattern = (TextPattern)m_le.GetCurrentPattern(TextPattern.Pattern);
            _frameworkId = ((string)m_le.GetCurrentPropertyValue(AutomationElement.FrameworkIdProperty)).ToLower(CultureInfo.InvariantCulture);
            _testPriority = TestPriorities.BuildVerificationTest; // default value

            // Determine if tests currently running on Windows Vista
            NativeMethods.OSVERSIONINFOEX ver = new NativeMethods.OSVERSIONINFOEX();
            UnsafeNativeMethods.GetVersionEx(ver);
            if (ver.majorVersion >= 6) // This should account for Windows Vista + Service Packs
                _windowsVista = true;   // It may also occur for Vienna, but the expectation is things
            else                        // could change so much post-Vista, that TextPattern tests will
                _windowsVista = false;  // have to be revisited anyway ((i.e. we will likely be moving to un-managed client)

            Comment("Operating System Version = " + ver.majorVersion + "." + ver.minorVersion + "." + ver.buildNumber);
        }
Exemple #23
0
        private void testPrioritiesToolStrip_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem senderMenu = (ToolStripMenuItem)sender;

            Debug.Assert(senderMenu.Tag is TestPriorities, "MainWindow design is broken!");
            TestPriorities testPriority = (TestPriorities)senderMenu.Tag;

            TestPriorities newValue = _automationTests.Priorities;

            // remove TestPriorities.PriorityAllTests tests
            newValue &= ~TestPriorities.OnlyPriorityAllTests;

            if (senderMenu.Checked)
            {
                newValue |= testPriority; //add flag
            }
            else
            {
                newValue &= ~testPriority; //remove flag
            }
            _automationTests.Priorities = newValue;
        }
Exemple #24
0
        /// <summary>
        /// This method translates WUILib.TestCaseAttribute.Priority to TestPriority enum value.
        /// </summary>
        private void ReadTestPriority()
        {
            //I have to translate WUILib.TestPriorities to VisulaUIVerify.TestPriorities
            WUILib.TestPriorities          wuiLibTestPriority = this.TestCaseAttribute.Priority;
            VisualUIAVerify.TestPriorities vuiTestPriority    = TestPriorities.None;

            if ((wuiLibTestPriority & WUILib.TestPriorities.BuildVerificationTest) == WUILib.TestPriorities.BuildVerificationTest)
            {
                vuiTestPriority |= TestPriorities.BuildVerificationTests;
            }

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri0) == WUILib.TestPriorities.Pri0)
            {
                vuiTestPriority |= TestPriorities.Priority0Tests;
            }

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri1) == WUILib.TestPriorities.Pri1)
            {
                vuiTestPriority |= TestPriorities.Priority1Tests;
            }

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri2) == WUILib.TestPriorities.Pri2)
            {
                vuiTestPriority |= TestPriorities.Priority2Tests;
            }

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri3) == WUILib.TestPriorities.Pri3)
            {
                vuiTestPriority |= TestPriorities.Priority3Tests;
            }

            if ((wuiLibTestPriority & WUILib.TestPriorities.PriAll) == WUILib.TestPriorities.PriAll)
            {
                vuiTestPriority |= TestPriorities.OnlyPriorityAllTests;
            }

            this._testPriority = vuiTestPriority;
        }
Exemple #25
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        public ScenarioObject(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
		base (element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _testCaseSampleType = TestCaseSampleType.Scenario;
		}
Exemple #26
0
 internal HyperLinkListControlTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, TypeOfControl.HyperLinkListControl, dirResults, testEvents, commands)
 {
 }
Exemple #27
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ScrollTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Scroll, dirResults, testEvents, commands)
 {
     DetermineValidPositions();
 }
Exemple #28
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Set local static avriable for _testPriority for current test/variation
        /// </summary>
        /// -------------------------------------------------------------------
        new internal void HeaderComment(TestCaseAttribute testCaseAttribute)
        {
            _testPriority = testCaseAttribute.Priority;
            _problemDescription = testCaseAttribute.ProblemDescription;

            base.HeaderComment(testCaseAttribute);
        }
Exemple #29
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ToggleTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Toggle, dirResults, testEvents, commands)
 {
 }
		/// -------------------------------------------------------------------
		/// <summary></summary>
		/// -------------------------------------------------------------------
		internal ExpandCollapsePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            m_pattern = (ExpandCollapsePattern)GetPattern(m_le, m_useCurrent, ExpandCollapsePattern.Pattern);
        }
Exemple #31
0
        public TextTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
            : base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Text, dirResults, testEvents, commands)
        {
            if (element == null)
                throw new ArgumentException("element cannot be null");

            _pattern = (TextPattern)element.GetCurrentPattern(TextPattern.Pattern);
        }
Exemple #32
0
        private static bool RunControlTestsOnDescendants(AutomationElement element, bool testEvents, bool testChildren, TestPriorities priority, TestCaseType testCaseType, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    string testSuite  = TestObject.GetTestType(element);
                    object testObject = TestObject.GetControlTestObject(element, testEvents, TestPriorities.PriAll, commands);
                    passed &= ((TestObject)testObject).InvokeTests(testSuite, testCaseType);
                    if (testChildren)
                    {
                        passed &= RunControlTestsOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(element), testEvents, testChildren, priority, testCaseType, commands);
                        passed &= RunControlTestsOnDescendants(TreeWalker.ControlViewWalker.GetNextSibling(element), testEvents, testChildren, priority, testCaseType, commands);
                    }
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }

            return(passed);
        }
        /// <summary>
        /// This method translates WUILib.TestCaseAttribute.Priority to TestPriority enum value.
        /// </summary>
        private void ReadTestPriority()
        {
            //I have to translate WUILib.TestPriorities to VisulaUIVerify.TestPriorities
            WUILib.TestPriorities wuiLibTestPriority = this.TestCaseAttribute.Priority;
            VisualUIAVerify.TestPriorities vuiTestPriority = TestPriorities.None;

            if ((wuiLibTestPriority & WUILib.TestPriorities.BuildVerificationTest) == WUILib.TestPriorities.BuildVerificationTest)
                vuiTestPriority |= TestPriorities.BuildVerificationTests;

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri0) == WUILib.TestPriorities.Pri0)
                vuiTestPriority |= TestPriorities.Priority0Tests;

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri1) == WUILib.TestPriorities.Pri1)
                vuiTestPriority |= TestPriorities.Priority1Tests;

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri2) == WUILib.TestPriorities.Pri2)
                vuiTestPriority |= TestPriorities.Priority2Tests;

            if ((wuiLibTestPriority & WUILib.TestPriorities.Pri3) == WUILib.TestPriorities.Pri3)
                vuiTestPriority |= TestPriorities.Priority3Tests;

            if ((wuiLibTestPriority & WUILib.TestPriorities.PriAll) == WUILib.TestPriorities.PriAll)
                vuiTestPriority |= TestPriorities.OnlyPriorityAllTests;

            this._testPriority = vuiTestPriority;
        }
        /// <summary>
        /// returns user friendly name for testPriority
        /// </summary>
        /// <param name="testPriority"></param>
        /// <returns></returns>
        private string GetPriorityName(TestPriorities testPriority)
        {
            string name;

            switch (testPriority)
            {
                case TestPriorities.BuildVerificationTests: name = "Build Verification Tests"; break;
                case TestPriorities.Priority0Tests: name = "Priority 0 Tests"; break;
                case TestPriorities.Priority1Tests: name = "Priority 1 Tests"; break;
                case TestPriorities.Priority2Tests: name = "Priority 2 Tests"; break;
                case TestPriorities.Priority3Tests: name = "Priority 3 Tests"; break;
                case TestPriorities.OnlyPriorityAllTests: name = "Priority All Tests"; break;

                default:
                    {
                        Debug.Fail("unexpected TestPriorities value");
                        name = Enum.GetName(typeof(TestPriorities), testPriority);
                    }
                    break;
            }

            return name;
        }
Exemple #35
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Run all the tests associated with the defined pattern and that meet
        /// the criteria as supplied as arguments
        /// </summary>
        /// -------------------------------------------------------------------
        public static bool RunPatternTests(AutomationElement element, bool testEvents, TestPriorities priority, TestCaseType testCaseType, string testSuite, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    object testObject = TestObject.GetPatternTestObject(testSuite, element, testEvents, priority, commands);
                    passed &= ((TestObject)testObject).InvokeTests(testSuite, testCaseType);
                }

                catch (Exception exception)
                {
                    if (exception.InnerException != null && !(exception.InnerException is IncorrectElementConfigurationForTestException))
                    {
                        UIVerifyLogger.LogUnexpectedError(exception);
                    }
                }
            }
            return(passed);
        }
Exemple #36
0
		/// -------------------------------------------------------------------
		/// <summary></summary>
		/// -------------------------------------------------------------------
		public ThumbControlTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, IApplicationCommands commands)
            :
        base(element, TestSuite, priority, TypeOfControl.ThumbControl, dirResults, testEvents, commands)
        {
        }
 public TestFilterPriority(TestPriorities testPriority)
 {
     this._testPriority = testPriority;
 }
Exemple #38
0
 /// -------------------------------------------------------------------
 /// <summary>
 /// Constructor
 /// </summary>
 /// -------------------------------------------------------------------
 public TestObject(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
 {
     m_le = element;
     _appCommands = commands;
     m_TestPriority = priority;
     m_TypeOfControl = typeOfControl;
     m_TypeOfPattern = typeOfPattern;
     _testEvents = testEvents;
     _testSuite = testSuite;
     m_TestStep = 0;
     _testCaseAttribute = null;
     TestObject.m_testObject = this;
     #if NATIVE_UIA
     GetGlobalizedQueryString(m_le);
     #endif
 }
 public AvalonTextScenarioTests(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
     _NotifiedEvent = new System.Threading.ManualResetEvent(false);
 }
Exemple #40
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Run all the supported pattern tests associated with the element and that meet
        /// the criteria as supplied as arguments
        /// </summary>
        /// -------------------------------------------------------------------
        public static bool RunAllPatternTests(AutomationElement element, bool testEvents, TestPriorities priority, TestCaseType testCaseType, bool testChildren, bool normalize, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    ArrayList al = Helpers.GetPatternSuitesForAutomationElement(element);

                    foreach (string testSuite in al)
                    {
                        passed &= RunPatternTests(element, testEvents, priority, testCaseType, testSuite, commands);
                    }

                    if (testChildren)
                    {
                        passed &= RunAllPatternTestsOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(element), testEvents, testChildren, priority, normalize, testCaseType, commands);
                    }
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }
            return(passed);
        }
Exemple #41
0
 /// <summary></summary>
 protected WindowPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
 {
     m_pattern = (WindowPattern)GetPattern(m_le, m_useCurrent, WindowPattern.Pattern);
 }
Exemple #42
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Run all control tests, pattern tests, and automation element tests
        /// </summary>
        /// -------------------------------------------------------------------
        public static bool RunAllControlTests(AutomationElement element, bool testEvents, TestPriorities priority, TestCaseType testCaseType, bool testChildren, bool normalize, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    passed &= RunControlTests(element, testEvents, false, priority, testCaseType, commands);

                    if (testChildren)
                    {
                        passed &= RunAllControlTestOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(element), testEvents, testChildren, priority, normalize, testCaseType, commands);
                    }
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }
            return(passed);
        }
Exemple #43
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public SelectionTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Selection, dirResults, testEvents, commands)
 {
 }
Exemple #44
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Run all the AutomationElement tests on the element that meet the
        /// criteria as supplied as arguments
        /// </summary>
        /// -------------------------------------------------------------------
        public static bool RunAutomationElementTests(AutomationElement element, bool testEvents, TestPriorities priority, TestCaseType testCaseType, bool testChildren, bool normalize, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    object test = new AutomationElementTests(element, priority, null, testEvents, TypeOfControl.UnknownControl, commands);

                    passed &= ((TestObject)test).InvokeTests(AutomationElementTests.TestSuite, testCaseType);

                    if (testChildren)
                    {
                        passed &= RunAutomationElementTestsOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(element), testEvents, testChildren, priority, normalize, testCaseType, commands);
                    }
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }
            return(passed);
        }
Exemple #45
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public SliderControlTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, TypeOfControl.SliderControl, dirResults, testEvents, commands)
 {
 }
Exemple #46
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal ScrollItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            Comment("Creating ScrollItemTests");

            _pattern = (ScrollItemPattern)GetPattern(m_le, m_useCurrent, ScrollItemPattern.Pattern);
            if (_pattern == null)
            {
                ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.PatternNotSupported + ": ScrollItemPattern");
            }

            // Find the ScrollPattern
            _container = m_le;

            while (_container != null && !(bool)_container.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty))
            {
                _container = TreeWalker.ControlViewWalker.GetParent(_container);
            }

            // Check to see if we actual found the container of the scrollitem
            if (_container == null)
            {
                ThrowMe(CheckType.IncorrectElementConfiguration, "Element does not have a container with ScrollPattern");
            }

            Comment("Found scroll container: " + Library.GetUISpyLook(_container));

            _scrollPattern = (ScrollPattern)_container.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
        }
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TopLevelEventsScenarioTests(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
 }
 public AvalonTextScenarioTests(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
     _NotifiedEvent = new System.Threading.ManualResetEvent(false);
 }
Exemple #49
0
 /// ---------------------------------------------------------------------------
 /// <summary></summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(TestPriorities value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
 public TestFilterPriority(TestPriorities testPriority)
 {
     this._testPriority = testPriority;
 }
Exemple #51
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Recursively tests the children Logical Elements
        /// </summary>
        /// -------------------------------------------------------------------
        static bool RunAutomationElementTestsOnDescendants(AutomationElement element, bool testEvents, bool testChildren, TestPriorities priority, bool normalize, TestCaseType testCaseType, IApplicationCommands commands)
        {
            bool passed = true;

            if (element != null)
            {
                try
                {
                    AutomationElement     tempLe;
                    ArrayList             list;
                    Hashtable             ht         = GetHashedElements(element);
                    IDictionaryEnumerator enumerator = ht.GetEnumerator();
                    Random rnd = new Random(unchecked ((int)DateTime.Now.Ticks));

                    // Add the nodes to the tree.  Some of the nodes we may want to remove
                    // because of redundancy for specific nodes as defined in the m_Duplicate
                    // ArrayList.
                    while (enumerator.MoveNext())
                    {
                        list = (ArrayList)ht[enumerator.Key];
                        if (normalize && Array.IndexOf(m_Duplicate, enumerator.Key) != -1)
                        {
                            // Remove defined items that we don't want duplicates of
                            tempLe = (AutomationElement)list[rnd.Next(list.Count)];

                            passed &= RunAutomationElementTests(tempLe, testEvents, priority, testCaseType, false, normalize, commands);
                            if (testChildren)
                            {
                                passed &= RunAutomationElementTestsOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(tempLe), testEvents, testChildren, priority, normalize, testCaseType, commands);
                            }
                        }
                        else
                        {
                            // Add everything else whether duplicate or not
                            foreach (AutomationElement el in list)
                            {
                                passed &= RunAutomationElementTests(el, testEvents, priority, testCaseType, false, normalize, commands);
                                if (testChildren)
                                {
                                    passed &= RunAutomationElementTestsOnDescendants(TreeWalker.ControlViewWalker.GetFirstChild(el), testEvents, testChildren, priority, normalize, testCaseType, commands);
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    UIVerifyLogger.LogUnexpectedError(exception);
                }
            }
            return(passed);
        }
        /// <summary>
        /// create subtree for parentNode according to the testPriority, testType and testFilter
        /// </summary>
        private void CreateTestPrioritySubtree(TestPriorities testPriority, TestTypes testType, TreeNode parentNode, AutomationTestsFilter testFilter)
        {
            //create node for the priority
            TreeNode priorityNode = new TreeNode(GetPriorityName(testPriority));
            parentNode.Nodes.Add(priorityNode);
            TreeNode currentRootNode = priorityNode;

            //create filter for the priority
            AndFilter priorityFilter = new AndFilter(new TestFilterPriority(testPriority), testFilter);

            //for all filtered available automation tests lets create tree node
            foreach (AutomationTest test in AutomationTestCollection.Filter(priorityFilter))
            {
                //lets make copy ot the test with only TestType and TestPriority belonging to this
                //branch

                AutomationTest testClone = new AutomationTest(test, testPriority, testType);

                TreeNode testNode = new TreeNode(testClone.Name);
                testNode.Tag = testClone;

                currentRootNode.Nodes.Add(testNode);
            }

            //if no child currentTestTypeRootNode was added then remove priority currentTestTypeRootNode
            if (currentRootNode.Nodes.Count == 0)
                currentRootNode.Remove();
        }
Exemple #53
0
        /// ---------------------------------------------------------------
        /// <summary></summary>
        /// ---------------------------------------------------------------
        internal static object GetScenarioTestObject(string testSuite, AutomationElement element, bool testEvents, TestPriorities priority, IApplicationCommands commands)
        {

            TestType testType = GetTestType(testSuite);

            switch (testType)
            {

                case TestType.MenuScenarioTests:
                    return new MenuScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.NarratorScenarioTests:
                    return new NarratorScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.MsaaScenarioTests:
                    return new MsaaScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.TextScenarioTests:
                    return new TextScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.ScreenReaderScenarioTests:
                    return new ScreenReaderScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.TopLevelEventsScenarioTests:
                    return new TopLevelEventsScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                case TestType.AvalonTextScenarioTests:
                    return new AvalonTextScenarioTests(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands);

                default:
                    throw new Exception("Unhandled TestType(" + testType + ") in GetScenarioTestObject()");
            }
        }
        static internal int[]      _runtimeID    = new int[0]; // Used to identify if we're on some runtime id as previously


        #endregion Member Variables

        #region TextTestsHelper constructor

        ///---------------------------------------------------------------------------
        /// <summary></summary>
        ///---------------------------------------------------------------------------
        public TextTestsHelper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            // Determine what type of provider is being used (useful for things like supported text units, attributes, etc.)
            string FrameworkId = (string)element.GetCurrentPropertyValue(AutomationElement.FrameworkIdProperty);

            Comment("Type of Provider for this target application is : " + FrameworkId);

            TextLibrary.SetProvider(FrameworkId);
            TextLibraryCount.SetProvider(FrameworkId);

            // Instantiate attribute madness table
            attributeMadness = new Hashtable(attributesCount);

            // Defines expected support for attributes.
            attributeMadness.Add(TextPattern.AnimationStyleAttribute, new AttributeMadness(false, true, true));
            attributeMadness.Add(TextPattern.BackgroundColorAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.BulletStyleAttribute, new AttributeMadness(false, true, true));
            attributeMadness.Add(TextPattern.CapStyleAttribute, new AttributeMadness(true, true, true));
            attributeMadness.Add(TextPattern.CultureAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.FontNameAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.FontSizeAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.FontWeightAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.ForegroundColorAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.HorizontalTextAlignmentAttribute, new AttributeMadness(true, true, true));
            attributeMadness.Add(TextPattern.IndentationFirstLineAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.IndentationLeadingAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.IndentationTrailingAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.IsHiddenAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.IsItalicAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.IsReadOnlyAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.IsSubscriptAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.IsSuperscriptAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.MarginBottomAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.MarginLeadingAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.MarginTopAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.MarginTrailingAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.OutlineStylesAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.OverlineColorAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.OverlineStyleAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.StrikethroughColorAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.StrikethroughStyleAttribute, new AttributeMadness(true, true, false));
            attributeMadness.Add(TextPattern.TabsAttribute, new AttributeMadness(false, true, false));
            attributeMadness.Add(TextPattern.TextFlowDirectionsAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.UnderlineColorAttribute, new AttributeMadness(false, false, false));
            attributeMadness.Add(TextPattern.UnderlineStyleAttribute, new AttributeMadness(true, true, false));
        }
Exemple #55
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public MenuScenarioTests(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
 }
Exemple #56
0
        /// ---------------------------------------------------------------
        /// <summary>
        /// Get test object associated with the testSuite namespace
        /// </summary>
        /// ---------------------------------------------------------------
        internal static object GetPatternTestObject(string testSuite, AutomationElement element, bool testEvents, TestPriorities priority, IApplicationCommands commands)
        {
            Type assemblyType = null;
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();

                assemblyType = assembly.GetType(testSuite);
                if (assemblyType == null)
                    throw new Exception("Could not load type \"" + testSuite + "\"");

                return Activator.CreateInstance(assemblyType,
                    new object[] { element, priority, null, testEvents, TypeOfControl.UnknownControl, commands });
            }
            catch (Exception error)
            {
                string s = string.Format("Failed to Activator.CreateInstance({0}) because {1}", assemblyType.Name, error.InnerException.Message);
                throw new Exception(s, error.InnerException);
            }
        }
Exemple #57
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        public PatternObject(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
		base (element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _testCaseSampleType = TestCaseSampleType.Pattern;
        }
Exemple #58
0
        /// ---------------------------------------------------------------
        /// <summary>Get the control test associated with the element's control type</summary>
        /// ---------------------------------------------------------------
        internal static object GetControlTestObject(AutomationElement element, bool testEvents, TestPriorities priority, IApplicationCommands commands)
        {
            ControlType ct = element.Current.ControlType;

            if (ct == null)
                throw new Exception("Could not get a ControlType for the element(" + Library.GetUISpyLook(element) + ") so could not select the correct test");

            Assembly assembly = Assembly.GetExecutingAssembly();

            string testSuite = "Microsoft.Test.UIAutomation.Tests.Controls." + Helpers.GetProgrammaticName(ct) + "ControlTests";
            Type assemblyType = assembly.GetType(testSuite);
            if (assemblyType == null)
                throw new Exception("Could not load type \"" + testSuite + "\"");

            return Activator.CreateInstance(assemblyType,
                new object[] { element, priority, null, testEvents, commands });

        }