Esempio n. 1
0
        public void DoWindowContents(Rect canvas)
        {
            StatusExplorer.UpdateAllStatusCounts();
            var options = new Listing_Standard();

            options.Begin(canvas);
            options.CheckboxLabeled("Include RimTests' own test suite", ref RunOwnTests, "if enabled, RimTest will run its' own test suite as well as any mod test suites.");
            options.CheckboxLabeled("Run tests at startup", ref RunAtStartup, "if enabled, RimTest will run every valid tests at the game startup.");
            options.GapLine();
            //if (options.ButtonText("Run everything"))
            //{
            //    Runner.RunAllRegisteredTests();
            //    StatusExplorer.UpdateAllStatusCounts();
            //}
            //if(options.ButtonText("Log all current results to Debug log"))
            //{
            //    Viewer.LogTestsResults();
            //}
            //options.GapLine();
            DrawControls(options);
            options.End();

            Rect GUIRect  = canvas.BottomPartPixels(canvas.height - options.CurHeight);
            Rect viewRect = GUIRect.LeftPartPixels(GUIRect.width - 16).AtZero();

            viewRect.Set(viewRect.xMin, viewRect.yMin, viewRect.width, CalcTotalHeight()); // update height to accomodate to all the data

            var testlisting = new Listing_Standard();

            //testlisting.BeginScrollView(GUIRect, ref ScrollPosition, ref viewRect);
            Widgets.BeginScrollView(GUIRect, ref ScrollPosition, viewRect, true);
            GUI.BeginGroup(viewRect);
            testlisting.Begin(viewRect);
            DrawTests(testlisting);
            testlisting.End();
            GUI.EndGroup();
            //testlisting.EndScrollView(ref viewRect);
            Widgets.EndScrollView();

            //reset fonts
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            //Widgets.CustomButtonText(ref labelRect, "test assembly", Color.black, Color.white, Color.red);

            // RimTest -- displayA  displayB ...
            // Assemblies: |collapse| |expand| filter regex: |_________________
            // TestSuites: |collapse| |expand| view: [x]✓ [v]! [v]✘ [x]➥ [v]?
            // |run all| |export logs|
            // V THIS PART V
            // |run| |time|   ||v [v] Assembly 1|       |
            // |run| |time|   ||^ [x] Assembly 2|       | error msg
            // |run| |time|    ||v [v] TestSuite 2.1|   |
            // |run| |time|    ||^ [x] TestSuite 2.2|   | error msg
            // |run| |time|     ||v [x] Test 2.2.1|     | error msg
            // |run| |time|     ||^ [v] Test 2.2.1|     |
            // ...
        }
Esempio n. 2
0
        /// <summary>
        /// Said entry point
        /// </summary>
        public RimTestMod(ModContentPack content) : base(content) //our constructor
        {
            Settings = GetSettings <RimTestSettings>();
            Explorer.ExploreAndRegisterAssemblies();
            StatusExplorer.UpdateAllStatusCounts();

            if (Settings.RunAtStartup)
            {
                Runner.RunAllRegisteredTests();
                StatusExplorer.UpdateAllStatusCounts();
                Viewer.LogTestsResults();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Draws the RimTest UI main canvas
        /// </summary>
        /// <param name="canvas"></param>
        public void DoWindowContents(Rect canvas)
        {
            StatusExplorer.UpdateAllStatusCounts();
            var options = new Listing_Standard();

            options.Begin(canvas);
            options.CheckboxLabeled("Include RimTests' own test suite", ref RunOwnTests, "if enabled, RimTest will run its' own test suite as well as any mod test suites.");
            options.CheckboxLabeled("Run tests at startup", ref RunAtStartup, "if enabled, RimTest will run every valid tests at the game startup.");
            options.GapLine();
            //if (options.ButtonText("Run everything"))
            //{
            //    Runner.RunAllRegisteredTests();
            //    StatusExplorer.UpdateAllStatusCounts();
            //}
            //if(options.ButtonText("Log all current results to Debug log"))
            //{
            //    Viewer.LogTestsResults();
            //}
            //options.GapLine();
            DrawControls(options);
            options.End();

            Rect GUIRect  = canvas.BottomPartPixels(canvas.height - options.CurHeight);
            Rect viewRect = GUIRect.LeftPartPixels(GUIRect.width - 16).AtZero();

            viewRect.Set(viewRect.xMin, viewRect.yMin, viewRect.width, CalcTotalHeight()); // update height to accomodate to all the data

            var testlisting = new Listing_Standard();

            //testlisting.BeginScrollView(GUIRect, ref ScrollPosition, ref viewRect);
            Widgets.BeginScrollView(GUIRect, ref ScrollPosition, viewRect, true);
            GUI.BeginGroup(viewRect);
            testlisting.Begin(viewRect);
            DrawTests(testlisting);
            testlisting.End();
            GUI.EndGroup();
            //testlisting.EndScrollView(ref viewRect);
            Widgets.EndScrollView();

            //reset fonts
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            //Widgets.CustomButtonText(ref labelRect, "test assembly", Color.black, Color.white, Color.red);

            // RimTest -- displayA  displayB ...
            //                                 Status: ✘ERROR  !WARNING  ➥SKIPPED  ?NOT RAN  ✓PASS
            // Assemblies: |collapse| |expand |         [x] 2    [v] 1                [v] 1    [v] 1
            // TestSuites: |collapse| |expand |         [x] 3    [v] 1    [x] 1       [v] 12   [v] 4
            // Tests:      |run all | |log all|         [x] 10            [x] 4       [v] 23   [v] 16
            // filter regex: |_________________
            // V THIS PART V
            // |run| |time|   ||v [v] Assembly 1|       |
            // |run| |time|   ||^ [x] Assembly 2|       | error msg
            // |run| |time|    ||v [v] TestSuite 2.1|   |
            // |run| |time|    ||^ [x] TestSuite 2.2|   | error msg
            // |run| |time|     ||v [x] Test 2.2.1|     | error msg
            // |run| |time|     ||^ [v] Test 2.2.1|     |
            // ...

            //TODO Status filter , utiliser colonnes + sliders
            //-----          [Skipped]  |  [Passed]
            //[Assemblies]   [x] [100]  |
            //[Test Suites][x][010] |
            //[Tests][x][000] |

            // TODO Statuses symbols
            // ?? pas ouf
            // !! pas ouf

            // TODO control rows size doivent être aussi gros que les checkbox.
        }
Esempio n. 4
0
        private void DrawControls(Listing_Standard bar)
        {
            Rect rowAsm = bar.GetRect(HEIGHT_CONTROLS);
            Rect rowTS  = bar.GetRect(HEIGHT_CONTROLS);
            Rect rowT   = bar.GetRect(HEIGHT_CONTROLS);

            // ASM - COLLAPSE / EXPAND - STATUSES
            Rect asmLabelRect    = rowAsm.LeftPartPixels(WIDTH_CONTROLS_ASM_LABEL);
            Rect asmCollapseRect = rowAsm.RightPartPixels(rowAsm.width - asmLabelRect.xMax).LeftPartPixels(WIDTH_CONTROLS_ASM_COLLAPSE);
            Rect asmExpandRect   = rowAsm.RightPartPixels(rowAsm.width - asmCollapseRect.xMax).LeftPartPixels(WIDTH_CONTROLS_ASM_EXPAND);

            Widgets.Label(asmLabelRect, "Assemblies");
            if (Widgets.ButtonText(asmCollapseRect, "Collapse"))
            {
                CollapseAllAssemblies();
            }
            if (Widgets.ButtonText(asmExpandRect, "Expand"))
            {
                ExpandAllAssemblies();
            }
            Rect statusAsmLabelRect      = rowAsm.RightPartPixels(rowAsm.width - asmExpandRect.xMax - WIDTH_CONTROLS_SECTION_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_LABEL);
            Rect statusAsmControllerRect = rowAsm.RightPartPixels(rowAsm.width - statusAsmLabelRect.xMax);

            Rect statusAsmFailRect    = statusAsmControllerRect.LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusAsmWarnRect    = statusAsmControllerRect.RightPartPixels(statusAsmControllerRect.width - statusAsmFailRect.width - WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusAsmSkipRect    = statusAsmControllerRect.RightPartPixels(statusAsmControllerRect.width - 2 * statusAsmWarnRect.width - 2 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusAsmUnknownRect = statusAsmControllerRect.RightPartPixels(statusAsmControllerRect.width - 3 * statusAsmSkipRect.width - 3 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusAsmPassRect    = statusAsmControllerRect.RightPartPixels(statusAsmControllerRect.width - 4 * statusAsmUnknownRect.width - 4 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);

            Widgets.CheckboxLabeled(statusAsmFailRect, $"{StatusExplorer.GetAssemblyStatusCount(AssemblyStatus.ERROR)} {StatusSymbol(AssemblyStatus.ERROR)}", ref FilteredExplorer.failEnabledAsm);

            Widgets.CheckboxLabeled(statusAsmWarnRect, $"{StatusExplorer.GetAssemblyStatusCount(AssemblyStatus.WARNING)} {StatusSymbol(AssemblyStatus.WARNING)}", ref FilteredExplorer.warningEnabledAsm);

            Widgets.CheckboxLabeled(statusAsmUnknownRect, $"{StatusExplorer.GetAssemblyStatusCount(AssemblyStatus.UNKNOWN)} {StatusSymbol(AssemblyStatus.UNKNOWN)}", ref FilteredExplorer.unknownEnabledAsm);

            Widgets.CheckboxLabeled(statusAsmPassRect, $"{StatusExplorer.GetAssemblyStatusCount(AssemblyStatus.PASS)} {StatusSymbol(AssemblyStatus.PASS)}", ref FilteredExplorer.passEnabledAsm);

            // TESTSUITE - COLLAPSE / EXPAND - STATUSES
            Rect tsLabelRect    = rowTS.LeftPartPixels(WIDTH_CONTROLS_TS_LABEL);
            Rect tsCollapseRect = rowTS.RightPartPixels(rowTS.width - tsLabelRect.xMax).LeftPartPixels(WIDTH_CONTROLS_TS_COLLAPSE);
            Rect tsExpandRect   = rowTS.RightPartPixels(rowTS.width - tsCollapseRect.xMax).LeftPartPixels(WIDTH_CONTROLS_TS_EXPAND);

            Widgets.Label(tsLabelRect, "Test Suites");
            if (Widgets.ButtonText(tsCollapseRect, "Collapse"))
            {
                CollapseAllTestSuites();
            }
            if (Widgets.ButtonText(tsExpandRect, "Expand"))
            {
                ExpandAllTestSuites();
            }
            Rect statusTSLabelRect      = rowTS.RightPartPixels(rowTS.width - tsExpandRect.xMax - WIDTH_CONTROLS_SECTION_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_LABEL);
            Rect statusTSControllerRect = rowTS.RightPartPixels(rowTS.width - statusTSLabelRect.xMax);

            Rect statusTSFailRect    = statusTSControllerRect.LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTSWarnRect    = statusTSControllerRect.RightPartPixels(statusTSControllerRect.width - statusTSFailRect.width - WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTSSkipRect    = statusTSControllerRect.RightPartPixels(statusTSControllerRect.width - 2 * statusTSWarnRect.width - 2 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTSUnknownRect = statusTSControllerRect.RightPartPixels(statusTSControllerRect.width - 3 * statusTSSkipRect.width - 3 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTSPassRect    = statusTSControllerRect.RightPartPixels(statusTSControllerRect.width - 4 * statusTSUnknownRect.width - 4 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);

            Widgets.CheckboxLabeled(statusTSFailRect, $"{StatusExplorer.GetTestSuiteStatusCount(TestSuiteStatus.ERROR)} {StatusSymbol(TestSuiteStatus.ERROR)}", ref FilteredExplorer.failEnabledTS);

            Widgets.CheckboxLabeled(statusTSWarnRect, $"{StatusExplorer.GetTestSuiteStatusCount(TestSuiteStatus.WARNING)} {StatusSymbol(TestSuiteStatus.WARNING)}", ref FilteredExplorer.warningEnabledTS);

            Widgets.CheckboxLabeled(statusTSSkipRect, $"{StatusExplorer.GetTestSuiteStatusCount(TestSuiteStatus.SKIP)} {StatusSymbol(TestSuiteStatus.SKIP)}", ref FilteredExplorer.skipEnabledTS);

            Widgets.CheckboxLabeled(statusTSUnknownRect, $"{StatusExplorer.GetTestSuiteStatusCount(TestSuiteStatus.UNKNOWN)} {StatusSymbol(TestSuiteStatus.UNKNOWN)}", ref FilteredExplorer.unknownEnabledTS);

            Widgets.CheckboxLabeled(statusTSPassRect, $"{StatusExplorer.GetTestSuiteStatusCount(TestSuiteStatus.PASS)} {StatusSymbol(TestSuiteStatus.PASS)}", ref FilteredExplorer.passEnabledTS);

            // TEST - RUN ALL / LOG ALL - STATUSES

            Rect tLabelRect  = rowT.LeftPartPixels(WIDTH_CONTROLS_TS_LABEL);
            Rect tRunAllRect = rowT.RightPartPixels(rowT.width - tLabelRect.xMax).LeftPartPixels(WIDTH_CONTROLS_TS_COLLAPSE);
            Rect tLogAllRect = rowT.RightPartPixels(rowT.width - tRunAllRect.xMax).LeftPartPixels(WIDTH_CONTROLS_TS_EXPAND);

            Widgets.Label(tLabelRect, "Tests");
            if (Widgets.ButtonText(tRunAllRect, "Run all"))
            {
                Runner.RunAllRegisteredTests();
                StatusExplorer.UpdateAllStatusCounts();
                TimeElapsedExplorer.UpdateAllAssembliesTimeElapsed();
            }
            if (Widgets.ButtonText(tLogAllRect, "Log all"))
            {
                Viewer.LogTestsResults();
            }

            Rect statusTLabelRect      = rowT.RightPartPixels(rowT.width - tLogAllRect.xMax - WIDTH_CONTROLS_SECTION_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_LABEL);
            Rect statusTControllerRect = rowT.RightPartPixels(rowT.width - statusTLabelRect.xMax);

            Rect statusTFailRect    = statusTControllerRect.LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTSkipRect    = statusTControllerRect.RightPartPixels(statusTControllerRect.width - 2 * statusTFailRect.width - 2 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTUnknownRect = statusTControllerRect.RightPartPixels(statusTControllerRect.width - 3 * statusTSkipRect.width - 3 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);
            Rect statusTPassRect    = statusTControllerRect.RightPartPixels(statusTControllerRect.width - 4 * statusTUnknownRect.width - 4 * WIDTH_CONTROLS_CONTROL_GAP).LeftPartPixels(WIDTH_CONTROLS_VIEW_CONTROL);

            Widgets.CheckboxLabeled(statusTFailRect, $"{StatusExplorer.GetTestStatusCount(TestStatus.ERROR)} {StatusSymbol(TestStatus.ERROR)}", ref FilteredExplorer.failEnabledT);

            Widgets.CheckboxLabeled(statusTSkipRect, $"{StatusExplorer.GetTestStatusCount(TestStatus.SKIP)} {StatusSymbol(TestStatus.SKIP)}", ref FilteredExplorer.skipEnabledT);

            Widgets.CheckboxLabeled(statusTUnknownRect, $"{StatusExplorer.GetTestStatusCount(TestStatus.UNKNOWN)} {StatusSymbol(TestStatus.UNKNOWN)}", ref FilteredExplorer.unknownEnabledT);

            Widgets.CheckboxLabeled(statusTPassRect, $"{StatusExplorer.GetTestStatusCount(TestStatus.PASS)} {StatusSymbol(TestStatus.PASS)}", ref FilteredExplorer.passEnabledT);

            //// SEARCH
            Rect rowSearch         = bar.GetRect(HEIGHT_CONTROLS);
            Rect searchLabelRect   = rowSearch.LeftPartPixels(WIDTH_CONTROLS_SEARCH_LABEL);
            Rect searchControlRect = rowSearch.RightPartPixels(rowSearch.width - searchLabelRect.xMax);

            Widgets.Label(searchLabelRect, "Search :");
            try
            {
                string searchRegexTmp = Widgets.TextField(searchControlRect, searchRegex);
                if (searchRegexTmp != searchRegex)
                {
                    searchRegex = searchRegexTmp;
                    FilteredExplorer.UpdateFilter(new Regex(searchRegex));
                }
            }
            catch
            {
                FilteredExplorer.UpdateFilter(new Regex(@""));
            }
        }