Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Integration Tests

on:
pull_request:
branches:
- "*"

jobs:
integration_tests:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2

- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
java-version: '17'
distribution: 'temurin'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e #v6.1.0

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Build test APK
run: ./gradlew :opencloudApp:assembleOriginalDebugAndroidTest

- name: Run integration tests with emulator
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a #v2.37.0
with:
api-level: 35
target: google_apis
arch: x86_64
profile: pixel
avd-name: integration-tests-avd
force-avd-creation: true
disable-animations: true
emulator-options: -no-window -no-audio -no-boot-anim -accel auto -memory 2048
script: |
curl -L -o adbserver-desktop.jar https://github.com/KasperskyLab/Kaspresso/raw/master/artifacts/adbserver-desktop.jar
java -jar adbserver-desktop.jar &
sleep 3
./gradlew :opencloudApp:connectedOriginalDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=eu.opencloud.android.LoginScreenTest#loginApp
adb pull /sdcard/Documents/screenshots/ opencloudApp/build/screenshots/ || true

- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-artifacts
path: opencloudApp/build/screenshots/
14 changes: 14 additions & 0 deletions .wood-pecker/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variables:
- &android_image 'docker.io/mingc/android-build-box:1.29.0'

when:
- event: pull_request
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}

steps:
- name: build
image: *android_image
commands:
- ./gradlew :opencloudApp:assembleOriginalDebugAndroidTest
35 changes: 35 additions & 0 deletions .wood-pecker/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
variables:
- &android_image 'docker.io/mingc/android-build-box:1.29.0'
- &emulator_image 'docker.io/shmayro/dockerify-android:09-02-26'

depends_on:
- build

when:
- event: pull_request
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}

steps:
- name: emulator
image: *emulator_image
detach: true

- name: wait for emulator
image: *android_image
commands:
- adb connect emulator:5555
- adb devices

- name: start adb server
image: *android_image
commands:
- curl -L -o adbserver-desktop.jar https://github.com/KasperskyLab/Kaspresso/raw/master/artifacts/adbserver-desktop.jar
- java -jar adbserver-desktop.jar &
detach: true

- name: run tests
image: *android_image
commands:
- ./gradlew :opencloudApp:connectedOriginalDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=eu.opencloud.android.LoginScreenTest#loginApp
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,28 @@ class LoginScreenTest : TestCase(
@get:Rule
val activityRule = ActivityScenarioRule(SplashActivity::class.java)

@get:Rule
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
)

@Test
fun loginApp() {
before {
adbServer.performCmd("adb", listOf("reverse", "tcp:9200", "tcp:9200"))
// adbServer.performCmd("adb", listOf("reverse", "tcp:9200", "tcp:9200"))
adbServer.performCmd("adb", listOf("shell", "settings", "put", "global", "heads_up_notifications_enabled", "0"))
adbServer.performCmd("adb", listOf("shell", "wm", "dismiss-keyguard"))
adbServer.performCmd("adb", listOf("shell", "input", "keyevent", "82"))
}.after {
adbServer.performCmd("adb", listOf("shell", "am", "force-stop", "com.android.chrome"))
adbServer.performCmd("adb", listOf("reverse", "--remove", "tcp:9200"))
// adbServer.performCmd("adb", listOf("reverse", "--remove", "tcp:9200"))
}.run {
step("set opencloud url") {
StartScreen {
hostUrlInput {
isVisible()
typeText("https://localhost:9200")
typeText("https://cloud.rc.opencloud.rocks")
}
checkServerButton {
isVisible()
Expand All @@ -52,15 +60,15 @@ class LoginScreenTest : TestCase(
}
}
}
step("trust certificate") {
TrustCertificate {
yesBtn {
isVisible()
isClickable()
click()
}
}
}
// step("trust certificate") {
// TrustCertificate {
// yesBtn {
// isVisible()
// isClickable()
// click()
// }
// }
// }
step("login") {
LoginScreen {
username.isDisplayed()
Expand Down
11 changes: 8 additions & 3 deletions opencloudApp/src/integrationTest/java/screens/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ object LoginScreen : UiScreen<LoginScreen>() {
override val packageName: String = "com.android.chrome"

// can't find it using withId("com.android.chrome", "username") so using withResourceName()
val username = UiEditText { withResourceName("oc-login-username") }
val password = UiEditText { withResourceName("oc-login-password") }
val loginButton = UiButton { withText("Log in") }
// val username = UiEditText { withResourceName("oc-login-username") }
// val password = UiEditText { withResourceName("oc-login-password") }
// val loginButton = UiButton { withText("Log in") }

// keycloak login form
val username = UiEditText { withResourceName("username") }
val password = UiEditText { withResourceName("password") }
val loginButton = UiButton { withResourceName("kc-login") }

val keepAccessForeverBtn = UiButton { withText("Allow") }
}
Loading