Skip to content

Test generation details are not accessible as Event Log tool window w… #688

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
Show file tree
Hide file tree
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 @@ -14,6 +14,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Computable
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.JavaDirectoryService
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiClassOwner
Expand Down Expand Up @@ -370,6 +371,9 @@ object CodeGenerationController {
}
}

private fun isEventLogAvailable(project: Project) =
ToolWindowManager.getInstance(project).getToolWindow("Event Log") != null

private fun eventLogMessage(): String =
"""
<a href="${TestReportUrlOpeningListener.prefix}${TestReportUrlOpeningListener.eventLogSuffix}">See details in Event Log</a>.
Expand Down Expand Up @@ -405,8 +409,9 @@ object CodeGenerationController {
appendHtmlLine(it)
appendHtmlLine()
}

appendHtmlLine(eventLogMessage())
if (isEventLogAvailable(model.project)) {
appendHtmlLine(eventLogMessage())
}
}
hasWarnings = report.hasWarnings
Pair(message, report.detailedStatistics)
Expand Down Expand Up @@ -439,8 +444,9 @@ object CodeGenerationController {
}
}
}

appendHtmlLine(eventLogMessage())
if (isEventLogAvailable(model.project)) {
appendHtmlLine(eventLogMessage())
}
}

Pair(message, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,11 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
}

TestReportUrlOpeningListener.callbacks[TestReportUrlOpeningListener.eventLogSuffix]?.plusAssign {
val twm = ToolWindowManager.getInstance(model.project)
twm.getToolWindow("Event Log")?.activate(null)
with(model.project) {
if (this.isDisposed) return@with
val twm = ToolWindowManager.getInstance(this)
twm.getToolWindow("Event Log")?.activate(null)
}
}

model.runGeneratedTestsWithCoverage = model.project.service<Settings>().runGeneratedTestsWithCoverage
Expand Down