protected AbstractIntegrationTest(
            string solutionName,
            string projectTemplate,
            VisualStudioInstanceFactory instanceFactory)
        {
            _visualStudioContext = instanceFactory.GetNewOrUsedInstance(SharedIntegrationHostFixture.RequiredPackageIds);
            VisualStudio         = _visualStudioContext.Instance;

            VisualStudio.SolutionExplorer.CreateSolution(solutionName);
            VisualStudio.SolutionExplorer.AddProject(Project, projectTemplate, DefaultLanguageName);

            // wait for restore to complete.
            VisualStudio.WaitForApplicationIdle();
            VisualStudio.WaitForNoErrorsInErrorList();

            // added to work around https://github.com/dotnet/project-system/issues/2256
            VisualStudio.SolutionExplorer.BuildSolution(waitForBuildToFinish: true);
            var path = VisualStudio.SolutionExplorer.SolutionFileFullPath;

            VisualStudio.SolutionExplorer.CloseSolution();
            VisualStudio.SolutionExplorer.OpenSolution(path);

            VisualStudio.WaitForApplicationIdle();
            VisualStudio.WaitForNoErrorsInErrorList();
        }
Ejemplo n.º 2
0
        private void SendInputs(NativeMethods.INPUT[] inputs)
        {
            var foregroundWindow = IntPtr.Zero;
            var inputBlocked     = false;

            try
            {
                inputBlocked     = IntegrationHelper.BlockInput();
                foregroundWindow = IntegrationHelper.GetForegroundWindow();

                _visualStudioInstance.ActivateMainWindow();

                IntegrationHelper.SendInput(inputs);
            }
            finally
            {
                if (foregroundWindow != IntPtr.Zero)
                {
                    IntegrationHelper.SetForegroundWindow(foregroundWindow);
                }

                if (inputBlocked)
                {
                    IntegrationHelper.UnblockInput();
                }
            }

            _visualStudioInstance.WaitForApplicationIdle(CancellationToken.None);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Verifies that the Preview Changes dialog is showing with the
        /// specified title. The dialog does not have an AutomationId and the
        /// title can be changed by features, so callers of this method must
        /// specify a title.
        /// </summary>
        /// <param name="expectedTitle"></param>
        public void VerifyOpen(string expectedTitle)
        {
            DialogHelpers.FindDialogByName(GetMainWindowHWnd(), expectedTitle, isOpen: true);

            // Wait for application idle to ensure the dialog is fully initialized
            VisualStudioInstance.WaitForApplicationIdle();
        }
Ejemplo n.º 4
0
        public void VerifyOpen()
        {
            // FindDialog will wait until the dialog is open, so the return value is unused.
            DialogHelpers.FindDialogByAutomationId(GetMainWindowHWnd(), ChangeSignatureDialogAutomationId, isOpen: true);

            // Wait for application idle to ensure the dialog is fully initialized
            VisualStudioInstance.WaitForApplicationIdle();
        }
Ejemplo n.º 5
0
        public void VerifyOpen(string dialogName)
        {
            // FindDialog will wait until the dialog is open, so the return value is unused.
            DialogHelpers.FindDialogByName(GetMainWindowHWnd(), dialogName, isOpen: true, CancellationToken.None);

            // Wait for application idle to ensure the dialog is fully initialized
            VisualStudioInstance.WaitForApplicationIdle(CancellationToken.None);
        }
Ejemplo n.º 6
0
        private void SendInputs(NativeMethods.INPUT[] inputs)
        {
            _visualStudioInstance.ActivateMainWindow();

            IntegrationHelper.SendInput(inputs);

            _visualStudioInstance.WaitForApplicationIdle(CancellationToken.None);
        }
Ejemplo n.º 7
0
        public void VerifyOpen(string dialogName)
        {
            using var cancellationTokenSource = new CancellationTokenSource(Helper.HangMitigatingTimeout);

            // FindDialog will wait until the dialog is open, so the return value is unused.
            DialogHelpers.FindDialogByName(GetMainWindowHWnd(), dialogName, isOpen: true, cancellationTokenSource.Token);

            // Wait for application idle to ensure the dialog is fully initialized
            VisualStudioInstance.WaitForApplicationIdle(cancellationTokenSource.Token);
        }
        /// <summary>
        /// Verifies that the Preview Changes dialog is showing with the
        /// specified title. The dialog does not have an AutomationId and the
        /// title can be changed by features, so callers of this method must
        /// specify a title.
        /// </summary>
        /// <param name="expectedTitle"></param>
        public void VerifyOpen(string expectedTitle, TimeSpan?timeout = default)
        {
            using (var cancellationTokenSource = timeout != null ? new CancellationTokenSource(timeout.Value) : null)
            {
                var cancellationToken = cancellationTokenSource?.Token ?? CancellationToken.None;
                DialogHelpers.FindDialogByName(GetMainWindowHWnd(), expectedTitle, isOpen: true, cancellationToken);

                // Wait for application idle to ensure the dialog is fully initialized
                VisualStudioInstance.WaitForApplicationIdle(cancellationToken);
            }
        }
        /// <summary>
        /// Verifies that the Extract Interface dialog is currently open.
        /// </summary>
        public void VerifyOpen()
        {
            var dialog = DialogHelpers.FindDialogByAutomationId(GetMainWindowHWnd(), ExtractInterfaceDialogID, isOpen: true);

            if (dialog == null)
            {
                throw new InvalidOperationException($"Expected the '{ExtractInterfaceDialogID}' dialog to be open but it is not.");
            }

            // Wait for application idle to ensure the dialog is fully initialized
            VisualStudioInstance.WaitForApplicationIdle(CancellationToken.None);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Sends key strokes to the active editor in Visual Studio. Various types are supported by this method:
 /// <see cref="string"/> (each character will be sent separately, <see cref="char"/>, <see cref="VirtualKey"/>
 /// and <see cref="KeyPress"/>.
 /// </summary>
 public void SendKeys(params object[] keys)
 {
     Activate();
     VisualStudioInstance.SendKeys.Send(keys);
     VisualStudioInstance.WaitForApplicationIdle();
 }
Ejemplo n.º 11
0
 protected override void WaitForApplicationIdle(CancellationToken cancellationToken)
 {
     _visualStudioInstance.WaitForApplicationIdle(cancellationToken);
 }