Пример #1
0
        public VisualStudioApp(IServiceProvider site)
            : this(new IntPtr(GetDTE(site).MainWindow.HWnd))
        {
            // TODO: Make site non-optional
            ServiceProvider = site ?? Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider;
            _dte            = GetDTE(site);

            foreach (var p in ((DTE2)_dte).ToolWindows.OutputWindow.OutputWindowPanes.OfType <OutputWindowPane>())
            {
                p.Clear();
            }

            var uiShell = GetService <IVsUIShell>(typeof(IVsUIShell));

            ErrorHandler.ThrowOnFailure(uiShell.GetDialogOwnerHwnd(out IntPtr hwnd));
            if (hwnd != _mainWindowHandle)
            {
                using (AutomationDialog dlg = new AutomationDialog(this, AutomationElement.FromHandle(hwnd)))
                {
                    //startup window popup, press button "Continue without code"
                    var cwc = dlg.FindByName("Continue without code");
                    if (cwc != null)
                    {
                        Invoke(cwc);
                        WaitForInputIdle();
                        return;
                    }
                    Console.WriteLine("Unexpected dialog at start of test");
                    DumpElement(dlg.Element);
                    dlg.WaitForClosed(TimeSpan.FromSeconds(5), dlg.CloseWindow);
                }
            }
        }