Exemple #1
0
        /// <summary>
        /// Dumps the current top-level window in VS
        /// </summary>
        public static void DumpVS()
        {
            IVsUIShell uiShell = VSTestContext.ServiceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell;
            IntPtr     hwnd;

            uiShell.GetDialogOwnerHwnd(out hwnd);
            AutomationWrapper.DumpElement(AutomationElement.FromHandle(hwnd));

            // if we have a dialog open dump the main VS window too
            var mainHwnd = new IntPtr(VSTestContext.DTE.MainWindow.HWnd);

            if (mainHwnd != hwnd)
            {
                Console.WriteLine("VS: ");
                AutomationWrapper.DumpElement(AutomationElement.FromHandle(mainHwnd));
            }
        }
        public AutomationElement this[Guid tabGuid] {
            get {
                var tabItem = FindByAutomationId("PropPage_" + tabGuid.ToString("n").ToLower());
                Assert.IsNotNull(tabItem, "Failed to find page");

                AutomationWrapper.DumpElement(tabItem);
                foreach (var p in tabItem.GetSupportedPatterns())
                {
                    Console.WriteLine("Supports {0}", p.ProgrammaticName);
                }

                try {
                    tabItem.GetInvokePattern().Invoke();
                } catch (InvalidOperationException) {
                    AutomationWrapper.DoDefaultAction(tabItem);
                }

                return(FindByAutomationId("PageHostingPanel"));
            }
        }
        /// <summary>
        /// Waits for no dialog. If a dialog appears before the timeout expires
        /// then the test fails and the dialog is closed.
        /// </summary>
        public void WaitForNoDialog(TimeSpan timeout)
        {
            IVsUIShell uiShell = GetService <IVsUIShell>(typeof(IVsUIShell));
            IntPtr     hwnd;

            uiShell.GetDialogOwnerHwnd(out hwnd);

            for (int i = 0; i < 100 && hwnd == _mainWindowHandle; i++)
            {
                System.Threading.Thread.Sleep((int)timeout.TotalMilliseconds / 100);
                uiShell.GetDialogOwnerHwnd(out hwnd);
            }

            if (hwnd != (IntPtr)_mainWindowHandle)
            {
                AutomationWrapper.DumpElement(AutomationElement.FromHandle(hwnd));
                NativeMethods.EndDialog(hwnd, (IntPtr)(int)MessageBoxButton.Cancel);
                Assert.Fail("Dialog appeared - see output for details");
            }
        }
        public void DismissAllDialogs()
        {
            int foundWindow = 2;

            while (foundWindow != 0)
            {
                IVsUIShell uiShell = GetService <IVsUIShell>(typeof(IVsUIShell));
                if (uiShell == null)
                {
                    return;
                }

                IntPtr hwnd;
                uiShell.GetDialogOwnerHwnd(out hwnd);

                for (int j = 0; j < 10 && hwnd == _mainWindowHandle; j++)
                {
                    System.Threading.Thread.Sleep(100);
                    uiShell.GetDialogOwnerHwnd(out hwnd);
                }

                //We didn't see any dialogs
                if (hwnd == IntPtr.Zero || hwnd == _mainWindowHandle)
                {
                    foundWindow--;
                    continue;
                }

                //MessageBoxButton.Abort
                //MessageBoxButton.Cancel
                //MessageBoxButton.No
                //MessageBoxButton.Ok
                //MessageBoxButton.Yes
                //The second parameter is going to be the value returned... We always send Ok
                Debug.WriteLine("Dismissing dialog");
                AutomationWrapper.DumpElement(AutomationElement.FromHandle(hwnd));
                NativeMethods.EndDialog(hwnd, new IntPtr(1));
            }
        }
Exemple #5
0
 void ITreeNode.AddToSelection()
 {
     AutomationWrapper.AddToSelection(Element);
 }
Exemple #6
0
 public static void Collapse(this AutomationElement node)
 {
     AutomationWrapper.Collapse(node);
 }
Exemple #7
0
 public static void EnsureExpanded(this AutomationElement node)
 {
     AutomationWrapper.EnsureExpanded(node);
 }
Exemple #8
0
 public static void Select(this AutomationElement element)
 {
     AutomationWrapper.Select(element);
 }