blob: 1f1bd3a18e1a4b0ce8e3d655bb326d1361cf64dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tools.idea.tests.gui.compose
import com.android.tools.idea.flags.StudioFlags
import com.android.tools.idea.tests.gui.framework.GuiTestRule
import com.android.tools.idea.tests.gui.framework.fixture.npw.NewActivityWizardFixture
import com.android.tools.idea.tests.util.WizardUtils
import com.android.tools.idea.wizard.template.Language
import com.google.common.truth.Truth.assertThat
import com.intellij.testGuiFramework.framework.GuiTestRemoteRunner
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit
@RunWith(GuiTestRemoteRunner::class)
class NewComposeProjectTest {
@get:Rule
val guiTest = GuiTestRule().withTimeout(5, TimeUnit.MINUTES)
@Before
fun setup() {
StudioFlags.COMPOSE_WIZARD_TEMPLATES.override(true)
}
@After
fun cleanUp() {
StudioFlags.COMPOSE_WIZARD_TEMPLATES.clearOverride()
}
/**
* Verifies that user is able to create a new Compose Activity Project through the
* new project wizard.
* <p>TT ID: f1c58981-0704-40be-9794-7f61e425a8d5
* Test steps:
* 1. Create new default "Empty Compose Activity" Project
* Verify:
* 1. Check that app/build.gradle has dependencies for "androidx.compose.ui:ui-framework" and "androidx.compose.ui:ui-tooling"
* 2. Check that the main activity has functions annotated with @Composable and @Preview
* 3. Check Gradle Sync to success
*/
@Test
fun newComposeProject() {
WizardUtils.createNewProject(guiTest, "Empty Compose Activity", Language.Kotlin)
guiTest.getProjectFileText("app/build.gradle").run {
assertThat(this).contains("implementation \"androidx.compose.ui:ui:")
assertThat(this).contains("implementation 'androidx.compose.material:material:")
assertThat(this).contains("implementation \"androidx.compose.ui:ui-tooling-preview:")
assertThat(this).contains("debugImplementation \"androidx.compose.ui:ui-tooling:")
}
guiTest.getProjectFileText("app/src/main/java/com/google/myapplication/MainActivity.kt").run {
assertThat(this).contains("@Composable")
assertThat(this).contains("@Preview")
assertThat(this).contains("fun DefaultPreview(")
assertThat(this).contains("fun Greeting(")
}
guiTest.ideFrame().focus().projectView
.selectAndroidPane()
.clickPath("app")
// Check if we can add another Compose Activity (will need to de-duplicate compose function names)
NewActivityWizardFixture.find(guiTest.ideFrame().invokeMenuPath("File", "New", "Compose", "Empty Compose Activity"))
.getConfigureActivityStep("Empty Compose Activity")
.wizard()
.clickFinishAndWaitForSyncToFinish()
guiTest.getProjectFileText("app/src/main/java/com/google/myapplication/MainActivity2.kt").run {
assertThat(this).contains("fun DefaultPreview2(")
assertThat(this).contains("fun Greeting2(")
}
}
}
|