Ejemplo n.º 1
0
        public void Value()
        {
            CheckDisposed();
            AccessibilityHelper child = m_ah.FindChild("informationBar", AccessibleRole.None);

            Assert.AreEqual("Information Bar Text", child.Value);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Verifies that each menu item has an accessible name.
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <param name="parent">The parent menu item</param>
        /// <param name="prevMenu">The menu item before this</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int VerifyMenuItemNames(AccessibilityHelper menu, AccessibilityHelper parent,
                                        AccessibilityHelper prevMenu)
        {
            int nErrors = 0;

            if (menu.Role != AccessibleRole.Separator &&
                (menu.Name == null || menu.Name.Length <= 0))
            {
                Console.WriteLine(
                    "Can't get menu name. Parent is '{0}', previous menu item is '{1}'. {2}",
                    parent != null ? parent.Name : "<null>",
                    prevMenu != null ? prevMenu.Name : "<null>",
                    menu.IsRealAccessibleObject && menu.ChildCount > 0 ?
                    "Not testing subitems." : "");
                nErrors++;
            }
            else if (menu.IsRealAccessibleObject)
            {
                AccessibilityHelper prevChild = null;
                foreach (AccessibilityHelper child in menu)
                {
                    nErrors  += VerifyMenuItemNames(child, menu, prevChild);
                    prevChild = child;
                }
            }
            return(nErrors);
        }
Ejemplo n.º 3
0
        public void FindChild()
        {
            CheckDisposed();
            AccessibilityHelper child = m_ah.FindChild("informationBar", AccessibleRole.None);

            Assert.IsNotNull(child);
            Assert.AreEqual("informationBar", child.Name);
            Assert.AreEqual(AccessibleRole.Window, child.Role);

            child = m_ah.FindChild(null, AccessibleRole.Client);
            Assert.IsNotNull(child);
            Assert.AreEqual("dummyTestForm", child.Name);
            Assert.AreEqual(AccessibleRole.Client, child.Role);

            child = m_ah.FindChild("informationBar", AccessibleRole.Window);
            Assert.IsNotNull(child);
            Assert.AreEqual("informationBar", child.Name);
            Assert.AreEqual(AccessibleRole.Window, child.Role);

            child = m_ah.FindChild("draftView", AccessibleRole.Client);
            Assert.IsNotNull(child);
            Assert.AreEqual("draftView", child.Name);
            Assert.AreEqual(AccessibleRole.Client, child.Role);

            child = m_ah.FindChild("NotExistantChild", AccessibleRole.None);
            Assert.IsNull(child);

            child = m_ah.FindChild(null, AccessibleRole.None);
            Assert.IsNull(child);
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loop through all menu items to make sure that they are loaded (some are created
        /// only when they show, but afterwards they still exist).
        /// </summary>
        /// <param name="parent"><see cref="AccessibilityHelper"/> of the main window</param>
        /// ------------------------------------------------------------------------------------
        public void ActivateAllMenuItems(AccessibilityHelper parent)
        {
            CheckDisposed();
            foreach (AccessibilityHelper child in parent)
            {
                if (child.Role == AccessibleRole.MenuBar && child.Name != "System")
                {
                    m_app.SendKeys("%");

                    foreach (AccessibilityHelper menu in child)
                    {
                        Debug.WriteLine("----------------------------------------");
                        Debug.WriteLine(string.Format("Activating main frame menu {0} (Role: {1})",
                                                      menu.Name, menu.Role));
                        if (menu.IsRealAccessibleObject)
                        {
                            m_app.SendKeys("{DOWN}");
                            Debug.WriteLine("{DOWN}");
                            ActivateThisMenu(menu);
                        }

                        Debug.WriteLine("{RIGHT}");
                        m_app.SendKeys("{RIGHT}");
                    }
                    Debug.WriteLine("{ESC}");
                    m_app.SendKeys("{ESC}");
                }
            }
        }
Ejemplo n.º 5
0
 public void AccessibleObjectFromPoint()
 {
     AccessibilityHelper child = m_ah.FindChild("informationBar", AccessibleRole.None);
     Rect rect;
     Win32.GetWindowRect((IntPtr)child.HWnd, out rect);
     Point pt = new Point(rect.left, rect.top);
     AccessibilityHelper test = new AccessibilityHelper(pt);
     Assert.AreEqual(child.HWnd, test.HWnd);
 }
Ejemplo n.º 6
0
		public void Init()
		{
			CheckDisposed();
			m_proc = Process.Start(@"DummyTestExe.exe");
			m_proc.WaitForInputIdle();
			while (Process.GetProcessById(m_proc.Id).MainWindowHandle == IntPtr.Zero)
				Thread.Sleep(100);
			m_proc.WaitForInputIdle();
			Win32.SetForegroundWindow(m_proc.MainWindowHandle);
			m_ah = new AccessibilityHelper(m_proc.MainWindowHandle);
		}
        public void AccessibleObjectFromPoint()
        {
            AccessibilityHelper child = m_ah.FindChild("informationBar", AccessibleRole.None);
            Rect rect;

            Win32.GetWindowRect((IntPtr)child.HWnd, out rect);
            Point pt = new Point(rect.left, rect.top);
            AccessibilityHelper test = new AccessibilityHelper(pt);

            Assert.AreEqual(child.HWnd, test.HWnd);
        }
 public void Init()
 {
     m_proc = Process.Start(@"DummyTestExe.exe");
     m_proc.WaitForInputIdle();
     while (Process.GetProcessById(m_proc.Id).MainWindowHandle == IntPtr.Zero)
     {
         Thread.Sleep(100);
     }
     m_proc.WaitForInputIdle();
     Win32.SetForegroundWindow(m_proc.MainWindowHandle);
     m_ah = new AccessibilityHelper(m_proc.MainWindowHandle);
 }
Ejemplo n.º 9
0
        public void VerifyMenuItemNames()
        {
            int nErrors = 0;
            AccessibilityHelper prevChild = null;

            foreach (AccessibilityHelper child in m_app.MainAccessibilityHelper)
            {
                if (child.Role == AccessibleRole.MenuBar)
                {
                    nErrors  += VerifyMenuItemNames(child, m_app.MainAccessibilityHelper, prevChild);
                    prevChild = child;
                }
            }

            Assert.AreEqual(0, nErrors, string.Format("{0} menu names couldn't be read. " +
                                                      "The other tests will fail. See 'Standard Out' for details.", nErrors));
        }
Ejemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loop through all menu items (and sub-menus) of one menu and check help text in the
        /// status bar.
        /// </summary>
        /// <param name="menuParent">The main frame menu <see cref="AccessibilityHelper"/>, e.g.
        /// for File.</param>
        /// ------------------------------------------------------------------------------------
        protected int CheckStatusbarMenuTexts(AccessibilityHelper menuParent)
        {
            int nErrors = 0;

            // Because we're really opening the menu, we have one additional layer, that is
            // usually not visible (if you inspect it with AccExplorer, e.g): the window.
            // This consists also only of 1 child
            foreach (AccessibilityHelper menuWindow in menuParent)
            {
                // There should be only 1 popup menu for the menuParent...
                foreach (AccessibilityHelper menuPopup in menuWindow)
                {
                    Debug.WriteLine(string.Format("Menu popup {0} (#children: {1}, role: {2})",
                                                  menuPopup.Name, menuPopup.ChildCount, menuPopup.Role));

                    foreach (AccessibilityHelper menuItem in menuPopup)
                    {
                        if (menuItem.Role == AccessibleRole.Separator)
                        {
                            Debug.WriteLine("Separator -------");
                        }
                        else
                        {
                            nErrors += CheckMenuHelp(menuItem.Name);
                            if (menuItem.IsRealAccessibleObject)
                            {
                                Debug.WriteLine(string.Format("Sub Menu {0} (role: {1})",
                                                              menuItem.Name, menuItem.Role));
                                Debug.WriteLine("{RIGHT}");
                                m_app.SendKeys("{RIGHT}");
                                nErrors += CheckStatusbarMenuTexts(menuItem);
                            }
                            else
                            {
                                Debug.WriteLine(string.Format("Menu item {0}", menuItem.Name));
                            }
                            Debug.WriteLine("{DOWN}");
                            m_app.SendKeys("{DOWN}");
                        }
                    }
                }
            }
            Debug.WriteLine("{ESC}");
            m_app.SendKeys("{ESC}");
            return(nErrors);
        }
Ejemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks the menu shortcuts for a particular menu
        /// </summary>
        /// <param name="menu">The menu to test</param>
        /// <param name="shortCuts">All short cuts found so far</param>
        /// <param name="menuNames">All menu names found so far</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuNameShortCutUniqueness(AccessibilityHelper menu,
                                                    Hashtable shortCuts, Hashtable menuNames)
        {
            int nErrors = 0;

            if (menu.Role == AccessibleRole.MenuItem)
            {
                string[] menuNameParts = menu.Name.Split(new char[] { '\t' });
                if (menuNameParts.Length > 1)
                {
                    string shortCut = menuNameParts[menuNameParts.Length - 1];
                    if (!shortCuts.Contains(shortCut))
                    {
                        shortCuts.Add(shortCut, menu.Name);
                    }
                    else
                    {
                        Console.WriteLine("\tThe shortcut '{0}' is used by '{1}' and by '{2}'",
                                          shortCut, shortCuts[shortCut], menu.Name);
                        nErrors++;
                    }
                }

                string name = menuNameParts[0].TrimEnd(new char[] { '.', ' ' });
                if (!menuNames.Contains(name))
                {
                    menuNames.Add(name, menu.Parent.Name);
                }
                else
                {
                    Console.WriteLine("\tThe menu name '{0}' is used by '{1}' and by '{2}'",
                                      name, menu.Parent.Name, menuNames[name]);
                    nErrors++;
                }
            }

            if (menu.IsRealAccessibleObject)
            {
                foreach (AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuNameShortCutUniqueness(child, shortCuts, menuNames);
                }
            }
            return(nErrors);
        }
Ejemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Test the menu capitalization and "Book Title" convention
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuCapitalization(AccessibilityHelper menu)
        {
            int nErrors = 0;

            if (menu.Role != AccessibleRole.Separator && menu.Role != AccessibleRole.MenuPopup &&
                menu.Name != null && menu.Name.Length > 0)
            {
                if (!Char.IsUpper(menu.Name[0]) && !Char.IsDigit(menu.Name[0]))
                {
                    Console.WriteLine("\t'{0}' is not capitalized nor digit", menu.Name);
                    nErrors++;
                }
                String[] menuNameParts = menu.Name.Split(new char[] { ' ' });
                for (int i = 1; i < menuNameParts.Length; i++)
                {
                    if (Char.IsLower(menuNameParts[i][0]))
                    {
                        switch (menuNameParts[i])
                        {
                        case "the":                                 //these are okay
                        case "or":
                        case "and":
                        case "a":
                        case "of":
                        case "in":
                            break;

                        default:                                 // any other lower case is not
                            Console.WriteLine(
                                "\t'{0}' does not follow 'Book Title' convention", menu.Name);
                            nErrors++;
                            break;
                        }
                    }
                }
            }
            if (menu.IsRealAccessibleObject)
            {
                foreach (AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuCapitalization(child);
                }
            }
            return(nErrors);
        }
Ejemplo n.º 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Find the nth child window with the specified name and/or role.
        /// </summary>
        /// <param name="name">Accessibility name of the matching window, or <c>null</c></param>
        /// <param name="role">Accessibility role of the matching window, or
        /// <see cref="AccessibleRole.None"/>.</param>
        /// <param name="nWhich">Number of specified child to find</param>
        /// <param name="nLevelsToRecurse">How much levels to go down. <c>0</c> if you want
        /// to search only in the immediate children.</param>
        /// <returns>A new <see cref="AccessibilityHelper"/> object that wraps the matched
        /// window.</returns>
        /// <remarks>If you provide only one parameter, it matches only that parameter.
        /// If you specify both parameters it tries to match both. </remarks>
        /// ------------------------------------------------------------------------------------
        public AccessibilityHelper FindNthChild(string name, AccessibleRole role, ref int nWhich,
                                                int nLevelsToRecurse)
        {
            if (name == null && role == AccessibleRole.None)
            {
                return(null);
            }

            AccessibilityHelper ah = null;

            foreach (AccessibilityHelper child in this)
            {
                if (child == null)
                {
                    continue;
                }
                // does this object match?
                if ((name == null || name == child.Name) &&
                    (role == AccessibleRole.None || role == child.Role))
                {
                    nWhich--;
                    if (nWhich <= 0)
                    {
                        return(child);
                    }
                }
                if (child.m_fRealAccessibleObject)
                {
                    if (nLevelsToRecurse > 0)
                    {
                        // look through the child objects
                        ah = child.FindNthChild(name, role, ref nWhich, nLevelsToRecurse - 1);
                        if (ah != null)
                        {
                            return(ah);
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 14
0
        public void FindNthChild()
        {
            CheckDisposed();
            Process             proc = m_proc;
            AccessibilityHelper ah   = m_ah;

            // start second instance
            Init();

            // now look for the second instance
            int nWhich = 1;
            AccessibilityHelper first = m_ah.Parent.FindNthChild("dummyTestForm",
                                                                 AccessibleRole.None, ref nWhich, 0);

            nWhich = 2;
            AccessibilityHelper second = m_ah.Parent.FindNthChild("dummyTestForm",
                                                                  AccessibleRole.None, ref nWhich, 0);

            nWhich = 3;
            AccessibilityHelper none = m_ah.Parent.FindNthChild("dummyTestForm",
                                                                AccessibleRole.None, ref nWhich, 0);

            int hwnd1      = m_proc.MainWindowHandle.ToInt32();
            int hwnd2      = proc.MainWindowHandle.ToInt32();
            int foundHwnd1 = first.HWnd;
            int foundHwnd2 = second.HWnd;

            // Close the second instance
            EndTest();

            m_proc = proc;
            m_ah   = ah;

            // now test that we got the right window. Do this after closing the second
            // instance, because if it fails the rest of this method isn't executed
            Assert.AreEqual(hwnd1, foundHwnd1);
            Assert.AreEqual(hwnd2, foundHwnd2);
            Assert.IsTrue(hwnd1 != foundHwnd2);
            Assert.IsNull(none);
        }
Ejemplo n.º 15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Recurse the menus to make sure no menus with sub menus contain trailing ellipses
        /// in the menu text.
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuEllipses(AccessibilityHelper menu)
        {
            int nErrors = 0;

            if (menu.Role == AccessibleRole.MenuPopup)
            {
                if (menu.Name.Trim().EndsWith("..."))
                {
                    Console.WriteLine("\tSub menu '{0}' has ellipses in name", menu.Name);
                    nErrors++;
                }
            }

            if (menu.IsRealAccessibleObject)
            {
                foreach (AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuEllipses(child);
                }
            }
            return(nErrors);
        }
        public void Parent_Navigate()
        {
            AccessibilityHelper child  = m_ah.FindChild("informationBar", AccessibleRole.None);
            AccessibilityHelper parent = child.Parent;

            Assert.AreEqual("dummyTestForm", parent.Name);
            AccessibilityHelper draftView = child.Navigate(AccessibleNavigation.Down);

            Assert.IsNotNull(draftView);
            Assert.AreEqual("draftView", draftView.Name);

            AccessibilityHelper navChild = m_ah.Navigate(AccessibleNavigation.FirstChild);

            Assert.AreEqual("System", navChild.Name);
            navChild = navChild.Navigate(AccessibleNavigation.Next);
            Assert.IsNull(navChild.Name);
            navChild = navChild.Navigate(AccessibleNavigation.Next);
            Assert.AreEqual("Application", navChild.Name);
            navChild = navChild.Navigate(AccessibleNavigation.Next);
            Assert.AreEqual("dummyTestForm", navChild.Name);
            navChild = navChild.Navigate(AccessibleNavigation.Next);
            Assert.IsNull(navChild);
        }
Ejemplo n.º 17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Recurse the menus to make sure no menus have duplicate hotkeys in the menu items
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuHotkeys(AccessibilityHelper menu)
        {
            int nErrors = 0;

            ArrayList rgMenuItems = new ArrayList(20);

            foreach (AccessibilityHelper child in menu)
            {
                rgMenuItems.Add(child);
                if (child.IsRealAccessibleObject)
                {
                    nErrors += CheckMenuHotkeys(child);
                }
            }

            for (int id1 = 0; id1 < rgMenuItems.Count; id1++)
            {
                AccessibilityHelper child1 = (AccessibilityHelper)rgMenuItems[id1];
                if (child1.Role != AccessibleRole.Separator)
                {
                    for (int id2 = id1 + 1; id2 < rgMenuItems.Count; id2++)
                    {
                        AccessibilityHelper child2 = (AccessibilityHelper)rgMenuItems[id2];
                        if (child2.Role != AccessibleRole.Separator &&
                            child1.Shortcut == child2.Shortcut &&
                            child1.Shortcut != null &&
                            child1.Shortcut.Length != 0)
                        {
                            Console.WriteLine("\tThe hotkey '{0}' is used by '{1}' and by '{2}'",
                                              child1.Shortcut, child1.Name, child2.Name);
                            nErrors++;
                        }
                    }
                }
            }
            return(nErrors);
        }
Ejemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Verifies that each menu item has an accessible name.
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <param name="parent">The parent menu item</param>
        /// <param name="prevMenu">The menu item before this</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int VerifyMenuItemNames(AccessibilityHelper menu, AccessibilityHelper parent,
			AccessibilityHelper prevMenu)
        {
            int nErrors = 0;
            if (menu.Role != AccessibleRole.Separator &&
                (menu.Name == null || menu.Name.Length <= 0))
            {
                Console.WriteLine(
                    "Can't get menu name. Parent is '{0}', previous menu item is '{1}'. {2}",
                    parent != null ? parent.Name : "<null>",
                    prevMenu != null ? prevMenu.Name : "<null>",
                    menu.IsRealAccessibleObject && menu.ChildCount > 0 ?
                        "Not testing subitems." : "");
                nErrors++;
            }
            else if (menu.IsRealAccessibleObject)
            {
                AccessibilityHelper prevChild = null;
                foreach(AccessibilityHelper child in menu)
                {
                    nErrors += VerifyMenuItemNames(child, menu, prevChild);
                    prevChild = child;
                }
            }
            return nErrors;
        }
Ejemplo n.º 19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks the menu shortcuts for a particular menu
        /// </summary>
        /// <param name="menu">The menu to test</param>
        /// <param name="shortCuts">All short cuts found so far</param>
        /// <param name="menuNames">All menu names found so far</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuNameShortCutUniqueness(AccessibilityHelper menu,
			Hashtable shortCuts, Hashtable menuNames)
        {
            int nErrors = 0;
            if (menu.Role == AccessibleRole.MenuItem)
            {
                string[] menuNameParts = menu.Name.Split(new char[] { '\t' });
                if (menuNameParts.Length > 1)
                {
                    string shortCut = menuNameParts[menuNameParts.Length - 1];
                    if (!shortCuts.Contains(shortCut))
                    {
                        shortCuts.Add(shortCut, menu.Name);
                    }
                    else
                    {
                        Console.WriteLine("\tThe shortcut '{0}' is used by '{1}' and by '{2}'",
                            shortCut, shortCuts[shortCut], menu.Name);
                        nErrors++;
                    }
                }

                string name = menuNameParts[0].TrimEnd(new char[] { '.', ' ' });
                if (!menuNames.Contains(name))
                {
                    menuNames.Add(name, menu.Parent.Name);
                }
                else
                {
                    Console.WriteLine("\tThe menu name '{0}' is used by '{1}' and by '{2}'",
                        name, menu.Parent.Name, menuNames[name]);
                    nErrors++;
                }
            }

            if (menu.IsRealAccessibleObject)
            {
                foreach(AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuNameShortCutUniqueness(child, shortCuts, menuNames);
                }
            }
            return nErrors;
        }
Ejemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Recurse the menus to make sure no menus have duplicate hotkeys in the menu items
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuHotkeys(AccessibilityHelper menu)
        {
            int nErrors = 0;

            ArrayList rgMenuItems = new ArrayList(20);
            foreach(AccessibilityHelper child in menu)
            {
                rgMenuItems.Add(child);
                if (child.IsRealAccessibleObject)
                {
                    nErrors += CheckMenuHotkeys(child);
                }
            }

            for (int id1 = 0; id1 < rgMenuItems.Count; id1++)
            {
                AccessibilityHelper child1 = (AccessibilityHelper)rgMenuItems[id1];
                if (child1.Role != AccessibleRole.Separator)
                {
                    for (int id2 = id1+1; id2 < rgMenuItems.Count; id2++)
                    {
                        AccessibilityHelper child2 = (AccessibilityHelper)rgMenuItems[id2];
                        if (child2.Role != AccessibleRole.Separator &&
                            child1.Shortcut == child2.Shortcut &&
                            child1.Shortcut != null &&
                            child1.Shortcut.Length != 0)
                        {
                            Console.WriteLine("\tThe hotkey '{0}' is used by '{1}' and by '{2}'",
                                child1.Shortcut, child1.Name, child2.Name);
                            nErrors++;
                        }
                    }
                }
            }
            return nErrors;
        }
Ejemplo n.º 21
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Recurse the menus to make sure no menus with sub menus contain trailing ellipses
        /// in the menu text.
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuEllipses(AccessibilityHelper menu)
        {
            int nErrors = 0;

            if (menu.Role == AccessibleRole.MenuPopup)
            {
                if (menu.Name.Trim().EndsWith("..."))
                {
                    Console.WriteLine("\tSub menu '{0}' has ellipses in name", menu.Name);
                    nErrors++;
                }
            }

            if (menu.IsRealAccessibleObject)
            {
                foreach(AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuEllipses(child);
                }
            }
            return nErrors;
        }
Ejemplo n.º 22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Test the menu capitalization and "Book Title" convention
        /// </summary>
        /// <param name="menu">Menu to test</param>
        /// <returns>Number of errors</returns>
        /// ------------------------------------------------------------------------------------
        private int CheckMenuCapitalization(AccessibilityHelper menu)
        {
            int nErrors = 0;
            if (menu.Role != AccessibleRole.Separator && menu.Role != AccessibleRole.MenuPopup
                && menu.Name != null && menu.Name.Length > 0)
            {
                if (!Char.IsUpper(menu.Name[0]) && !Char.IsDigit(menu.Name[0]))
                {
                    Console.WriteLine("\t'{0}' is not capitalized nor digit", menu.Name);
                    nErrors++;
                }
                String[] menuNameParts = menu.Name.Split(new char[] { ' ' });
                for(int i = 1; i < menuNameParts.Length; i++)
                {
                    if (Char.IsLower(menuNameParts[i][0]))
                    {
                        switch(menuNameParts[i])
                        {
                            case "the": //these are okay
                            case "or":
                            case "and":
                            case "a":
                            case "of":
                            case "in":
                                break;

                            default: // any other lower case is not
                                Console.WriteLine(
                                    "\t'{0}' does not follow 'Book Title' convention", menu.Name);
                                nErrors++;
                                break;
                        }

                    }
                }
            }
            if (menu.IsRealAccessibleObject)
            {
                foreach(AccessibilityHelper child in menu)
                {
                    nErrors += CheckMenuCapitalization(child);
                }
            }
            return nErrors;
        }
Ejemplo n.º 23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loop through all menu items (and sub-menus) of one menu and check help text in the
        /// status bar.
        /// </summary>
        /// <param name="menuParent">The main frame menu <see cref="AccessibilityHelper"/>, e.g.
        /// for File.</param>
        /// ------------------------------------------------------------------------------------
        protected int CheckStatusbarMenuTexts(AccessibilityHelper menuParent)
        {
            int nErrors = 0;
            // Because we're really opening the menu, we have one additional layer, that is
            // usually not visible (if you inspect it with AccExplorer, e.g): the window.
            // This consists also only of 1 child
            foreach (AccessibilityHelper menuWindow in menuParent)
            {
                // There should be only 1 popup menu for the menuParent...
                foreach (AccessibilityHelper menuPopup in menuWindow)
                {
                    Debug.WriteLine(string.Format("Menu popup {0} (#children: {1}, role: {2})",
                        menuPopup.Name, menuPopup.ChildCount, menuPopup.Role));

                    foreach (AccessibilityHelper menuItem in menuPopup)
                    {
                        if (menuItem.Role == AccessibleRole.Separator)
                            Debug.WriteLine("Separator -------");
                        else
                        {
                            nErrors += CheckMenuHelp(menuItem.Name);
                            if (menuItem.IsRealAccessibleObject)
                            {
                                Debug.WriteLine(string.Format("Sub Menu {0} (role: {1})",
                                    menuItem.Name, menuItem.Role));
                                Debug.WriteLine("{RIGHT}");
                                m_app.SendKeys("{RIGHT}");
                                nErrors += CheckStatusbarMenuTexts(menuItem);
                            }
                            else
                            {
                                Debug.WriteLine(string.Format("Menu item {0}", menuItem.Name));
                            }
                            Debug.WriteLine("{DOWN}");
                            m_app.SendKeys("{DOWN}");
                        }
                    }
                }
            }
            Debug.WriteLine("{ESC}");
            m_app.SendKeys("{ESC}");
            return nErrors;
        }
Ejemplo n.º 24
0
        ///// <summary>
        ///// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
        ///// </summary>
        ///// <param name="disposing"></param>
        //protected override void Dispose(bool disposing)
        //{
        //    if (IsDisposed)
        //        return;
        //    if (disposing)
        //    {
        //        if (m_app != null)
        //        {
        //            m_app.Exit();
        //        }
        //    }
        //    m_app = null;
        //    m_StatusBar = null;
        //    base.Dispose(disposing);
        //}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loop through all menu items to make sure that they are loaded (some are created
        /// only when they show, but afterwards they still exist).
        /// </summary>
        /// <param name="parent"><see cref="AccessibilityHelper"/> of the main window</param>
        /// ------------------------------------------------------------------------------------
        public void ActivateAllMenuItems(AccessibilityHelper parent)
        {
            foreach (AccessibilityHelper child in parent)
            {
                if (child.Role == AccessibleRole.MenuBar && child.Name != "System")
                {
                    m_app.SendKeys("%");

                    foreach (AccessibilityHelper menu in child)
                    {
                        Debug.WriteLine("----------------------------------------");
                        Debug.WriteLine(string.Format("Activating main frame menu {0} (Role: {1})",
                            menu.Name, menu.Role));
                        if (menu.IsRealAccessibleObject)
                        {
                            m_app.SendKeys("{DOWN}");
                            Debug.WriteLine("{DOWN}");
                            ActivateThisMenu(menu);
                        }

                        Debug.WriteLine("{RIGHT}");
                        m_app.SendKeys("{RIGHT}");
                    }
                    Debug.WriteLine("{ESC}");
                    m_app.SendKeys("{ESC}");
                }
            }
        }
Ejemplo n.º 25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Exits the application
        /// </summary>
        /// <param name="fOnCurrentWindow">If <c>true</c> send Alt-F4 regardless of what window
        /// is active. Otherwise switch to the main window first.</param>
        /// ------------------------------------------------------------------------------------
        public void Exit(bool fOnCurrentWindow)
        {
            try
            {
                m_proc.WaitForInputIdle();
                if (!fOnCurrentWindow)
                    Win32.SetForegroundWindow(m_proc.MainWindowHandle);

                // It works better if we send an ESC first
                m_proc.Close();
                m_proc.WaitForExit();
            }
            catch
            {
            }

            m_proc = null;
            m_AccHelper = null;
        }
Ejemplo n.º 26
0
		public override void Init()
		{
			base.Init();

			Thread.Sleep(500);

			// Select "File/Import/Standard Format" to bring up the import dialog
			m_app.SendKeys("%F");
			m_app.SendKeys("{DOWN 8}");
			m_app.SendKeys("{ENTER}");
			m_app.SendKeys("{ENTER}");
			Application.DoEvents();

			AccessibilityHelper importDlg =
				m_app.MainAccessibilityHelper.Parent.FindDirectChild("Import Standard Format",
				AccessibleRole.None);

			// select the "Import" button which is the default button
			if (importDlg != null)
				m_app.SendKeys("{ENTER}");

			Application.DoEvents();

			m_dialog = m_app.MainAccessibilityHelper.Parent.FindDirectChild(
				"Import Standard Format", AccessibleRole.None);

			m_saveRegistryData = Unpacker.PrepareRegistryForPTData();
		}
Ejemplo n.º 27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check the radio buttons. We should have exactly two: Paratext and Other
		/// </summary>
		/// <param name="parent">The element to start with</param>
		/// <param name="nRbsFound">Number of radio buttons found.</param>
		/// <remarks>On return <paramref name="nRbsFound"/> should be 2. If there are additional
		/// radio buttons on the dialog, <paramref name="nRbsFound"/> will return a negative
		/// number.</remarks>
		/// ------------------------------------------------------------------------------------
		protected void CheckRadioButtons(AccessibilityHelper parent, ref int nRbsFound)
		{
			foreach (AccessibilityHelper child in parent)
			{
				if ((child.States & AccessibleStates.Invisible) == AccessibleStates.Invisible)
					continue;

				if (child.Role == AccessibleRole.RadioButton)
				{
					if (child.Name == "Paratext")
					{
						// paratext radio button has to be default if paratext is installed
						RegistryKey regKey = Registry.LocalMachine.OpenSubKey(kPTSettingsRegKey);
						if (regKey != null)
							Assert.AreEqual(AccessibleStates.Checked, (child.States & AccessibleStates.Checked),
								"Paratext is installed, but Paratext radio button "
								+ "is not the default.");

						nRbsFound++;
					}
					else if (child.Name == "Other")
					{
						// Other radio button has to be default if Paratext isn't installed
						RegistryKey regKey = Registry.LocalMachine.OpenSubKey(kPTSettingsRegKey);
						if (regKey == null)
							Assert.AreEqual(AccessibleStates.Checked, (child.States & AccessibleStates.Checked),
								"Paratext is not installed, but Other radio button is not the default.");

						nRbsFound++;
					}
					else
						nRbsFound = -99;
				}

				if (child.IsRealAccessibleObject)
					CheckRadioButtons(child, ref nRbsFound);
			}
		}
Ejemplo n.º 28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check the controls on the step and see if there are non-excaptable controls on it,
		/// i.e. for the overview page return false if there are any check boxes.
		/// </summary>
		/// <param name="parent">The element to start with</param>
		/// <param name="acceptableRoles">Sorted array of acceptable controls</param>
		/// <returns><c>true</c> if all visible controls are acceptable, otherwise
		/// <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		protected bool CheckControls(AccessibilityHelper parent, AccessibleRole[] acceptableRoles)
		{
			bool fRet = true;
			foreach (AccessibilityHelper child in parent)
			{
				if ((child.States & AccessibleStates.Invisible) == AccessibleStates.Invisible)
					continue;

				if (Array.BinarySearch(acceptableRoles, child.Role) < 0)
					return false;

				if (child.IsRealAccessibleObject)
					fRet = CheckControls(child, acceptableRoles);

				if (!fRet)
					return fRet;
			}

			return fRet;

		}
Ejemplo n.º 29
0
        public void FindNthChild()
        {
            Process proc = m_proc;
            AccessibilityHelper ah = m_ah;

            // start second instance
            Init();

            // now look for the second instance
            int nWhich = 1;
            AccessibilityHelper first = m_ah.Parent.FindNthChild("dummyTestForm",
                AccessibleRole.None, ref nWhich, 0);
            nWhich = 2;
            AccessibilityHelper second = m_ah.Parent.FindNthChild("dummyTestForm",
                AccessibleRole.None, ref nWhich, 0);
            nWhich = 3;
            AccessibilityHelper none = m_ah.Parent.FindNthChild("dummyTestForm",
                AccessibleRole.None, ref nWhich, 0);

            int hwnd1 = m_proc.MainWindowHandle.ToInt32();
            int hwnd2 = proc.MainWindowHandle.ToInt32();
            int foundHwnd1 = first.HWnd;
            int foundHwnd2 = second.HWnd;

            // Close the second instance
            EndTest();

            m_proc = proc;
            m_ah = ah;

            // now test that we got the right window. Do this after closing the second
            // instance, because if it fails the rest of this method isn't executed
            Assert.AreEqual(hwnd1, foundHwnd1);
            Assert.AreEqual(hwnd2, foundHwnd2);
            Assert.IsTrue(hwnd1 != foundHwnd2);
            Assert.IsNull(none);
        }