Skip to content

Commit

Permalink
Use buildconfig to get if we are running ksp or not
Browse files Browse the repository at this point in the history
  • Loading branch information
oas004 committed Sep 4, 2022
1 parent 84315b7 commit fbf680a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Expand Up @@ -56,7 +56,7 @@ jobs:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=false -DuseKsp=false
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=false

- name: Run UI Tests w/ KSP
uses: reactivecircus/android-emulator-runner@v2
Expand All @@ -65,7 +65,7 @@ jobs:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=true -DuseKsp=true
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=true

- name: Run Screenshot Tests
uses: reactivecircus/android-emulator-runner@v2
Expand Down
7 changes: 7 additions & 0 deletions showkase-browser-testing/build.gradle
Expand Up @@ -20,6 +20,7 @@ android {
exclude 'META-INF/gradle/incremental.annotation.processors'
exclude("META-INF/*.kotlin_module")
}

defaultConfig {
minSdkVersion 26
targetSdkVersion 32
Expand All @@ -28,6 +29,12 @@ android {
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'

if (project.hasProperty('useKsp')) {
buildConfigField "boolean", "IS_RUNNING_KSP", "true"
} else {
buildConfigField "boolean", "IS_RUNNING_KSP", "false"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
Expand Down
Expand Up @@ -6,7 +6,6 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry
import com.airbnb.android.showkase.models.Showkase
import com.airbnb.android.showkase.ui.ShowkaseBrowserActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -41,17 +40,12 @@ class ShowcaseBrowserTest {
// beyond the source retention KEEP, except for in the new IR backend which was introduced
// in Kotlin 1.6. It will be available in the old backend in Kotlin version 1.7.20.
// See https://youtrack.jetbrains.com/issue/KT-49682 for more information about this.
private val componentSize = if (System.getProperty("useKsp") == "true") {
private val componentSize = if (BuildConfig.IS_RUNNING_KSP) {
11
} else {
7
}

@Before
fun setupLog() {
println("Use KSP value = ${System.getProperty("useKsp")}")
}

@Test
fun activity_starts_and_all_the_showkase_ui_elements_are_visible_on_the_screen_and_clickable() {
// Assert that all the categories are displayed on the screen and that they are clickable.
Expand Down Expand Up @@ -92,7 +86,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Tap on the "Colors" row
clickRowWithText("Colors (4)")
Expand All @@ -109,7 +104,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Tap on the "Typography" row
clickRowWithText("Typography (13)")
Expand Down Expand Up @@ -193,7 +189,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Tap on the "Colors" row
clickRowWithText("Colors (4)")
Expand All @@ -213,7 +210,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Tap on the "Typography" row
clickRowWithText("Typography (13)")
Expand Down Expand Up @@ -242,7 +240,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Select Components
clickRowWithText("Components ($componentSize)")
Expand All @@ -267,7 +266,8 @@ class ShowcaseBrowserTest {
verifyLandingScreen(
components = componentSize,
typography = 13,
colors = 4,)
colors = 4,
)

// Select Colors
clickRowWithText("Colors (4)")
Expand Down

0 comments on commit fbf680a

Please sign in to comment.