diff options
Diffstat (limited to 'pkg/integration/components/test.go')
-rw-r--r-- | pkg/integration/components/test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go index 464779e38..d17e3f7c5 100644 --- a/pkg/integration/components/test.go +++ b/pkg/integration/components/test.go @@ -19,6 +19,11 @@ import ( // to get the test's name via it's file's path. const unitTestDescription = "test test" +const ( + defaultWidth = 100 + defaultHeight = 100 +) + type IntegrationTest struct { name string description string @@ -32,6 +37,8 @@ type IntegrationTest struct { keys config.KeybindingConfig, ) gitVersion GitVersionRestriction + width int + height int } var _ integrationTypes.IntegrationTest = &IntegrationTest{} @@ -52,6 +59,11 @@ type NewIntegrationTestArgs struct { Skip bool // to run a test only on certain git versions GitVersion GitVersionRestriction + // width and height when running in headless mode, for testing + // the UI in different sizes. + // If these are set, the test must be run in headless mode + Width int + Height int } type GitVersionRestriction struct { @@ -120,6 +132,8 @@ func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest { setupConfig: args.SetupConfig, run: args.Run, gitVersion: args.GitVersion, + width: args.Width, + height: args.Height, } } @@ -172,6 +186,18 @@ func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) { } } +func (self *IntegrationTest) HeadlessDimensions() (int, int) { + if self.width == 0 && self.height == 0 { + return defaultWidth, defaultHeight + } + + return self.width, self.height +} + +func (self *IntegrationTest) RequiresHeadless() bool { + return self.width != 0 && self.height != 0 +} + func testNameFromCurrentFilePath() string { path := utils.FilePath(3) return TestNameFromFilePath(path) |