Skip to content

Commit b17cd9a

Browse files
authored
"Test generation method" setting UI update #863 (#1008)
1 parent 28d1eb8 commit b17cd9a

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt

+22-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import com.intellij.openapi.components.service
44
import com.intellij.openapi.project.Project
55
import com.intellij.openapi.ui.DialogPanel
66
import com.intellij.ui.ContextHelpLabel
7+
import com.intellij.ui.components.JBLabel
78
import com.intellij.ui.layout.CCFlags
89
import com.intellij.ui.layout.LayoutBuilder
910
import com.intellij.ui.layout.PropertyBinding
1011
import com.intellij.ui.layout.labelTable
1112
import com.intellij.ui.layout.panel
1213
import com.intellij.ui.layout.slider
1314
import com.intellij.ui.layout.withValueBinding
15+
import com.intellij.util.castSafelyTo
1416
import com.intellij.util.ui.UIUtil
17+
import com.intellij.util.ui.components.BorderLayoutPanel
1518
import javax.swing.DefaultComboBoxModel
1619
import javax.swing.JCheckBox
17-
import javax.swing.JLabel
1820
import javax.swing.JPanel
1921
import kotlin.reflect.KClass
2022
import org.utbot.framework.UtSettings
@@ -26,6 +28,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage
2628
import org.utbot.framework.plugin.api.JavaDocCommentStyle
2729
import org.utbot.framework.plugin.api.TreatOverflowAsError
2830
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
31+
import javax.swing.JSlider
2932

3033
class SettingsWindow(val project: Project) {
3134
private val settings = project.service<Settings>()
@@ -127,20 +130,34 @@ class SettingsWindow(val project: Project) {
127130

128131
}
129132

130-
row("Code analysis:") {
133+
val fuzzLabel = JBLabel("Fuzzing")
134+
val symLabel = JBLabel("Symbolic execution")
135+
row("Test generation method:") {
131136
enabled = UtSettings.useFuzzing
132-
val granularity = 60
137+
val granularity = 20
133138
slider(0, granularity, 1, granularity / 4)
134139
.labelTable {
135-
put(0, JLabel("Simpler"))
136-
put(granularity, JLabel("Deeper"))
140+
// clear all labels
137141
}.withValueBinding(
138142
PropertyBinding(
139143
get = { ((1 - settings.fuzzingValue) * granularity).toInt() },
140144
set = { settings.fuzzingValue = 1 - it / granularity.toDouble() }
141145
)
142146
)
143147
.constraints(CCFlags.growX)
148+
.component.castSafelyTo<JSlider>()?.apply {
149+
toolTipText = "<html><body>While fuzzer \"guesses\" the values to enter as much execution paths as possible, symbolic executor tries to \"deduce\" them. Choose the proportion of generation time allocated for each of these methods within Test generation timeout</body></html>"
150+
addChangeListener {
151+
fuzzLabel.text = "Fuzzing " + "%.0f %%".format(100.0 * (granularity - value) / granularity)
152+
symLabel.text = "%.0f %%".format(100.0 * value / granularity) + " Symbolic execution"
153+
}
154+
}
155+
}
156+
row("") {
157+
BorderLayoutPanel().apply {
158+
addToLeft(fuzzLabel)
159+
addToRight(symLabel)
160+
}().constraints(CCFlags.growX)
144161
}
145162
}
146163

0 commit comments

Comments
 (0)