6
6
7
7
package io.flutter.integrationTest
8
8
9
- import com.intellij.driver.sdk.ui.Finder
10
- import com.intellij.driver.sdk.ui.components.ComponentData
11
- import com.intellij.driver.sdk.ui.components.UiComponent
12
9
import com.intellij.driver.sdk.ui.components.UiComponent.Companion.waitFound
13
10
import com.intellij.driver.sdk.ui.components.common.ideFrame
14
11
import com.intellij.driver.sdk.ui.components.common.toolwindows.projectView
15
- import com.intellij.driver.sdk.ui.components.common.welcomeScreen
16
- import com.intellij.driver.sdk.wait
17
12
import com.intellij.driver.sdk.waitForIndicators
18
13
import com.intellij.ide.starter.driver.engine.BackgroundRun
19
14
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
20
15
import com.intellij.ide.starter.junit5.config.UseLatestDownloadedIdeBuild
16
+ import io.flutter.integrationTest.utils.newProjectWelcomeScreen
21
17
import org.junit.jupiter.api.*
22
18
import org.junit.jupiter.api.extension.ExtendWith
23
19
import java.nio.file.Paths
24
20
import kotlin.time.Duration.Companion.minutes
25
- import kotlin.time.Duration.Companion.seconds
26
21
27
22
@Tag(" ui" )
28
23
@TestInstance(TestInstance .Lifecycle .PER_METHOD )
@@ -87,7 +82,7 @@ class MyProjectUITest {
87
82
println (" Test project will be created as: $testProjectName " )
88
83
run = Setup .setupTestContextIC(" MyProjectUITest" ).runIdeWithDriver()
89
84
90
- newProjectWelcomeScreen()
85
+ newProjectWelcomeScreen(run, testProjectName )
91
86
newProjectInProjectView()
92
87
}
93
88
@@ -98,7 +93,7 @@ class MyProjectUITest {
98
93
println (" Test project will be created as: $testProjectName " )
99
94
run = Setup .setupTestContextUE(" MyProjectUITest" ).runIdeWithDriver()
100
95
101
- newProjectWelcomeScreen()
96
+ newProjectWelcomeScreen(run, testProjectName )
102
97
run.driver.withContext {
103
98
ideFrame {
104
99
// Wait for the ideFrame to appear before attempting to interact with it.
@@ -115,58 +110,10 @@ class MyProjectUITest {
115
110
println (" Test project will be created as: $testProjectName " )
116
111
run = Setup .setupTestContextWS(" MyProjectUITest" ).runIdeWithDriver()
117
112
118
- newProjectWelcomeScreen()
113
+ newProjectWelcomeScreen(run, testProjectName )
119
114
newProjectInProjectView()
120
115
}
121
116
122
-
123
- /* *
124
- * Automates the process of creating a new Flutter project from the welcome screen.
125
- * <p>
126
- * This function navigates the "New Project" dialog, selects the Flutter project type,
127
- * and enters a unique project name. It relies on the {@code FLUTTER_SDK} environment
128
- * variable to be set for the test to proceed.
129
- */
130
- fun newProjectWelcomeScreen () {
131
- run.driver.withContext {
132
- // Assert that the welcome screen is visible before interacting with it.
133
- welcomeScreen {
134
- assert (isVisible())
135
- println (" Creating the new project from Welcome Screen" )
136
- createNewProjectButton.click()
137
-
138
- // The test expects the `FlutterGeneratorPeer` to automatically populate the
139
- // Flutter SDK path. This behavior relies on the FLUTTER_SDK environment
140
- // variable being set.
141
- //
142
- // If the FLUTTER_SDK variable is not present, the UI will not find the SDK,
143
- // and the 'Next' button will remain disabled, causing the test to fail.
144
- // A common reason for this failure is an unconfigured test environment.
145
-
146
- newProjectDialog {
147
- // Wait for the dialog to fully load
148
- wait(1 .seconds)
149
-
150
- // Select project type - adjust based on your needs
151
- chooseProjectType(" Flutter" )
152
- wait(1 .seconds)
153
-
154
- // Expect setup to take care of setting the correct Flutter SDK
155
- if (! nextButton.isEnabled()) {
156
- fail { " The FLUTTER_SDK environment variable was not set." }
157
- }
158
- nextButton.click()
159
- wait(1 .seconds)
160
-
161
- keyboard {
162
- typeText(testProjectName)
163
- }
164
- createButton.click()
165
- }
166
- }
167
- }
168
- }
169
-
170
117
/* *
171
118
* Verifies the successful creation of a new project by asserting the presence
172
119
* and structure of files in the project view.
@@ -226,47 +173,3 @@ class MyProjectUITest {
226
173
}
227
174
}
228
175
}
229
-
230
- //
231
- // TODO(jwren) move this into a utility for project creation tasks
232
- //
233
-
234
- // A Kotlin extension function for the `Finder` class.
235
- // This function adds a new method, `newProjectDialog`, that can be
236
- // called on any `Finder` object.
237
- fun Finder.newProjectDialog (action : NewProjectDialogUI .() -> Unit ) {
238
- // Locates the "New Project" dialog.
239
- // - `x(...)` creates an XPath-like query to find the UI component.
240
- // - The query targets a `div` with a `title` of "New Project".
241
- // - `NewProjectDialogUI::class.java` specifies that the found component
242
- // should be treated as an instance of the `NewProjectDialogUI` class,
243
- // allowing access to its properties and functions.
244
- //
245
- // The found dialog component is then passed to the `action` lambda,
246
- // which contains the test steps to perform within the dialog.
247
- x(" //div[@title='New Project']" , NewProjectDialogUI ::class .java).action()
248
- }
249
-
250
- // A UI component representing the "New Project" dialog.
251
- // This class provides a structured way to interact with the dialog's elements
252
- // using the IntelliJ Driver SDK.
253
- open class NewProjectDialogUI (data : ComponentData ) : UiComponent(data) {
254
-
255
- // Clicks on the specified project type from the list.
256
- // The function waits until the text is found before performing the click action.
257
- fun chooseProjectType (projectType : String ) {
258
- projectTypeList.waitOneText(projectType).click()
259
- }
260
-
261
- // Locates the list of project types within the dialog.
262
- // The xQuery targets a component with the specific class "JBList".
263
- private val projectTypeList = x(" //div[@class='JBList']" )
264
-
265
- // Locates the "Next" button in the dialog.
266
- // The xQuery finds a button component with the visible text "Next".
267
- val nextButton = x(" //div[@text='Next']" )
268
-
269
- // Locates the "Create" button in the dialog.
270
- // The xQuery finds a button component with the visible text "Create".
271
- val createButton = x(" //div[@text='Create']" )
272
- }
0 commit comments