private VsIdeHostRunConfigData(VsIdeHostRunConfigData other)
 {
     m_registryHive = other.m_registryHive;
     m_additionalCommandLineArguments = other.m_additionalCommandLineArguments;
     m_additionalTestData = other.m_additionalTestData;
     m_sessionId = other.m_sessionId;
 }
Esempio n. 2
0
 private VsIdeHostRunConfigData(VsIdeHostRunConfigData other)
 {
     m_registryHive = other.m_registryHive;
     m_additionalCommandLineArguments = other.m_additionalCommandLineArguments;
     m_additionalTestData             = other.m_additionalTestData;
     m_sessionId = other.m_sessionId;
 }
Esempio n. 3
0
 /// <summary>
 /// Main editor is asking for the current host specific data.
 /// </summary>
 /// <returns></returns>
 IHostSpecificRunConfigurationData IRunConfigurationCustomHostEditor.GetData()
 {
     if (m_data == null)
     {
         m_data = new VsIdeHostRunConfigData(VSRegistry.GetDefaultVersion());
     }
     m_data.AdditionalCommandLineArguments = m_additionalCommandLineArgumentsEdit.Text;
     m_data.AdditionalTestData             = m_additionalTestDataEdit.Text;
     return(m_data);
 }
Esempio n. 4
0
        private string GetAdditionalCommandLine()
        {
            TestRunConfiguration   runConfig         = m_runContext.RunConfig.TestRun.RunConfiguration;
            VsIdeHostRunConfigData runConfigHostData = runConfig.HostData[Name] as VsIdeHostRunConfigData;

            if (runConfigHostData != null)
            {
                return(runConfigHostData.AdditionalCommandLineArguments);
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// If run under debugger, attaches to the host session of test runner IDE.
        /// </summary>
        private void InitHostSession()
        {
            Debug.Assert(m_hostSession == null, "HA.InitHostSession: m_hostSession should be null!");
            Debug.Assert(m_runConfig != null);

            if (m_runConfig.IsExecutedUnderDebugger)
            {
                // First check if there is Host Data in Run Config.
                // There is not host data when using HostType attribute (not using Run Config).
                string sessionId = null;
                VsIdeHostRunConfigData hostData = m_runConfig.HostData[Name] as VsIdeHostRunConfigData;
                if (hostData != null)
                {
                    sessionId = hostData.SessionId;
                }
                else
                {
                    try
                    {
                        // Try connecting by parent process id.
                        // This is not very reliable because Windows does not really track parent-child process relationship.
                        int ppid = ProcessUtil.GetParentProcessId(System.Diagnostics.Process.GetCurrentProcess().Id);
                        sessionId = VsIdeHostSession.Prefix + ppid.ToString(CultureInfo.InvariantCulture);
                    }
                    catch (COMException ex)
                    {
                        m_runContext.ResultSink.AddResult(new TestRunTextResultMessage(Environment.MachineName, m_runContext.RunConfig.TestRun.Id,
                                                                                       "Warning: " + ex.GetType() + ": " + ex.Message, TestMessageKind.TextMessage));
                    }
                }

                Debug.Assert(m_hostSession == null, "HA.InitHostSession: m_hostSession should be null!");

                if (!string.IsNullOrEmpty(sessionId))
                {
                    // Now get the IDE runner session, the Uri is ipc://ServerPortName/AppName.
                    string uri = string.Format(
                        CultureInfo.InvariantCulture, "ipc://{0}/{1}",
                        sessionId,
                        VsIdeHostSession.RemoteObjectName);

                    m_hostSession = (IVsIdeHostDebugger)Activator.GetObject(typeof(IVsIdeHostDebugger), uri);
                }
                else
                {
                    m_runContext.ResultSink.AddResult(new TestRunTextResultMessage(Environment.MachineName, m_runContext.RunConfig.TestRun.Id,
                                                                                   "Warning: failed to get session id for debugger VS IDE, debugging child VS will be disabled.", TestMessageKind.TextMessage));
                }
            }
        }
        void ITestAdapter.Initialize(IRunContext runContext)
        {
            // We delay inner TAs initialization until Run method because we don't know which test type this is going to be.
            m_runContext = runContext;

            TestRunConfiguration runConfig = m_runContext.RunConfig.TestRun.RunConfiguration;

            Debug.Assert(runConfig != null);
            VsIdeHostRunConfigData runConfigHostData = runConfig.HostData[VsIdeHostAdapter.Name] as VsIdeHostRunConfigData;

            if (runConfigHostData != null)
            {
                VsIdeTestHostContext.AdditionalTestData = runConfigHostData.AdditionalTestData;
            }
        }
Esempio n. 7
0
        [SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")] // TODO: should we care about rightAlign? -- no unless we ship this HA.
        void IRunConfigurationCustomHostEditor.SetData(IHostSpecificRunConfigurationData data)
        {
            string currentVersion = VSRegistry.GetDefaultVersion();  // Throws if VS is not installed.

            VsIdeHostRunConfigData vsIdeHostData = data as VsIdeHostRunConfigData;

            if (vsIdeHostData == null)
            {
                vsIdeHostData = new VsIdeHostRunConfigData(currentVersion);

                // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect.
                SetDirty();
            }
            else if (!m_hiveCombo.Items.Contains(vsIdeHostData.RegistryHive))
            {
                // If .testrunconfig file has VS version that we do not have in combobox,
                // show message box and use default version.
                MessageBox.Show(
                    this,
                    Resources.WrongVSVersionPassedToRunConfigControl(vsIdeHostData.RegistryHive, currentVersion),
                    Resources.MicrosoftVisualStudio);

                vsIdeHostData.RegistryHive = currentVersion;
                // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect.
                SetDirty();
            }

            // Set the data.
            m_data = vsIdeHostData;

            int selectedIndex = m_hiveCombo.Items.IndexOf(vsIdeHostData.RegistryHive);

            if (selectedIndex < 0)
            {
                selectedIndex = m_hiveCombo.Items.IndexOf(currentVersion);
                Debug.Assert(selectedIndex >= 0);
            }
            if (selectedIndex >= 0)
            {
                m_hiveCombo.SelectedIndex = selectedIndex;
            }

            m_additionalCommandLineArgumentsEdit.Text = vsIdeHostData.AdditionalCommandLineArguments;
            m_additionalTestDataEdit.Text             = vsIdeHostData.AdditionalTestData;
        }
Esempio n. 8
0
        /// <summary>
        /// Determine which registry hive to use:
        ///     If override value is set, use it, don't use anything else.
        ///     Else If using RunConfig, get it from RunConfig
        ///     Else get it from environment.
        /// </summary>
        /// <returns></returns>
        private string GetRegistryHive()
        {
            // We get registry hive each time we initialize host side, i.e. it can be changed in between tests.
            string overrideHiveValue = RegistrySettings.RegistryHiveOverride;

            if (!string.IsNullOrEmpty(overrideHiveValue))
            {
                return(overrideHiveValue);
            }

            // Note that Run Config Data can be null, e.g. when executing using HostType attribute.
            TestRunConfiguration   runConfig         = m_runContext.RunConfig.TestRun.RunConfiguration;
            VsIdeHostRunConfigData runConfigHostData = runConfig.HostData[Name] as VsIdeHostRunConfigData;

            if (runConfigHostData != null)
            {
                return(runConfigHostData.RegistryHive);
            }

            return(null);    // VsIde will figure out and use default.
        }
 /// <summary>
 /// Main editor is asking for the current host specific data.
 /// </summary>
 /// <returns></returns>
 IHostSpecificRunConfigurationData IRunConfigurationCustomHostEditor.GetData()
 {
     if (m_data == null)
     {
         m_data = new VsIdeHostRunConfigData(VSRegistry.GetDefaultVersion());
     }
     m_data.AdditionalCommandLineArguments = m_additionalCommandLineArgumentsEdit.Text;
     m_data.AdditionalTestData = m_additionalTestDataEdit.Text;
     return m_data;
 }
        [SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")] // TODO: should we care about rightAlign? -- no unless we ship this HA.
        void IRunConfigurationCustomHostEditor.SetData(IHostSpecificRunConfigurationData data)
        {
            string currentVersion = VSRegistry.GetDefaultVersion();  // Throws if VS is not installed.
            
            VsIdeHostRunConfigData vsIdeHostData = data as VsIdeHostRunConfigData;
            if (vsIdeHostData == null)
            {
                vsIdeHostData = new VsIdeHostRunConfigData(currentVersion);

                // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect.
                SetDirty();
            }
            else if (!m_hiveCombo.Items.Contains(vsIdeHostData.RegistryHive))
            {
                // If .testrunconfig file has VS version that we do not have in combobox,
                // show message box and use default version.
                MessageBox.Show(
                    this, 
                    Resources.WrongVSVersionPassedToRunConfigControl(vsIdeHostData.RegistryHive, currentVersion),
                    Resources.MicrosoftVisualStudio);

                vsIdeHostData.RegistryHive = currentVersion;
                // TODO: SetDirty() that set run config to dirty is disabled in parent during Initialize/SetData, so this makes no effect.
                SetDirty();
            }

            // Set the data.
            m_data = vsIdeHostData;

            int selectedIndex = m_hiveCombo.Items.IndexOf(vsIdeHostData.RegistryHive);
            if (selectedIndex < 0)
            {
                selectedIndex = m_hiveCombo.Items.IndexOf(currentVersion);
                Debug.Assert(selectedIndex >= 0);
            }
            if (selectedIndex >= 0)
            {
                m_hiveCombo.SelectedIndex = selectedIndex;
            }

            m_additionalCommandLineArgumentsEdit.Text = vsIdeHostData.AdditionalCommandLineArguments;
            m_additionalTestDataEdit.Text = vsIdeHostData.AdditionalTestData;
        }