Пример #1
0
        private void SolutionEvents_AfterClosing()
        {
            _currentSolution = null;
            TestList window = GetTestList();

            window.ClearTests();
        }
Пример #2
0
        public int ExecMarkerCommand(IVsTextMarker pMarker, int iItem)
        {
            var      tester   = new GTestRunner();
            TestList testList = TestPackage.GetTestList();

            tester.OnTestsUpdated += testList.UpdateTestResult;
            switch (iItem)
            {
            case (int)MarkerCommandValues2.mcvRightClickCommand:
                IVsUIShell uiShell = (IVsUIShell)TestPackage.GetGlobalService(typeof(SVsUIShell));
                Guid       context = GuidList.GUIDTestMarkerCmdSet;
                POINTS[]   menuPos = new POINTS[1];
                menuPos[0].x = (short)Cursor.Position.X;
                menuPos[0].y = (short)Cursor.Position.Y;
                var hr = uiShell.ShowContextMenu(0, ref context, (int)PkgCmdIDList.ContextMenu, menuPos, this as IOleCommandTarget);
                if (hr != VSConstants.S_OK)
                {
                    return(VSConstants.S_FALSE);
                }
                break;

            case (int)PkgCmdIDList.cmdRunTest:
                tester.RunTests(_projectMarkerBelongsTo, _testName, false);
                break;

            case (int)PkgCmdIDList.cmdDebugTest:
                tester.RunTests(_projectMarkerBelongsTo, _testName, true);
                break;

            default:

                return(VSConstants.S_FALSE);
            }
            return(VSConstants.S_OK);
        }
Пример #3
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            var      tester   = new GTestRunner();
            TestList testList = TestPackage.GetTestList();

            tester.OnTestsUpdated += testList.UpdateTestResult;
            try
            {
                switch (nCmdID)
                {
                case PkgCmdIDList.cmdRunTest:
                    tester.RunTests(_projectMarkerBelongsTo, _testName, false);
                    break;

                case PkgCmdIDList.cmdDebugTest:
                    tester.RunTests(_projectMarkerBelongsTo, _testName, true);
                    break;
                }
            }
            catch (TestRunnerException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
            }
            return(VSConstants.S_OK);
        }
Пример #4
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation

        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            //Debugger.Launch();
            base.Initialize();
            if (false == this.AttemptInit())
            {
                IVsShell shellService = GetService(typeof(SVsShell)) as IVsShell;

                if (shellService != null)
                {
                    ErrorHandler.ThrowOnFailure(shellService.AdviseShellPropertyChanges(this, out _cookie));
                }
                else
                {
                    Debug.WriteLine("shellService == null Unable to set initializing routine exiting...");
                    return;
                }
            }
            //   _markers = null;
            // Add our command handlers for menu (commands must exist in the .vsct file)
            _mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != _mcs)
            {
                // Create the command for the menu item.
                CommandID      menuCommandID = new CommandID(GuidList.GUIDTestPackageCmdSet, (int)PkgCmdIDList.cmdTestSettings);
                OleMenuCommand menuItem      = new OleMenuCommand(MenuItemCallback, menuCommandID);
                menuItem.BeforeQueryStatus += TestSettingsVisiblityCallback;
                _mcs.AddCommand(menuItem);
                // Create the command for the tool window
                CommandID   toolwndCommandID = new CommandID(GuidList.GUIDTestPackageCmdSet, (int)PkgCmdIDList.cmdTestList);
                MenuCommand menuToolWin      = new MenuCommand(ShowTestList, toolwndCommandID);
                _mcs.AddCommand(menuToolWin);
                //   CommandID ctxRunTestsID = new CommandID(GuidList.GUIDTestMarkerCmdSet,(int)PkgCmdIDList.cmdRunTest);
                //  _mcs.AddCommand(new MenuCommand(test,ctxRunTestsID));
            }

            _oleServiceProvider = (IOLEServiceProvider)GetService(typeof(IOLEServiceProvider));
            IServiceContainer container = (IServiceContainer)this;

            container.AddService(typeof(TestMarkerProvider), _provider, true);


            ToolWindowPane failure = this.FindToolWindow(typeof(TestFailure), 0, true);

            if ((null == failure) || (null == failure.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            _testFailureWindow = (TestFailure)failure;
            ToolWindowPane testlist = this.FindToolWindow(typeof(TestList), 0, true);

            if ((null == testlist) || (null == testlist.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            _testListWindow = (TestList)testlist;
        }
Пример #5
0
        private void Settings_Closed(object sender, EventArgs e)
        {
            Contract.Requires(sender.GetType() == typeof(GSettings));
            GSettings settings = (GSettings)sender;

            if (!settings.Configuration.Dirty)
            {
                return;
            }
            _config.Save();

            TestList window = GetTestList();

            window.DisplayAvaliableTests(settings.Configuration);
        }
Пример #6
0
        private void GetTestsForProject(Project p, string configName)
        {
            Contract.Requires(p != null);
            Contract.Requires(!String.IsNullOrEmpty(configName));

            if (p.Kind != GuidList.CPPProject)
            {
                return;
            }
            // get build configuration for project, name and path of the output
            // to feed gtest.
            VCProject       cppProject = (VCProject)p.Object;
            VCConfiguration vcC        =
                (VCConfiguration)
                (((IVCCollection)cppProject.Configurations).Item(configName));

            if (!vcC.PrimaryOutput.EndsWith("exe", true, CultureInfo.CurrentCulture))
            {
                return;
            }
            ConfiguredProject project = _config.GetConfiguration(p);

            project.Name    = p.Name;
            project.TestExe = vcC.PrimaryOutput;
            //try to get tests if a build exists)
            if (File.Exists(vcC.PrimaryOutput))
            {
                TestList window = GetTestList();
                if (window.DisplayAvaliableTests(project))
                {
                    if (!_projectsWithTests.ContainsKey(project.Name))
                    {
                        _projectsWithTests.Add(project.Name, project);
                    }
                }
            }
        }