Inheritance: System.Attribute
Beispiel #1
0
        public void GetBoundingRect1(TestCaseAttribute testAttribute)
        {
            HeaderComment(testAttribute);
            Rect rect;
            Rect parentRect = m_le.Current.BoundingRectangle;

            if (!m_le.Current.IsOffscreen)
            {
                if (parentRect.Width == 0)
                    ThrowMe(CheckType.Verification, "TitleBar Width cannot be zero");

                if (parentRect.Height == 0)
                    ThrowMe(CheckType.Verification, "TitleBar Height cannot be zero");
            }

            foreach (AutomationElement child in m_le.FindAll(TreeScope.Subtree, Condition.TrueCondition))
            {
                rect = child.Current.BoundingRectangle;

                if (rect.Width == 0)
                    ThrowMe(CheckType.Verification, "{0}'s Width cannot be zero", child.Current.Name);

                if (rect.Height == 0)
                    ThrowMe(CheckType.Verification, "{0}'s Height cannot be zero", child.Current.Name);

                if (Rect.Intersect(parentRect, rect) != rect)
                    ThrowMe(CheckType.Verification, "{0}'s BoundingRectangle is not within the parents BoundingRectangle", child.Current.Name);
            }
            
            m_TestStep++;

        }
Beispiel #2
0
        public void NarratorScenario1(TestCaseAttribute testCase)
        {
            HeaderComment(testCase);

            // blah blah blah...

        }
Beispiel #3
0
        /// ---------------------------------------------------------------
        /// <summary>The call will generate the XML log if the logger is
        /// XML </summary>
        /// ---------------------------------------------------------------
        public static void GenerateXMLLog(string filePath)
        {
            String logSaveLocation;

            if (filePath == string.Empty)
            {
                String newLog1 = Path.Combine(Directory.GetCurrentDirectory(), "UIAVerifyLogs"); //Default UIAVerifyLogs Log directory = %Desktop%\UIAVerifyLogs

                String logTimeStamp = String.Format("[{0:yyyy}.{0:mm}.{0:dd}]_({0:HH}.{0:mm}.{0:ss})", DateTime.Now);

                if (!Directory.Exists(newLog1))
                {
                    Directory.CreateDirectory(newLog1);
                }

                //Save file format: UserName_OSVersion_[Year.Month.Day]_(Hour.Minute.Second).xml
                String newLog2 = String.Format("{0}_{1}_{2}.xml", Environment.UserName, Environment.OSVersion.VersionString, logTimeStamp);
                logSaveLocation = Path.Combine(newLog1, newLog2);
            }
            else
            {
                if (Path.GetExtension(filePath).ToLower() == ".xml")
                {
                    logSaveLocation = filePath;
                }
                else
                {
                    logSaveLocation = Path.ChangeExtension(filePath, "xml");
                }
            }
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Indent = true;

            #if NATIVE_UIA
            // Add the machine configuration details as another test
            Microsoft.Test.UIAutomation.TestManager.TestCaseAttribute tca = new Microsoft.Test.UIAutomation.TestManager.TestCaseAttribute("Configuration", TestPriorities.Pri0, Microsoft.Test.UIAutomation.TestManager.TestStatus.Works, "Microsoft Corp.", new string[] { "This test logs Machine Configuration" });
            StringBuilder pathXmlString = new StringBuilder();
            using (XmlWriter xmlConfigLog = XmlTextWriter.Create(pathXmlString))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(QueryString.LogSystemInformationObject.GetType());
                xmlSerializer.Serialize(xmlConfigLog, QueryString.LogSystemInformationObject);
            }
            // Now return only the InnerDocument
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(pathXmlString.ToString());

            StartTest(doc.DocumentElement.FirstChild.Clone(), tca, null);
            LogPass();
            EndTest();
            #endif

            //lets save log file
            _uivLogFile = logSaveLocation;
            using (XmlWriter xmlLogFile = XmlTextWriter.Create(logSaveLocation, writerSettings))
            {
                XmlLog.GetTestRunXml(xmlLogFile);
            }
        }
Beispiel #4
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;
        }
Beispiel #5
0
        /// <summary>
        /// initializes new instance, extracts test priority and test type
        /// </summary>
        public AutomationTest(WUILib.TestCaseAttribute testCaseAttribute, MethodInfo method)
        {
            this.TestCaseAttribute = testCaseAttribute;
            this.Method = method;

            ReadTestPriority();
            ExtractTestType();
        }
Beispiel #6
0
        /// <summary>
        /// initializes new instance, extracts test priority and test type
        /// </summary>
        public AutomationTest(WUILib.TestCaseAttribute testCaseAttribute, MethodInfo method)
        {
            this.TestCaseAttribute = testCaseAttribute;
            this.Method            = method;

            ReadTestPriority();
            ExtractTestType();
        }
Beispiel #7
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;
        }
Beispiel #8
0
 public TestNode(XmlDocument document, int step, string message, string methodName, bool isClientSideProvider, TestCaseAttribute testCaseAttribute, string verificationMethod, string controlPath)
 {
     Document = document;
     Step = step; MethodName = methodName; IsClientSideProvider = isClientSideProvider.ToString().Substring(0, 1).ToUpper();
     Attribute = testCaseAttribute;
     VerificationMethod = verificationMethod;
     ControlPath = controlPath;
     Message = message;
 }
Beispiel #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xmlNodeObjectID">XmlNode that idetifies the object to test.  This can be as simple as the name of the control, to a node that represents the path</param>
        /// <param name="testCaseAttribute"></param>
        /// <param name="methodInfo">MethodInfo of the method of the test</param>
        public StartTestInfo(XmlNode xmlNodeObjectID, TestCaseAttribute testCaseAttribute, MethodInfo methodInfo)
        {
            this.XmlNodeObjectID = xmlNodeObjectID; 
            this.TestAttribute = testCaseAttribute;
            this.MethodInfo = methodInfo;

            StringBuilder possibleIssuesMessageBuilder = new StringBuilder();

            this.PossibleIssuesMessage = possibleIssuesMessageBuilder.ToString();
        }
Beispiel #10
0
        public void Layout1(TestCaseAttribute testCaseAttribute)
        {
            HeaderComment(testCaseAttribute);

            // "Precondition: This is a vertical scrollbar",
            TSC_VerifyPropertyEqual(m_le.GetCurrentPropertyValue(AutomationElement.OrientationProperty), OrientationType.Vertical, AutomationElement.OrientationProperty, CheckType.IncorrectElementConfiguration);

            // "If this is a non Right to Left layout, the bounding rectangle will be on the right side, if Right to Left, bounding rectangle will be on the left side of the parent control",
            TS_VerifyLayout(m_le, CheckType.Verification);
        }
Beispiel #11
0
        public void StaticsDontHaveLabels(TestCaseAttribute testCaseAttribute)
        {
            HeaderComment(testCaseAttribute);

            //"Precondition: Classname is 'Static'",
            TSC_VerifyPropertyEqual(m_le.Current.ClassName.ToLower(), "static", AutomationElement.ClassNameProperty, CheckType.IncorrectElementConfiguration);

            //"Verify: LabeledBy == null",
            TSC_VerifyPropertyEqual(m_le.Current.LabeledBy, null, AutomationElement.LabeledByProperty, CheckType.Verification);

        }
Beispiel #12
0
        public void AccessOneCharacter(TestCaseAttribute testCaseAttribute)
        {
            HeaderComment(testCaseAttribute);

            //"Precondition: There is an access key character",
            TSC_VerifyProperty(m_le.Current.AccessKey.Length, 0, false, AutomationElement.AcceleratorKeyProperty, CheckType.IncorrectElementConfiguration);

            //"Verify: AccessKey length must be one character in length",
            TSC_VerifyProperty(m_le.Current.AccessKey.Length, 1, true, AutomationElement.AcceleratorKeyProperty, CheckType.Verification);

        }
Beispiel #13
0
        public void IsTextPatternAvailableProperty1(TestCaseAttribute testCaseAttribute)
        {
            HeaderComment(testCaseAttribute);

            // "Precondition: Element has a valid hwnd",
            TSC_VerifyProperty(m_le.Current.NativeWindowHandle, 0, false, AutomationElement.NativeWindowHandleProperty, CheckType.IncorrectElementConfiguration);

            // "Verification: HelpTextProeprty != null",
            TSC_VerifyProperty(m_le.Current.FrameworkId, "Win32", true, AutomationElement.FrameworkIdProperty, CheckType.IncorrectElementConfiguration);

            // "Verification: HelpTextProeprty != \"\"",
            TSC_VerifyPropertyEqual((bool)m_le.GetCurrentPropertyValue(AutomationElement.IsTextPatternAvailableProperty), false, AutomationElement.IsTextPatternAvailableProperty, CheckType.Verification);
        }
Beispiel #14
0
        public void MsaaScenario1(TestCaseAttribute testCase)
        {
            HeaderComment(testCase);
            _errorList = new ArrayList();
            GetProperties(m_le, true, false, "1");
            if (_errorList.Count != 0)
            {
                string error = "";
                foreach (string s in _errorList)
                    error += s + "\n";

                ThrowMe(CheckType.Verification, error);
            }
        }
Beispiel #15
0
        public void TestGridItemContainingGridPropertyS11(TestCaseAttribute checkType)
        {
            HeaderComment(checkType);
            AutomationElement grid1 = null;
            AutomationElement grid2 = null;

            //"Step: Traverse up the tree to find a AutomationElement that supports GridPattern",
            TS_GetContainGridByNavigation(m_le, out grid1, CheckType.Verification);

            //"Step: Get the ContainingGrid property",
            TS_GetContainGridByCall(out grid2, CheckType.Verification);

            //"Step: Verify that the two AutomationElements are the same"
            TS_AreTheseTheSame(grid1, grid2, true, CheckType.Verification);
        }
Beispiel #16
0
        public void TestMenuStructureAndNames(TestCaseAttribute testCase, object[] arguments)
        {
            XmlDocument doc = new XmlDocument();

            if (arguments == null)
                throw new ArgumentException();

            string xml = (string)arguments[0];

            //"Step: Load the argument into an XmlDocument",
            TS_LoadMenuDefinition(xml, ref doc, CheckType.Verification);

            //"Verify: That the menu tree matches the XmlDocument tree structure by name"
            TestMenu menuBar = _appCommands.GetIWUIMenuCommands().GetMenuBar().GetFirstSubMenu();
            TS_VerifyXmlToTree(doc.DocumentElement.FirstChild, menuBar);

        }
Beispiel #17
0
        private XmlTestInfo(
            TestCaseAttribute testCaseAttribute, 
            MethodInfo methodInfo,
            XmlNode xmlElementPathNode)
        {
            this.Name = testCaseAttribute.TestName;
            this.Summary = testCaseAttribute.TestSummary;
            this.Priority = testCaseAttribute.Priority.ToString();
            this.Status = testCaseAttribute.Status.ToString();
            this.Author = testCaseAttribute.Author;
            this.TestCaseType = testCaseAttribute.TestCaseType.ToString();
            this.Description = testCaseAttribute.Description;
            
            if (methodInfo != null)
            {
                this.MethodInfo.AssemblyFile = methodInfo.DeclaringType.Assembly.FullName;
                this.MethodInfo.Class = methodInfo.DeclaringType.FullName;
                this.MethodInfo.Method = methodInfo.Name;
            }

            this.ElementInfo = new XmlTestElementInfo(xmlElementPathNode); 
        }
Beispiel #18
0
        public void TstWindowClosedEvent1(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");

            string appPath = (string)arguments[0];

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            // "Step: Add WindowClosedEvent listener for application",
            TSC_AddEventListener(m_le, WindowPattern.WindowClosedEvent, TreeScope.Element, CheckType.Verification);

            // "Step: Close the aplication",
            TS_CloseWindow(m_le, CheckType.Verification);

            // "Step: Wait for one event to occur",
            TSC_WaitForEvents(5);

            // "Verify: That the WindowClosedEvent is fired for the application"
            TSC_VerifyEventListener(null, WindowPattern.WindowClosedEvent, EventFired.True, CheckType.Verification);

        }
Beispiel #19
0
        public void TstBoundingRectangleEvent2(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");

            string appPath = (string)arguments[0];

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(System.IO.Directory.GetCurrentDirectory() + @"\" + appPath, null, CheckType.Verification);

            // "Step: Add BoundingRectangleProperty listener for application",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);

            // "Minimize Ctrltest
            TS_SetWindowVisualState(m_le, WindowVisualState.Minimized, CheckType.Verification);

            // "Step: Wait for one event to occur
            TSC_WaitForEvents(1);

            // "Verify: That the BoundingRectangleProperty event is fired for the application"
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.True }, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);

            // "Close Application",
            TS_CloseWindow(m_le, CheckType.Verification);

        }
Beispiel #20
0
        public void TstBoundingRectangleEvent1(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");

            Exception cachedException = null;
            string appPath = (string)arguments[0];

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(System.IO.Directory.GetCurrentDirectory() + @"\" + appPath, null, CheckType.Verification);

            // "Step: Resize the application to a known size",
            TS_ResizeWindow(m_le, 100, 100, CheckType.IncorrectElementConfiguration);

            try
            {
                // "Step: Add BoundingRectangleProperty listener for application",
                TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);

                // "Resize Ctrltest
                TS_ResizeWindow(m_le, 300, 300, CheckType.Verification);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(1);

                // "Verify: That the BoundingRectangleProperty event is fired for the application"
                TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.True }, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Close Application",
                TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #21
0
        public void TstToolTipClosedEvent1(TestCaseAttribute testCase)
        {
            HeaderComment(testCase);
            AutomationElement tooltip = null;
            Exception errorThrown = null;
            try
            {

                // "Step: Move mouse 
                ATGTestInput.Input.MoveTo(new Point(500, 500)); m_TestStep++;

                // "Step: Get the Start menu button",
                TS_GetStartMenuButton(ref m_le, CheckType.Verification);

                // Precondition: Verify that the start menu is visible",
                TSC_VerifyPropertyEqual(m_le.Current.IsOffscreen, false, AutomationElement.IsOffscreenProperty, CheckType.IncorrectElementConfiguration);

                // "Step: Add WindowOpenedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, AutomationElement.ToolTipOpenedEvent, TreeScope.Subtree, CheckType.Verification);

                // "Step: Add ToolTipClosedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, AutomationElement.ToolTipClosedEvent, TreeScope.Element | TreeScope.Subtree, CheckType.Verification);

                Thread.Sleep(1000);

                // "Step: Move the mouse to the middle of the Start menu button so that an AutomationElement.ToolTipOpenedEvent is fired",
                TS_MoveTo(m_le, CheckType.Verification);

                // "Step: Find the corrent tooltip",
                // Sometimes the tooltip won't come up so if this happens, just bail for now and catch it the next time we run
                TS_ToolTipCurrentlyOpened(TreeWalker.ControlViewWalker.GetParent(m_le), ref m_le, CheckType.IncorrectElementConfiguration);

                // "Step: Move mouse to the 256,0, so that ToolTipClosedEvent can be fired.
                ATGTestInput.Input.MoveTo(new Point(256, 256)); m_TestStep++;

                // "Step: Wait for one event to occur
                //waiting for 5 seconds here because that's how long it takes for tooltipevents to propagate.
                TSC_WaitForEvents(5);

                // "Verify: That the ToolTipOpenedEvent is fired for the application"
                TSC_VerifyEventListener(m_le, AutomationElement.ToolTipOpenedEvent, EventFired.True, CheckType.Verification);

                // "Verify: That the ToolTipClosedEvent is fired for the application"
                TSC_VerifyEventListener(tooltip, AutomationElement.ToolTipClosedEvent, EventFired.True, CheckType.Verification);

            }
            catch (Exception error)
            {
                errorThrown = error;
            }
            finally
            {
                // Precondition: Remove all listeners
                TS_RemoveAllListeners(CheckType.Verification);

                if (errorThrown != null)
                {
                    throw errorThrown;
                }
            }
        }
Beispiel #22
0
        public void TstMenuClosedEvent1(TestCaseAttribute testCase, object[] arguments)
        {
            //TODO: this case passes, but it crashes the application, looks like there is a UIA bug, that when
            //it's monitoring the MenuClosedEvent, it crashes when an event takes place.
            //bug filed: 1286276 
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");
            string appPath = (string)arguments[0];
            Exception cachedException = null;

            AutomationElement menu = null;

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            try
            {
                // "Step: Add WindowOpenedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, AutomationElement.MenuClosedEvent, TreeScope.Element, CheckType.Verification);

                // "Step: Get the menu",
                TS_GetMenu(MENU_FILE, m_le, out menu, CheckType.Verification);

                // "Step: Expand the menu",
                TS_ExpandMenu(menu, CheckType.Verification);

                // "Step: Collapse the menu",
                TS_CollapseMenu(menu, CheckType.Verification);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(1);

                // "Verify: WindowOpenedEvent is fired",
                TSC_VerifyEventListener(null, AutomationElement.MenuClosedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Cleanup: Close the application",
                if (m_le != null)
                    TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #23
0
        public void TestTableItemContainingGridPropertyS13(TestCaseAttribute checkType)
        {
            HeaderComment(checkType);
            int col;
            int row;
            AutomationElement cell = null;

            //"Step: Get the AutomationElement's col",
            TS_GetColumn(out col, CheckType.Verification);

            //"Step: Get the AutomationElement's row",
            TS_GetRow(out row, CheckType.Verification);

            //"Step: Add and event listener for ContainingGridProperty property change event",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { TableItemPattern.ContainingGridProperty }, CheckType.Verification);

            //"Step: Call containing table's GetCell(row, col)",
            TS_GetCell(row, col, out cell, CheckType.Verification);

            // "Step: Wait for event to occur",
            TSC_WaitForEvents(1);

            //"Step: Verify that listener for ContainingGridProperty property change event did not fire",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.False }, new AutomationProperty[] { TableItemPattern.ContainingGridProperty }, CheckType.Verification);

            //"Step: Verify that AutomationElement and one from GetCell() are the same"
            TS_AreTheseTheSame(m_le, cell, true, CheckType.Verification);
        }
Beispiel #24
0
        public void TstMenuOpenedEvent1(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");
            string appPath = (string)arguments[0];
            
            AutomationElement fileMenuElement = null;
            Exception cachedException = null; 

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            try
            {
                // "Step: Add WindowOpenedEvent listener for application",
                TSC_AddEventListener(m_le, AutomationElement.MenuOpenedEvent, TreeScope.Subtree, CheckType.Verification);

                // "Find the FileMenu and then expand it.",
                TS_GetMenu(MENU_FILE, m_le, out fileMenuElement, CheckType.Verification);

                // "Step: Expand the 'File' menu",
                TS_ExpandCollapsePatternExpand(fileMenuElement, CheckType.Verification);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(2);

                // "Verify: That the WindowOpenedEvent is fired for the application"
                // Getting First Child of the FileMenuElement, because that's the source of the event
                TSC_VerifyEventListener(TreeWalker.ControlViewWalker.GetFirstChild(fileMenuElement), AutomationElement.MenuOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Close the application"
                if (m_le != null)
                    TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #25
0
        public void TstWindowOpenedEvent3(TestCaseAttribute testCase)
        {
            AutomationElement dialog = null;
            Exception cachedException = null;

            HeaderComment(testCase);

            try
            {
                // "Step: Add WindowOpenedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, WindowPattern.WindowOpenedEvent, TreeScope.Subtree | TreeScope.Element, CheckType.Verification);

                // "Step: Open Run Dialog",
                TS_OpenRunDialog(out dialog, CheckType.Verification);

                // "Step: Wait for one event to occur",
                TSC_WaitForEvents(1);

                //"Verify: WindowPattern.WindowOpenedEvent is fired",
                TSC_VerifyEventListener(dialog, WindowPattern.WindowOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Step: Press ESC to dismiss the window",
                if (dialog != null)
                    TS_PressKeys(true, Key.Escape);

                if (cachedException != null)
                    throw (cachedException);
            }
        }
Beispiel #26
0
        public void TstWindowOpenedEvent2(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");
            string appPath = (string)arguments[0];

            AutomationElement menu = null;
            AutomationElement dialog = null;
            Exception cachedException = null;

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            try
            {
                // "Step: Get the 'Format' menu item
                TS_GetMenu(MENU_FORMAT, m_le, out menu, CheckType.Verification);

                // "Step: Expand the Format menu",
                TS_ExpandCollapsePatternExpand(menu, CheckType.Verification);

                // "Step: Get the 'Font..' menu item
                TS_GetMenu(MENU_FONT, menu, out menu, CheckType.Verification);

                // "Step: Add WindowOpenedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, WindowPattern.WindowOpenedEvent, TreeScope.Subtree, CheckType.Verification);

                // "Step: Invoke the font dialog in notepad.exe 
                TS_InvokePatternInvoke(menu, CheckType.Verification);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(1);

                // "Step: Find the automationelement for the font dialog"
                TS_FindDialog(m_le, out dialog, CheckType.Verification);

                // "Verify: WindowOpenedEvent is fired",
                TSC_VerifyEventListener(dialog, WindowPattern.WindowOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Step: Close the Font dialog
                if (dialog != null)
                    TS_CloseWindow(dialog, CheckType.Verification);

                // "Cleanup: Close the application",
                if (m_le != null)
                    TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #27
0
        public void TstWindowOpenEvent1(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");

            Exception cachedException = null;

            string appPath = (string)arguments[0];

            HeaderComment(testCase);

            // "Step: Add WindowOpenedEvent listener for application",
            TSC_AddEventListener(AutomationElement.RootElement, WindowPattern.WindowOpenedEvent, TreeScope.Children, CheckType.Verification);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            try
            {
                // "Step: Wait for one event to occur
                TSC_WaitForEvents(2);

                // "Verify: That the WindowOpenedEvent is fired for the application"
                TSC_VerifyEventListener(m_le, WindowPattern.WindowOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Cleanup: Close the application",
                TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #28
0
        public void TstWindowClosedEvent2(TestCaseAttribute testCase)
        {
            AutomationElement runDialog;
            HeaderComment(testCase);

            // "Step: Open run dialog",
            TS_OpenRunDialog(out runDialog, CheckType.Verification);

            // "Step: Add WindowClosedEvent listener for application",
            TSC_AddEventListener(runDialog, WindowPattern.WindowClosedEvent, TreeScope.Element, CheckType.Verification);

            // "Step: Press ESC to dismiss the window",
            TS_PressKeys(true, Key.Escape);

            // "Step: Wait for one event to occur",
            TSC_WaitForEvents(1);

            // "Verify: That the WindowClosedEvent is fired for the application"
            TSC_VerifyEventListener(null, WindowPattern.WindowClosedEvent, EventFired.True, CheckType.Verification);
        }
Beispiel #29
0
        public void TestTableItemColumnPropertyS41(TestCaseAttribute checkType, object args)
        {
            HeaderComment(checkType);

            if (args == null)
                throw new ArgumentException();

            if (!args.GetType().Equals(typeof(int)))
                ThrowMe(CheckType.Verification, "Invalid argument type");

            if (!m_pattern.Current.ColumnSpan.Equals(Convert.ToInt32(args, CultureInfo.CurrentUICulture)))
                ThrowMe(CheckType.Verification, "ColumnSpan returned " + m_pattern.Current.ColumnSpan);
        }
Beispiel #30
0
        public void TstMenuOpenedEvent2(TestCaseAttribute testCase)
        {
            Exception cachedException = null;

            HeaderComment(testCase);

            // "Step: Get the Start menu button",
            TS_GetStartMenuButton(ref m_le, CheckType.Verification);

            // Precondition: Verify that the start menu is visible",
            TSC_VerifyPropertyEqual(m_le.Current.IsOffscreen, false, AutomationElement.IsOffscreenProperty, CheckType.IncorrectElementConfiguration);

            // "Step: Add MenuOpenedEvent listener for start button",
            TSC_AddEventListener(AutomationElement.RootElement, AutomationElement.MenuOpenedEvent, TreeScope.Element | TreeScope.Subtree, CheckType.Verification);

            try
            {
                // "Step: Invoke the Start Button",
                TS_InvokePatternInvoke(m_le, CheckType.Verification);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(1);

                // "Verify: That the WindowOpenedEvent is fired for the application"
                TSC_VerifyEventListener(TreeWalker.ControlViewWalker.GetFirstChild(TreeWalker.ControlViewWalker.GetParent(m_le)), AutomationElement.MenuOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {
                // "Step: Press ESC to close the Start Menu"
                TS_PressKeys(true, Key.Escape);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #31
0
        /// <summary>
        /// this method creates the cache of all available automation tests.
        /// </summary>
        private static void PrepareTestCollection()
        {
            if (AutomationTestCollection._allTestsCache != null)
            {
                return;
            }

            //create the cache, expect 1500 tests
            AutomationTestCollection._allTestsCache = new List <AutomationTest>(1500);

            //this is unfortunately hard coded
            Assembly testAssembly = null;

            try
            {
                testAssembly = Assembly.Load(WUITestLibratyAssemblyName);
            }
            catch (Exception ex)
            {
                string message = "Cannon load assembly " + WUITestLibratyAssemblyName + " with automation tests.\n" +
                                 "There will be no tests to run!";

                MessageBox.Show(message);

                Trace.Fail(message, ex.Message);
            }

            if (testAssembly != null)
            {
                Type[] mytypes = testAssembly.GetTypes();

                //go thru all types in library
                foreach (Type type in mytypes)
                {
                    //if the type has this field the assume this is the test class
                    FieldInfo suite = type.GetField("TestSuite");

                    if (suite != null)
                    {
                        string TestSuite = suite.GetValue(null) as string;

                        if (!string.IsNullOrEmpty(TestSuite))
                        {
                            //go thru all methods and if it has TestCaseAttribute then it is test method
                            foreach (MethodInfo method in type.GetMethods())
                            {
                                foreach (Attribute attr in method.GetCustomAttributes(true))
                                {
                                    if (attr is WUILib.TestCaseAttribute)
                                    {
                                        WUILib.TestCaseAttribute test = (WUILib.TestCaseAttribute)attr;

                                        if (test.Status == WUILib.TestStatus.Works &&
                                            (test.TestCaseType & WUILib.TestCaseType.Arguments) != WUILib.TestCaseType.Arguments)
                                        {
                                            //TODO: sort items
                                            _allTestsCache.Add(new AutomationTest(test, method));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #32
0
        public void TstMenuOpenedEvent3(TestCaseAttribute testCase, object[] arguments)
        {
            Library.ValidateArgumentNonNull(testCase, "testCase");
            Library.ValidateArgumentNonNull(arguments, "arguments");
            Library.ValidateArgumentNonNull(arguments[0], "arguments[0]");
            string appPath = (string)arguments[0];

            Exception cachedException = null;
            AutomationElement menu = null;

            HeaderComment(testCase);

            // "Step: Start the application",
            TS_OpenWindow(appPath, null, CheckType.Verification);

            try
            {
                // "Step: Add MenuOpenedEvent listener for application",
                TSC_AddEventListener(AutomationElement.RootElement, AutomationElement.MenuOpenedEvent, TreeScope.Subtree, CheckType.Verification);

                // "Step: Invoke the font dialog in notepad.exe by using the keys Alt, O
                TS_PressKeys(true, Key.LeftAlt, Key.O);

                // "Step: Wait for one event to occur
                TSC_WaitForEvents(1);

                // "Step: Get the format menu",
                TS_GetMenu(MENU_FORMAT, m_le, out menu, CheckType.Verification);

                // "Verify: That the MenuOpenedEvent is fired for the application"
                TSC_VerifyEventListener(TreeWalker.ControlViewWalker.GetFirstChild(menu), AutomationElement.MenuOpenedEvent, EventFired.True, CheckType.Verification);
            }
            catch (Exception error)
            {
                cachedException = error;
            }
            finally
            {

                // "Step: Press ESC to remove focus from the menu
                TS_PressKeys(true, Key.Escape);

                // "Cleanup: Close the application",
                if (m_le != null)
                    TS_CloseWindow(m_le, CheckType.Verification);

                if (cachedException != null)
                    throw cachedException;
            }
        }
Beispiel #33
0
        public void GetRowNumber(TestCaseAttribute testCaseAtrribute)
        {
            HeaderComment(testCaseAtrribute);
            int retrievedRowNum;
            //"Step: Get the AutomationElement's row",
            TS_GetRow(out retrievedRowNum, CheckType.Verification);

            Comment("Row Number is {0}", retrievedRowNum);
            if (retrievedRowNum < 0)
            {
                ThrowMe(CheckType.Verification, "{0} :  negative value returned for Row number on the Table Item", retrievedRowNum);
            }
        }
Beispiel #34
0
 public void GetRowHeaderItems(TestCaseAttribute testCaseAtrribute)
 {
     HeaderComment(testCaseAtrribute);
     AutomationElement[] tableRowHeaderItems;
     TS_GetRowHeaderItems(out tableRowHeaderItems, CheckType.Verification);
     Comment("Number of RowHeaderItems: {0}", tableRowHeaderItems.Length);
     if (tableRowHeaderItems.Length < 0)
     {
         ThrowMe(CheckType.Verification, "{0} :  negative value returned for RowHeaders", tableRowHeaderItems.Length);
     }
     foreach (AutomationElement header in tableRowHeaderItems)
     {
         if (header.Current.ControlType == ControlType.HeaderItem)
         {
             Comment("Header Control Type verified for Row Header: {0}", header.Current.Name);
         }
         else
         {
             ThrowMe(CheckType.Verification, "{0} :  Control Type on Row Header", header.Current.ControlType, header.Current.Name);
         }
     }
 }