1
1
package org.utbot.intellij.plugin.language.python
2
2
3
+ import com.intellij.openapi.components.service
3
4
import com.intellij.openapi.project.Project
4
- import com.intellij.openapi.ui.ComboBox
5
- import com.intellij.openapi.ui.DialogPanel
6
- import com.intellij.openapi.ui.DialogWrapper
7
- import com.intellij.openapi.ui.ValidationInfo
5
+ import com.intellij.openapi.ui.*
8
6
import com.intellij.ui.ContextHelpLabel
9
7
import com.intellij.ui.JBIntSpinner
10
8
import com.intellij.ui.components.Panel
@@ -17,15 +15,18 @@ import com.jetbrains.python.refactoring.classes.PyMemberInfoStorage
17
15
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo
18
16
import com.jetbrains.python.refactoring.classes.ui.PyMemberSelectionTable
19
17
import org.utbot.framework.UtSettings
18
+ import org.utbot.intellij.plugin.settings.Settings
20
19
import java.awt.BorderLayout
21
20
import java.util.concurrent.TimeUnit
22
21
import org.utbot.intellij.plugin.ui.components.TestSourceDirectoryChooser
23
22
import org.utbot.intellij.plugin.ui.utils.createTestFrameworksRenderer
23
+ import java.awt.event.ActionEvent
24
24
import javax.swing.*
25
25
26
26
27
27
private const val WILL_BE_INSTALLED_LABEL = " (will be installed)"
28
28
private const val MINIMUM_TIMEOUT_VALUE_IN_SECONDS = 1
29
+ private const val ACTION_GENERATE = " Generate Tests"
29
30
30
31
class PythonDialogWindow (val model : PythonTestsModel ) : DialogWrapper(model.project) {
31
32
@@ -38,13 +39,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
38
39
Int .MAX_VALUE ,
39
40
MINIMUM_TIMEOUT_VALUE_IN_SECONDS
40
41
)
41
- private val timeoutSpinnerForOneRun =
42
- JBIntSpinner (
43
- TimeUnit .MILLISECONDS .toSeconds(DEFAULT_TIMEOUT_FOR_RUN_IN_MILLIS ).toInt(),
44
- MINIMUM_TIMEOUT_VALUE_IN_SECONDS ,
45
- Int .MAX_VALUE ,
46
- MINIMUM_TIMEOUT_VALUE_IN_SECONDS
47
- )
48
42
private val testFrameworks =
49
43
ComboBox (DefaultComboBoxModel (model.cgLanguageAssistant.getLanguageTestFrameworkManager().testFrameworks.toTypedArray()))
50
44
@@ -64,7 +58,7 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
64
58
override fun createCenterPanel (): JComponent {
65
59
66
60
panel = panel {
67
- row(" Test source root:" ) {
61
+ row(" Test sources root:" ) {
68
62
component(testSourceFolderField)
69
63
}
70
64
row(" Test framework:" ) {
@@ -80,13 +74,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
80
74
component(ContextHelpLabel .create(" Set the timeout for all test generation processes." ))
81
75
}
82
76
}
83
- row(" Timeout for one function run:" ) {
84
- cell {
85
- component(timeoutSpinnerForOneRun)
86
- label(" seconds" )
87
- component(ContextHelpLabel .create(" Set the timeout for one function execution." ))
88
- }
89
- }
90
77
row(" Generate test methods for:" ) {}
91
78
row {
92
79
scrollPane(functionsTable)
@@ -165,14 +152,31 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
165
152
contextHelpLabel?.let { add(it, BorderLayout .LINE_END ) }
166
153
})
167
154
155
+ class OKOptionAction (private val okAction : Action ) : AbstractAction(ACTION_GENERATE ) {
156
+ init {
157
+ putValue(DEFAULT_ACTION , java.lang.Boolean .TRUE )
158
+ putValue(FOCUSED_ACTION , java.lang.Boolean .TRUE )
159
+ }
160
+ override fun actionPerformed (e : ActionEvent ? ) {
161
+ okAction.actionPerformed(e)
162
+ }
163
+ }
164
+
165
+ private val okOptionAction: OKOptionAction get() = OKOptionAction (super .getOKAction())
166
+ override fun getOKAction () = okOptionAction
167
+
168
168
override fun doOKAction () {
169
169
val selectedMembers = functionsTable.selectedMemberInfos
170
170
model.selectedFunctions = selectedMembers.mapNotNull { it.member as ? PyFunction }.toSet()
171
171
model.testFramework = testFrameworks.item
172
172
model.timeout = TimeUnit .SECONDS .toMillis(timeoutSpinnerForTotalTimeout.number.toLong())
173
- model.timeoutForRun = TimeUnit .SECONDS .toMillis(timeoutSpinnerForOneRun.number.toLong())
174
173
model.testSourceRootPath = testSourceFolderField.text
175
174
175
+ val settings = model.project.service<Settings >()
176
+ with (settings) {
177
+ model.timeoutForRun = hangingTestsTimeout.timeoutMs
178
+ }
179
+
176
180
super .doOKAction()
177
181
}
178
182
0 commit comments