Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AutotestPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2
4 name: "Run test",
5 description: "Runs the test suite or test case the cursor currently is in.\nSupports only SCR_Autotest* suites.",
6 shortcut: "F4",
7 wbModules: { "ScriptEditor" },
8// category: SCR_PluginCategory.SCRIPTEDITOR_ASSISTANCE,
9 awesomeFontCode: 0xF188
10)]
11class SCR_AutotestPlugin : WorkbenchPlugin
12{
13 [Attribute(defvalue: "1", desc: "Focus world editor when starting the run")]
14 bool m_bFocusWorldEditor;
15
16 [Attribute(defvalue: "1", desc: "Open result dialog after the test run")]
17 bool m_bOpenDialogAfterRun;
18
19 [Attribute(defvalue: "0", desc: "Open the autotest.log after the test run")]
20 bool m_bOpenLogAfterRun;
21
22 [Attribute(defvalue: "0", desc: "Output all logs for successful tests in autotest.log")]
23 bool m_bVerboseLog;
24
25 [Attribute(defvalue: "1", desc: "Close the game after test runner has finished")]
26 bool m_bCloseGameAfterRun;
27
28#ifndef AUTOTEST_DISABLE_RUN_SCRIPT_EDITOR
29 //------------------------------------------------------------------------------------------------
33 static bool GetCursorClassAndMethodNames(out string className, out string methodName)
34 {
35 ScriptEditor scriptEditor = Workbench.GetModule(ScriptEditor);
36 return SCR_CopyClassAndMethodPlugin.GetCursorClassAndMethodNames(scriptEditor, className, methodName);
37 }
38
39 //------------------------------------------------------------------------------------------------
40 override void Run()
41 {
42 string className, methodName;
43 if (!GetCursorClassAndMethodNames(className, methodName))
44 {
45 Print("The current line is not inside of a class.", LogLevel.WARNING);
46 return;
47 }
48
49 if (m_bFocusWorldEditor)
50 {
51 FocusWorldEditor();
52 }
53
54 RunClassName(className.Trim());
55 }
56#endif
57
58 //------------------------------------------------------------------------------------------------
60 override void Configure()
61 {
62 Workbench.ScriptDialog("Autotest Plugin Configuration", "", this);
63 }
64
65 //------------------------------------------------------------------------------------------------
67 void RunConfig(notnull SCR_AutotestGroup testGroupConfig)
68 {
69 PrintFormat("Running test group: %1", testGroupConfig, level: LogLevel.NORMAL);
70
71 SCR_AutotestHarness.s_bOpenLogAfterRun = m_bOpenLogAfterRun;
72 SCR_AutotestHarness.s_bOpenDialogAfterRun = m_bOpenDialogAfterRun;
73 SCR_AutotestHarness.s_bCloseGameAfterRun = m_bCloseGameAfterRun;
74
75 SCR_AutotestHarness.Begin(testGroupConfig, true, m_bVerboseLog);
76 }
77
78 //------------------------------------------------------------------------------------------------
80 void RunClassName(string className, bool gui = false)
81 {
82 if (className.ToType().IsInherited(SCR_AutotestSuiteBase))
83 {
84 RunTestSuite(className);
85 return;
86 }
87
88 if (className.ToType().IsInherited(SCR_AutotestCaseBase))
89 {
90 RunTestCase(className, gui);
91 return;
92 }
93
94 PrintFormat("Current line is not inside of a test suite or test case: \"%1\"", className, level: LogLevel.WARNING);
95 if (gui)
96 {
97 string msg = string.Format("\"%1\" is not a test suite or test case class.", className);
98 Workbench.Dialog("Invalid class", msg);
99 }
100 }
101
102 //------------------------------------------------------------------------------------------------
103 protected void RunTestSuite(string testSuiteClass)
104 {
105 PrintFormat("Running test suite: %1", testSuiteClass, level: LogLevel.NORMAL);
106
107 SCR_AutotestHarness.s_bOpenLogAfterRun = m_bOpenLogAfterRun;
108 SCR_AutotestHarness.s_bOpenDialogAfterRun = m_bOpenDialogAfterRun;
109 SCR_AutotestHarness.s_bCloseGameAfterRun = m_bCloseGameAfterRun;
110
111 SCR_AutotestSuiteBase testSuite = SCR_AutotestSuiteBase.Cast(testSuiteClass.ToType().Spawn());
112 SCR_AutotestHarness.Begin(testSuite, true, m_bVerboseLog);
113 }
114
115 //------------------------------------------------------------------------------------------------
116 protected void RunTestCase(string testCaseClass, bool gui)
117 {
118 PrintFormat("Running test case: %1", testCaseClass, level: LogLevel.NORMAL);
119 SCR_AutotestCaseBase testCase = SCR_AutotestCaseBase.Cast(testCaseClass.ToType().Spawn());
120
121 // TODO(maciejewskifil) refactor
122 /*if (!testCase.GetSuite())
123 {
124 Print("Specified test does not have parent suite.", LogLevel.WARNING);
125 if (gui)
126 Workbench.Dialog("Error", "Specified test does not have parent suite.");
127
128 return;
129 }*/
130
131 SCR_AutotestHarness.s_bOpenLogAfterRun = m_bOpenLogAfterRun;
132 SCR_AutotestHarness.s_bOpenDialogAfterRun = m_bOpenDialogAfterRun;
133 SCR_AutotestHarness.s_bCloseGameAfterRun = m_bCloseGameAfterRun;
134
135 SCR_AutotestHarness.Begin(testCase, true, m_bVerboseLog);
136 }
137
138 [Friend(SCR_AutotestTool)]
139 protected void FocusWorldEditor()
140 {
141 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
142 // getting plugin focuses the module window
143 worldEditor.GetPlugin(SCR_AutotestTool);
144 }
145}
146#endif
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
override void Run()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
override void Configure()
Collection of test suites.
static void Begin(SCR_AutotestGroup testGroup, bool autorun=false, bool verboseLog=false)
Configures the test runner to execute only the test suites present in the specified test group and in...
static bool s_bOpenDialogAfterRun
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute