Skip to content

"Test generation method" setting UI update #863 #1008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogPanel
import com.intellij.ui.ContextHelpLabel
import com.intellij.ui.components.JBLabel
import com.intellij.ui.layout.CCFlags
import com.intellij.ui.layout.LayoutBuilder
import com.intellij.ui.layout.PropertyBinding
import com.intellij.ui.layout.labelTable
import com.intellij.ui.layout.panel
import com.intellij.ui.layout.slider
import com.intellij.ui.layout.withValueBinding
import com.intellij.util.castSafelyTo
import com.intellij.util.ui.UIUtil
import com.intellij.util.ui.components.BorderLayoutPanel
import javax.swing.DefaultComboBoxModel
import javax.swing.JCheckBox
import javax.swing.JLabel
import javax.swing.JPanel
import kotlin.reflect.KClass
import org.utbot.framework.UtSettings
Expand All @@ -26,6 +28,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.JavaDocCommentStyle
import org.utbot.framework.plugin.api.TreatOverflowAsError
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
import javax.swing.JSlider

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

}

row("Code analysis:") {
val fuzzLabel = JBLabel("Fuzzing")
val symLabel = JBLabel("Symbolic execution")
row("Test generation method:") {
enabled = UtSettings.useFuzzing
val granularity = 60
val granularity = 20
slider(0, granularity, 1, granularity / 4)
.labelTable {
put(0, JLabel("Simpler"))
put(granularity, JLabel("Deeper"))
// clear all labels
}.withValueBinding(
PropertyBinding(
get = { ((1 - settings.fuzzingValue) * granularity).toInt() },
set = { settings.fuzzingValue = 1 - it / granularity.toDouble() }
)
)
.constraints(CCFlags.growX)
.component.castSafelyTo<JSlider>()?.apply {
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>"
addChangeListener {
fuzzLabel.text = "Fuzzing " + "%.0f %%".format(100.0 * (granularity - value) / granularity)
symLabel.text = "%.0f %%".format(100.0 * value / granularity) + " Symbolic execution"
}
}
}
row("") {
BorderLayoutPanel().apply {
addToLeft(fuzzLabel)
addToRight(symLabel)
}().constraints(CCFlags.growX)
}
}

Expand Down