JonasPammer commented on code in PR #15067:
URL: https://github.com/apache/grails-core/pull/15067#discussion_r2368673990
##########
grails-geb/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy:
##########
@@ -59,99 +64,130 @@ import grails.plugin.geb.serviceloader.ServiceRegistry
class WebDriverContainerHolder {
private static final String DEFAULT_HOSTNAME_FROM_HOST = 'localhost'
+ private static final String REMOTE_ADDRESS_PROPERTY =
'webdriver.remote.server'
+ private static final String[] SELENIUM_BROWSERS = ['chrome', 'edge',
'firefox']
+ private static final String DEFAULT_DOCKER_IMAGE_NAME =
'selenium/standalone-chrome'
- GrailsGebSettings grailsGebSettings
+ GrailsGebSettings settings
GebTestManager testManager
- Browser currentBrowser
- BrowserWebDriverContainer currentContainer
- WebDriverContainerConfiguration currentConfiguration
+ Browser browser
+ BrowserWebDriverContainer container
+ WebDriverContainerConfiguration containerConf
- WebDriverContainerHolder(GrailsGebSettings grailsGebSettings) {
- this.grailsGebSettings = grailsGebSettings
+ WebDriverContainerHolder(GrailsGebSettings settings) {
+ this.settings = settings
}
boolean isInitialized() {
- currentContainer != null
+ container != null
}
void stop() {
- currentContainer?.stop()
- currentContainer = null
- currentBrowser = null
+ container?.stop()
+ container = null
+ browser = null
testManager = null
- currentConfiguration = null
+ containerConf = null
}
- boolean
matchesCurrentContainerConfiguration(WebDriverContainerConfiguration
specConfiguration) {
- specConfiguration == currentConfiguration &&
grailsGebSettings.recordingMode ==
BrowserWebDriverContainer.VncRecordingMode.SKIP
+ boolean
matchesCurrentContainerConfiguration(WebDriverContainerConfiguration specConf) {
+ specConf == containerConf &&
+ settings.recordingMode ==
BrowserWebDriverContainer.VncRecordingMode.SKIP
}
- private static int getPort(IMethodInvocation invocation) {
+ private static int findServerPort(IMethodInvocation methodInvocation) {
try {
- return (int)
invocation.instance.metaClass.getProperty(invocation.instance, 'serverPort')
+ return (int) methodInvocation.instance.metaClass.getProperty(
+ methodInvocation.instance,
+ 'serverPort'
+ )
} catch (ignored) {
- throw new IllegalStateException('Test class must be annotated with
@Integration for serverPort to be injected')
+ throw new IllegalStateException(
+ 'Test class must be annotated with @Integration for
serverPort to be injected'
+ )
}
}
@PackageScope
- boolean reinitialize(IMethodInvocation invocation) {
- WebDriverContainerConfiguration specConfiguration = new
WebDriverContainerConfiguration(
- invocation.getSpec()
+ boolean reinitialize(IMethodInvocation methodInvocation) {
+ def specConf = new WebDriverContainerConfiguration(
+ methodInvocation.spec
)
- if (matchesCurrentContainerConfiguration(specConfiguration)) {
+ if (matchesCurrentContainerConfiguration(specConf)) {
return false
}
if (initialized) {
stop()
}
- currentConfiguration = specConfiguration
- currentContainer = new BrowserWebDriverContainer().withRecordingMode(
- grailsGebSettings.recordingMode,
- grailsGebSettings.recordingDirectory,
- grailsGebSettings.recordingFormat
+ def gebConf = new ConfigurationLoader().conf
+ def dockerImageName = defaultDockerImageName
+
+ def gebConfigFileFound = false
+ if (gebConfigFileExists) {
+ if (!gebConf.driverConf instanceof Closure) {
+ throw new IllegalStateException(
+ 'The "driver" config value must be a Closure that
returns an instance of RemoteWebDriver.'
+ )
+ }
+ gebConfigFileFound = true
+
+ // Prepare for creating a suitable container matching the driver
+ // configured in GebConfig.groovy, or more specifically,
+ // specified by the `configuredBrowser` property.
+ dockerImageName =
createDockerImageName(gebConf.rawConfig.configuredBrowser)
Review Comment:
[nice](https://github.com/apache/grails-core/pull/15067/commits/79b8708c8f39b4f77d11ce7c124dd9ac4ee246e6)!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]