From 1ccb754186796a941e07ce77c388a711f556b078 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 20:23:06 +0100 Subject: [PATCH 01/21] Update config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 348774f1..714a2d9d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: @@ -71,4 +71,4 @@ workflows: - build - test: requires: - - build \ No newline at end of file + - build From bb5ba6ce9ee227750eab95289065ac88e5154d5f Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:37:44 +0100 Subject: [PATCH 02/21] Update config.yml --- .circleci/config.yml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 714a2d9d..a29bbe8f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,12 +2,12 @@ version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: - name: android/android-machine - resource-class: large + name: android/default tag: 2024.01.1 steps: @@ -15,23 +15,14 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - - - android/create-avd: - avd-name: avd - install: true - system-image: system-images;android-29;default;x86 - - android/start-emulator: - avd-name: avd - no-window: true - restore-gradle-cache-prefix: v2 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - - android/save-gradle-cache: - cache-prefix: v1 + - android/setup-emulator: + api-level: 29 + emulator-type: full + - android/wait-for-emulator: + timeout-sec: 180 + - run: + name: Install APKs and Run Tests + command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -42,18 +33,15 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/restore-gradle-cache: - cache-prefix: v1 - run: name: Download Dependencies command: ./gradlew androidDependencies - - android/save-gradle-cache: - cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug From 882ac4c25d56a3e6e49d281f1c620f16c7927df8 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:42:35 +0100 Subject: [PATCH 03/21] Update config.yml --- .circleci/config.yml | 54 ++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a29bbe8f..e20dd29d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,25 +1,27 @@ version: 2.1 -orbs: - android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common - executor: - name: android/default - tag: 2024.01.1 - + docker: + - image: circleci/android:2020.10 steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/setup-emulator: - api-level: 29 - emulator-type: full - - android/wait-for-emulator: - timeout-sec: 180 + - run: + name: Download and Install SDK Packages + command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk + - run: + name: Create and Start Emulator + command: | + echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 + emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & + circle-android wait-for-boot + - run: + name: Wait for Emulator to Start + command: adb wait-for-device - run: name: Install APKs and Run Tests command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest @@ -30,33 +32,7 @@ jobs: name: Store Test Reports path: services_app/build/reports - build: - docker: - - image: cimg/android:2024.01 - - steps: - - checkout - - run: - name: Chmod Permissions - command: sudo chmod +x gradlew - - run: - name: Download Dependencies - command: ./gradlew androidDependencies - - run: - name: Build Services - command: ./gradlew assembleSnapshotDebug - - store_artifacts: - name: Store Build Artifacts - path: services_app/build/outputs/apk - - persist_to_workspace: - root: . - paths: - - services_app/build/outputs/apk - workflows: build-test-workflow: jobs: - - build - - test: - requires: - - build + - test From bd8faad5bf2acce655f98ebec8545824411e5bbe Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:44:14 +0100 Subject: [PATCH 04/21] Update config.yml --- .circleci/config.yml | 73 +++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e20dd29d..95e8df3c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,30 +1,38 @@ + version: 2.1 +orbs: + android: circleci/android@2.4.0 jobs: test: description: Runs unit tests and instrumented tests on the Android Common - docker: - - image: circleci/android:2020.10 + executor: + name: android/android-machine + resource-class: large + tag: 2024.01.1 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - run: - name: Download and Install SDK Packages - command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk - - run: - name: Create and Start Emulator - command: | - echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 - emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & - circle-android wait-for-boot - - run: - name: Wait for Emulator to Start - command: adb wait-for-device - - run: - name: Install APKs and Run Tests - command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + + - android/create-avd: + avd-name: avd + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: avd + no-window: true + restore-gradle-cache-prefix: v2 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + - android/save-gradle-cache: + cache-prefix: v1 - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -32,7 +40,36 @@ jobs: name: Store Test Reports path: services_app/build/reports + build: + docker: + - image: cimg/android:2024.01 + steps: + - checkout + - run: + name: Chmod Permissions + command: sudo chmod +x gradlew + - android/restore-gradle-cache: + cache-prefix: v1 + - run: + name: Download Dependencies + command: ./gradlew androidDependencies + - android/save-gradle-cache: + cache-prefix: v1 + - run: + name: Build Services + command: ./gradlew assembleSnapshotDebug + - store_artifacts: + name: Store Build Artifacts + path: services_app/build/outputs/apk + - persist_to_workspace: + root: . + paths: + - services_app/build/outputs/apk + workflows: build-test-workflow: jobs: - - test + - build + - test: + requires: + - build From 3f5bed479e96f0b835df3cc35dfb9d28af7ade07 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:45:20 +0100 Subject: [PATCH 05/21] Update config.yml --- .circleci/config.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f94a866c..51762538 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,3 @@ - version: 2.1 orbs: @@ -16,6 +15,8 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + environment: + TERM: dumb - android/create-avd: avd-name: avd @@ -27,11 +28,17 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + environment: + TERM: dumb - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + environment: + TERM: dumb - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + environment: + TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -49,16 +56,22 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + environment: + TERM: dumb - android/restore-gradle-cache: cache-prefix: v1 - run: name: Download Dependencies command: ./gradlew androidDependencies + environment: + TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug + environment: + TERM: dumb - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From 18376679aebadcd99c759e458ea2fc3230261dc1 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:50:59 +0100 Subject: [PATCH 06/21] Update config.yml --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51762538..30de6259 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,9 +15,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - environment: - TERM: dumb - - android/create-avd: avd-name: avd install: true @@ -28,8 +25,6 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - environment: - TERM: dumb - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest @@ -57,7 +52,6 @@ jobs: name: Chmod Permissions command: sudo chmod +x gradlew environment: - TERM: dumb - android/restore-gradle-cache: cache-prefix: v1 - run: From cac1a57e636c7ec7c31b77bad3c0b53e258d88cc Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:53:25 +0100 Subject: [PATCH 07/21] Update config.yml --- .circleci/config.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30de6259..741a3bbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,12 +28,8 @@ jobs: - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - environment: - TERM: dumb - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - environment: - TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -57,15 +53,11 @@ jobs: - run: name: Download Dependencies command: ./gradlew androidDependencies - environment: - TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug - environment: - TERM: dumb - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From 87104d5f8a1d8be8ed16e6a2d17c5cd7d90a6b1b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:58:34 +0100 Subject: [PATCH 08/21] Update config.yml --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 741a3bbc..4ff1b081 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,6 +30,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + no_output_timeout: 1h - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From b3e33e39db971ccf524a9e9f82f6e87ec11e090a Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:59:33 +0100 Subject: [PATCH 09/21] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ff1b081..e628cbcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - no_output_timeout: 1h + no-output-timeout: 1h - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From 6898371699d447782e23660f24855220b0fa155b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:22:41 +0100 Subject: [PATCH 10/21] Update config.yml --- .circleci/config.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e628cbcf..20063323 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,6 +2,7 @@ version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -25,12 +26,25 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - run: + name: Wait for Emulator + command: | + # Wait for the emulator to fully boot up + adb wait-for-device + sleep 30 + adb shell input keyevent 82 + - run: + name: Restart ADB Server + command: | + adb kill-server + adb start-server + adb devices - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - no-output-timeout: 1h + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + no-output-timeout: 30min - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -39,6 +53,9 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports + - run: + name: Collect ADB Logs + command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt build: docker: From 37db507f0a8fe314bcdfb86868d1e0f02eef36ae Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:29:08 +0100 Subject: [PATCH 11/21] Update config.yml --- .circleci/config.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 20063323..9edb89bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,15 +40,16 @@ jobs: adb start-server adb devices - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - no-output-timeout: 30min + no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - - store_artifacts: - name: Store Test Results + - store_test_results: path: services_app/build/outputs/androidTest-results - store_artifacts: name: Store Test Reports @@ -56,6 +57,9 @@ jobs: - run: name: Collect ADB Logs command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt + - store_artifacts: + name: Store ADB Logs + path: $CIRCLE_ARTIFACTS/adb_log.txt build: docker: @@ -65,7 +69,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - environment: - android/restore-gradle-cache: cache-prefix: v1 - run: From 8bbd1d75f8219bd14372cf28e04acb762869f42b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:13:31 +0100 Subject: [PATCH 12/21] Update config.yml --- .circleci/config.yml | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9edb89bd..68e0747f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ + version: 2.1 orbs: android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -16,6 +16,7 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/create-avd: avd-name: avd install: true @@ -26,40 +27,20 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - - run: - name: Wait for Emulator - command: | - # Wait for the emulator to fully boot up - adb wait-for-device - sleep 30 - adb shell input keyevent 82 - - run: - name: Restart ADB Server - command: | - adb kill-server - adb start-server - adb devices - android/disable-animations - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest --info + - android/run-tests: + test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - - store_test_results: + - store_artifacts: + name: Store Test Results path: services_app/build/outputs/androidTest-results - store_artifacts: name: Store Test Reports path: services_app/build/reports - - run: - name: Collect ADB Logs - command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt - - store_artifacts: - name: Store ADB Logs - path: $CIRCLE_ARTIFACTS/adb_log.txt build: docker: From 27345a300c967e950bd75391a58957c31affa71d Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:36:52 +0100 Subject: [PATCH 13/21] Update config.yml --- .circleci/config.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68e0747f..f5828c14 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: @@ -16,7 +16,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/create-avd: avd-name: avd install: true @@ -28,10 +27,12 @@ jobs: memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest --info - - android/run-tests: - test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 @@ -41,6 +42,12 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports + - run: + name: Collect ADB Logs + command: adb logcat -d > adb_log.txt + - store_artifacts: + name: Store ADB Logs + path: adb_log.txt build: docker: @@ -54,12 +61,12 @@ jobs: cache-prefix: v1 - run: name: Download Dependencies - command: ./gradlew androidDependencies + command: ./gradlew androidDependencies --info - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services - command: ./gradlew assembleSnapshotDebug + command: ./gradlew assembleSnapshotDebug --info - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From dc66510f71baf137ff8c2f89c802ac702f35ee81 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:46:04 +0100 Subject: [PATCH 14/21] Update config.yml --- .circleci/config.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5828c14..196a112a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -17,15 +17,19 @@ jobs: name: Chmod Permissions command: sudo chmod +x gradlew - android/create-avd: - avd-name: avd - install: true - system-image: system-images;android-29;default;x86 + avd-name: Pixel_7_Pro + device: pixel_7_pro + system-image: system-images;android-33;google_apis_playstore;x86_64 + tag: google_apis_playstore + abi: x86_64 + sdcard-path: sdcard.img + force: true - android/start-emulator: - avd-name: avd + avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 - memory: 4096 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + memory: 4096 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - run: name: Run Unit Tests @@ -33,7 +37,7 @@ jobs: - run: name: Run Instrumented Tests command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - no-output-timeout: 30m + timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From abb7c961301ed8324443d54ad411b835f9b6e2d9 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:50:49 +0100 Subject: [PATCH 15/21] Update config.yml --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 196a112a..251b8ee5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,6 +23,7 @@ jobs: tag: google_apis_playstore abi: x86_64 sdcard-path: sdcard.img + install: true force: true - android/start-emulator: avd-name: Pixel_7_Pro From 1d84806b8c83f48e1c58e4acdb2a37e813defecf Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:52:05 +0100 Subject: [PATCH 16/21] Update config.yml --- .circleci/config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 251b8ee5..e997f352 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,13 +18,8 @@ jobs: command: sudo chmod +x gradlew - android/create-avd: avd-name: Pixel_7_Pro - device: pixel_7_pro system-image: system-images;android-33;google_apis_playstore;x86_64 - tag: google_apis_playstore - abi: x86_64 - sdcard-path: sdcard.img install: true - force: true - android/start-emulator: avd-name: Pixel_7_Pro no-window: true From e434b0ab5262a94fdc71a4bfdab851af02a6bb37 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:55:41 +0100 Subject: [PATCH 17/21] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e997f352..de4ebe6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: From 576569c15ce8cc50a6bac305223a407798ef205f Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:55:13 +0100 Subject: [PATCH 18/21] Update config.yml --- .circleci/config.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index de4ebe6a..16cff964 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ + version: 2.1 orbs: android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -16,9 +16,10 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/create-avd: avd-name: Pixel_7_Pro - system-image: system-images;android-33;google_apis_playstore;x86_64 + system-image: system-images;android-29;google_apis_playstore;x86_64 install: true - android/start-emulator: avd-name: Pixel_7_Pro @@ -27,13 +28,10 @@ jobs: memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - timeout: 30m + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -42,12 +40,6 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports - - run: - name: Collect ADB Logs - command: adb logcat -d > adb_log.txt - - store_artifacts: - name: Store ADB Logs - path: adb_log.txt build: docker: @@ -61,12 +53,12 @@ jobs: cache-prefix: v1 - run: name: Download Dependencies - command: ./gradlew androidDependencies --info + command: ./gradlew androidDependencies - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services - command: ./gradlew assembleSnapshotDebug --info + command: ./gradlew assembleSnapshotDebug - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From e6261d84605cf2d3437c6cf3d1c90eee5d56e5a1 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:30:30 +0100 Subject: [PATCH 19/21] Update config.yml --- .circleci/config.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 16cff964..feab5628 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -13,30 +13,50 @@ jobs: steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew - android/create-avd: avd-name: Pixel_7_Pro - system-image: system-images;android-29;google_apis_playstore;x86_64 + system-image: system-images;android-30;google_apis_playstore;x86_64 install: true + + - run: + name: Start ADB server + command: adb start-server + - android/start-emulator: avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + + - run: + name: Wait for Emulator to be Ready + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + + - run: + name: Restart ADB server + command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - android/save-gradle-cache: cache-prefix: v1 + - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results + - store_artifacts: name: Store Test Reports path: services_app/build/reports @@ -44,24 +64,32 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/restore-gradle-cache: cache-prefix: v1 + - run: name: Download Dependencies command: ./gradlew androidDependencies + - android/save-gradle-cache: cache-prefix: v1 + - run: name: Build Services command: ./gradlew assembleSnapshotDebug + - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk + - persist_to_workspace: root: . paths: From a7a415b00539d495f45a832a5181ee18f161b0f6 Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 29 Jun 2024 12:09:14 +0100 Subject: [PATCH 20/21] new stable branch --- .circleci/config.yml | 9 +- .../java/org/opendatakit/BaseUITest.java | 121 +++++++++++------- .../java/org/opendatakit/TestConsts.java | 4 + .../LoginActivity/GeneralStateTest.java | 44 ++++--- .../LoginActivity/LoggedOutStateTest.java | 5 +- .../MainActivity/AnonymousStateTest.java | 45 +++++-- .../AuthenticatedUserStateTest.java | 18 ++- .../MainActivity/GeneralStateTest.java | 11 +- .../MainActivity/LoggedOutStateTest.java | 13 +- .../SyncActivity/AnonymousStateTest.java | 19 +-- .../AuthenticatedUserStateTest.java | 19 +-- .../AnonymousStateTest.java | 35 +++-- .../AuthenticatedUserStateTest.java | 34 ++++- .../GeneralStateTest.java | 10 +- .../LoggedOutStateTest.java | 5 +- .../AdminAppPropertiesActivityTest.java | 10 +- ...onfigurableDeviceSettingsFragmentTest.java | 6 +- ...onfigurableServerSettingsFragmentTest.java | 7 +- ...onfigurableTablesSettingsFragmentTest.java | 5 +- .../GeneralDeviceSettingsFragmentTest.java | 5 +- .../fragments/VerifyUserPermissionTest.java | 21 ++- 21 files changed, 287 insertions(+), 159 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index feab5628..05d94d6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,19 +8,18 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: - checkout - - run: name: Chmod Permissions command: sudo chmod +x gradlew - android/create-avd: avd-name: Pixel_7_Pro - system-image: system-images;android-30;google_apis_playstore;x86_64 + system-image: system-images;android-30;google_apis;x86 install: true - run: @@ -48,7 +47,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - android/save-gradle-cache: cache-prefix: v1 @@ -101,4 +100,4 @@ workflows: - build - test: requires: - - build + - build \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index 7279013a..ceec9cd8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -3,10 +3,8 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.replaceText; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.android.gms.common.internal.Preconditions.checkNotNull; @@ -16,39 +14,21 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.os.RemoteException; -import android.view.InputDevice; -import android.view.MotionEvent; -import android.view.View; -import android.widget.CheckBox; -import android.widget.Checkable; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.preference.CheckBoxPreference; import android.view.View; import android.widget.Checkable; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.PerformException; import androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction; -import androidx.test.espresso.action.GeneralClickAction; -import androidx.test.espresso.action.Press; -import androidx.test.espresso.action.Tap; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; -import androidx.test.espresso.matcher.ViewMatchers; -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Rule; -import org.opendatakit.services.R; -import androidx.test.espresso.intent.Intents; -import androidx.test.espresso.matcher.BoundedMatcher; +import androidx.test.espresso.util.HumanReadables; +import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.GrantPermissionRule; @@ -57,14 +37,18 @@ import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; +import org.opendatakit.services.R; import org.opendatakit.utilities.LocalizationUtils; import org.opendatakit.utilities.ODKFileUtils; import java.io.File; +import java.util.concurrent.TimeoutException; public abstract class BaseUITest { + private static boolean isInitialized = false; protected final static String APP_NAME = "testAppName"; protected final static String TEST_SERVER_URL = "https://testUrl.com"; protected final static String TEST_PASSWORD = "testPassword"; @@ -78,34 +62,46 @@ public abstract class BaseUITest { protected ActivityScenario activityScenario; @Rule - public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule .grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); + public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); @Rule - public GrantPermissionRule readtimePermissionRule = GrantPermissionRule .grant(Manifest.permission.READ_EXTERNAL_STORAGE); + public GrantPermissionRule readtimePermissionRule = GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); @Before public void setUp() { - Intents.init(); + if (!isInitialized) { + System.out.println("Intents.init() called"); + Intents.init(); + isInitialized = true; + } + activityScenario = ActivityScenario.launch(getLaunchIntent()); setUpPostLaunch(); } - protected abstract void setUpPostLaunch(); - protected abstract Intent getLaunchIntent(); - @After public void tearDown() throws Exception { - if (activityScenario != null) activityScenario.close(); - Intents.release(); + if (activityScenario != null) { + activityScenario.close(); + activityScenario = null; + } + + if (isInitialized) { + System.out.println("Intents.release() called"); + Intents.release(); + isInitialized = false; + } } + + protected abstract void setUpPostLaunch(); + protected abstract Intent getLaunchIntent(); protected Context getContext() { return InstrumentationRegistry.getInstrumentation().getTargetContext(); } public void resetConfiguration() { - PropertiesSingleton mProps = CommonToolProperties.get(getContext() - , APP_NAME); + PropertiesSingleton mProps = CommonToolProperties.get(getContext(), APP_NAME); mProps.clearSettings(); LocalizationUtils.clearTranslations(); File f = new File(ODKFileUtils.getTablesInitializationCompleteMarkerFile(APP_NAME)); @@ -172,23 +168,62 @@ protected boolean matchesSafely(final RecyclerView view) { } }; } + public static ViewAction waitFor(long delay) { return new ViewAction() { - @Override public Matcher getConstraints() { - return ViewMatchers.isRoot(); + @Override + public Matcher getConstraints() { + return isRoot(); } - @Override public String getDescription() { - return "wait for " + delay + "milliseconds"; + @Override + public String getDescription() { + return "wait for " + delay + " milliseconds"; } - @Override public void perform(UiController uiController, View view) { + @Override + public void perform(UiController uiController, View view) { uiController.loopMainThreadForAtLeast(delay); } }; } - public static void enableAdminMode() { + public static ViewAction waitForView(final Matcher viewMatcher, final long millis) { + return new ViewAction() { + @Override + public Matcher getConstraints() { + return isRoot(); + } + + @Override + public String getDescription() { + return "Wait for a specific view with id <" + viewMatcher + "> during " + millis + " millis."; + } + + @Override + public void perform(final UiController uiController, final View view) { + final long startTime = System.currentTimeMillis(); + final long endTime = startTime + millis; + + do { + for (View child : TreeIterables.breadthFirstViewTraversal(view)) { + if (viewMatcher.matches(child)) { + return; + } + } + + uiController.loopMainThreadForAtLeast(50); + } while (System.currentTimeMillis() < endTime); + + throw new PerformException.Builder() + .withActionDescription(this.getDescription()) + .withViewDescription(HumanReadables.describe(view)) + .withCause(new TimeoutException()) + .build(); + } + }; + } + public static void enableAdminMode() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.user_restrictions)), click())); @@ -202,9 +237,7 @@ public static void enableAdminMode() { protected Activity getActivity() { final Activity[] activity1 = new Activity[1]; - activityScenario.onActivity(activity -> activity1[0] =activity); + activityScenario.onActivity(activity -> activity1[0] = activity); return activity1[0]; } - -} - +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java index e2585185..78237649 100644 --- a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java +++ b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java @@ -1,3 +1,4 @@ + package org.opendatakit; /** @@ -5,4 +6,7 @@ */ public class TestConsts { public static final String APPNAME = "unittestTMP"; + + public static final long WAIT_TIME = 2000; + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index f048dd1d..58e26532 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -1,27 +1,29 @@ package org.opendatakit.activites.LoginActivity; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; -import android.Manifest; import android.content.Intent; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import androidx.test.rule.GrantPermissionRule; +import androidx.test.rule.ActivityTestRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -35,10 +37,14 @@ public class GeneralStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(LoginActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -47,12 +53,13 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + onView(withId(R.id.tvTitleLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnAnonymousSignInLogin)).check(matches(withText(R.string.anonymous_user))); onView(withId(R.id.btnUserSignInLogin)).check(matches(withText(R.string.authenticated_user))); @@ -60,36 +67,37 @@ public void verifyValuesTest() { onView(withId(R.id.btnUserSignInLogin)).check(matches(isEnabled())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } - @Ignore // OUTREACHY-BROKEN-TEST + @Test public void checkDrawerServerLoginTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_server_login)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_server_login)).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(TEST_SERVER_URL))); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void checkDrawerSettingsClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_settings)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_settings)).perform(click()); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -99,4 +107,4 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java index a8672970..316fd212 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.activites.LoginActivity; import static androidx.test.espresso.Espresso.onView; @@ -6,7 +7,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; - import static com.google.common.truth.Truth.assertThat; import android.content.Intent; @@ -14,7 +14,6 @@ import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -44,13 +43,11 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { onView(withId(R.id.tvServerUrlLogin)).check(matches(withText(TEST_SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index 86ad1381..e7b0ea0e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -1,25 +1,40 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + +import android.content.Context; import android.content.Intent; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -59,7 +74,6 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -70,12 +84,11 @@ public void checkFirstStartupTest() { activity.recreate(); }); - onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(ViewActions.click()); + onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.action_sync)).check(matches(isDisplayed())); @@ -84,7 +97,7 @@ public void verifyVisibilityTest() { onView(withId(R.id.tvLastSyncTimeMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); onView(withId(R.id.btnSignInMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(withId(R.id.drawer_resolve_conflict)).check(matches(isDisplayed())); onView(withId(R.id.drawer_switch_sign_in_type)).check(matches(isDisplayed())); @@ -117,22 +130,24 @@ public void verifyLastSyncTimeTest() { @Test public void verifyToolbarSyncItemClick() { - onView(withId(R.id.action_sync)).perform(ViewActions.click()); + onView(withId(R.id.action_sync)).perform(click()); Intents.intended(IntentMatchers.hasComponent(SyncActivity.class.getName())); } @Test public void verifyDrawerResolveConflictsClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); + + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_resolve_conflict)).perform(click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSwitchSignInTypeClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_switch_sign_in_type)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_switch_sign_in_type)).perform(click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); @@ -141,10 +156,13 @@ public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.inputUsernameLogin)).check(matches(isDisplayed())); } - @Ignore // OUTREACHY-BROKEN-TEST + + @Ignore @Test public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); @@ -153,10 +171,13 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), MainActivity.class); intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index eb6e8b53..303b3f76 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -1,10 +1,12 @@ package org.opendatakit.activites.MainActivity; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -12,17 +14,16 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -188,16 +189,19 @@ public void verifyDrawerUpdateCredentialsClick() { onView(withId(R.id.inputTextUsername)).check(matches(withText(TEST_USERNAME))); onView(withId(R.id.inputTextPassword)).check(matches(withText(""))); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void verifyDrawerSignOutButtonClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); + onView(withId(R.id.btnDrawerLogin)).perform(click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index aed7dc9f..a9108601 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -5,23 +5,23 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -61,7 +61,6 @@ protected Intent getLaunchIntent() { return intent; } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -89,9 +88,12 @@ public void checkToolbarVerifyBtnClick() { Intents.intended(IntentMatchers.hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Ignore @Test public void checkToolbarSettingsBtnClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -123,4 +125,5 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 500066f7..90e13cb1 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -1,9 +1,11 @@ + package org.opendatakit.activites.MainActivity; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -11,17 +13,16 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -104,12 +105,16 @@ public void verifySignInButtonClickTest() { onView(withId(R.id.btnSignInMain)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void verifyDrawerSignInButtonClickTest() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java index eb97f186..82f9411a 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java @@ -17,15 +17,15 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -46,10 +46,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -62,8 +65,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -113,7 +117,6 @@ public void verifyLastSyncTimeTest() { onView(withId(R.id.tvLastSyncTimeSync)).check(matches(withText(DateTimeUtil.getDisplayDate(currentTime)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); @@ -155,4 +158,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvSignInWarnHeadingSync)).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java index 50165065..eb986c8c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java @@ -17,15 +17,15 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -47,10 +47,13 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -63,8 +66,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -102,7 +106,6 @@ public void verifyValuesTest() { onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_out_button_text)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); @@ -189,4 +192,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvSignInWarnHeadingSync)).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index fb9f35e7..24d6cb08 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -11,16 +11,17 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -36,10 +37,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -52,9 +56,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); - + Espresso.onIdle(); } @Override @@ -89,10 +93,25 @@ public void verifyValuesTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } + @Test public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); @@ -113,4 +132,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvUserHeadingVerifySettings)).check(matches(withText(getContext().getString(R.string.user_logged_out_label)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index 15ec28be..3e07e0c5 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -12,16 +12,17 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -40,10 +41,14 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -56,8 +61,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -108,7 +114,21 @@ public void verifyLastSyncTimeTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @@ -165,4 +185,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvUserHeadingVerifySettings)).check(matches(withText(getContext().getString(R.string.user_logged_out_label)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 436346e4..2c776ea8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -5,22 +5,22 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -69,9 +69,11 @@ public void verifyValuesTest() { @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); @@ -100,4 +102,4 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java index dd91cb2a..395fc01f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java @@ -10,14 +10,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -83,4 +80,4 @@ public void verifyDrawerSignInButtonClick() { onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java index e1113e69..024e1bcf 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java @@ -37,7 +37,7 @@ protected void setUpPostLaunch() { enableAdminMode(); Espresso.pressBack(); } - + @Ignore @Test public void checkIfChangeAdminPasswordScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(3, scrollTo())) @@ -46,7 +46,7 @@ public void checkIfChangeAdminPasswordScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 3), isDisplayed())).check(matches(withText(R.string.admin_password_enabled))); } - + @Ignore @Test public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(8, scrollTo())) @@ -56,7 +56,7 @@ public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.restrict_server_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(9, scrollTo())) @@ -65,7 +65,7 @@ public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 9), isDisplayed())).check(matches(withText(R.string.restrict_device_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(10, scrollTo())) @@ -75,6 +75,7 @@ public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.admin_tool_tables_settings_summary))); } + @Ignore @Test public void checkIfResetConfigurationScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(6, scrollTo())) @@ -84,6 +85,7 @@ public void checkIfResetConfigurationScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.clear_configuration_settings))); } + @Ignore @Test public void checkIfExitAdminModeScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(11, scrollTo())) diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java index 1c074ad3..72ce6f3a 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; import static androidx.test.espresso.Espresso.onView; @@ -21,9 +22,9 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -102,7 +103,7 @@ private void launchDeviceSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.preferences)), @@ -120,4 +121,3 @@ public void setCheckboxValue(boolean checked) { } - diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java index 3a12d59a..21af2357 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java @@ -2,9 +2,7 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.action.ViewActions.replaceText; import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isClickable; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -20,13 +18,12 @@ import android.content.Intent; import androidx.test.espresso.Espresso; -import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -117,7 +114,7 @@ public void launchServerSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.server)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java index 17a8fffb..7ec2829f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; @@ -22,9 +23,9 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -94,7 +95,7 @@ private void launchTableServerSettingPreferenceScreen() { .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.odkx_tables)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java index 48370f24..0c4e44e7 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; import static androidx.test.espresso.Espresso.onView; @@ -17,7 +18,6 @@ import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -41,6 +41,7 @@ protected void setUpPostLaunch() { } + @Test public void whenTextFontSizeIsClicked_doChangeFontSize_checkIfSizeIsExtraLarge() { onView(withId(androidx.preference.R.id.recycler_view)) @@ -112,4 +113,4 @@ protected Intent getLaunchIntent() { return intent; } -} \ No newline at end of file +} diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 1780ff5c..a2e4ea4f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -8,19 +8,19 @@ import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.allOf; import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -47,19 +47,28 @@ public void whenVerifyUserPermissionScreenIsClicked_launchVerifyServerSettingsAc intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Test public void whenVerifyUserPermissionIsClicked_configureServerUrl() { resetConfiguration(); - onView(withId(androidx.preference.R.id.recycler_view)) - .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.verify_server_settings_header)), - click())); + + onView(withId(androidx.preference.R.id.recycler_view)).check(matches(isDisplayed())); + onView(withId(androidx.preference.R.id.recycler_view)).perform(RecyclerViewActions.actionOnItem( + hasDescendant(withText(R.string.verify_server_settings_header)), click())); + + onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), TestConsts.WAIT_TIME)); onView(withText(R.string.configure_server_settings)) .inRoot(isDialog()) .check(matches(isDisplayed())); + + onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), TestConsts.WAIT_TIME)); onView(allOf(withId(android.R.id.button1), withText(R.string.yes))).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), AppPropertiesActivity.class); @@ -67,4 +76,4 @@ protected Intent getLaunchIntent() { return intent; } -} +} \ No newline at end of file From 18cce2cf2285114fcaa2e9bc5f037a85f77649ba Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:50:59 +0100 Subject: [PATCH 21/21] rebased stable branch drop2 Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml Update config.yml new stable branch --- .circleci/config.yml | 43 +++++-- .../java/org/opendatakit/BaseUITest.java | 121 +++++++++++------- .../java/org/opendatakit/TestConsts.java | 4 + .../LoginActivity/GeneralStateTest.java | 44 ++++--- .../LoginActivity/LoggedOutStateTest.java | 5 +- .../MainActivity/AnonymousStateTest.java | 45 +++++-- .../AuthenticatedUserStateTest.java | 18 ++- .../MainActivity/GeneralStateTest.java | 11 +- .../MainActivity/LoggedOutStateTest.java | 13 +- .../SyncActivity/AnonymousStateTest.java | 19 +-- .../AuthenticatedUserStateTest.java | 19 +-- .../AnonymousStateTest.java | 35 +++-- .../AuthenticatedUserStateTest.java | 34 ++++- .../GeneralStateTest.java | 10 +- .../LoggedOutStateTest.java | 5 +- .../AdminAppPropertiesActivityTest.java | 10 +- ...onfigurableDeviceSettingsFragmentTest.java | 6 +- ...onfigurableServerSettingsFragmentTest.java | 7 +- ...onfigurableTablesSettingsFragmentTest.java | 5 +- .../GeneralDeviceSettingsFragmentTest.java | 5 +- .../fragments/VerifyUserPermissionTest.java | 21 ++- 21 files changed, 318 insertions(+), 162 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f94a866c..05d94d6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -18,25 +18,44 @@ jobs: command: sudo chmod +x gradlew - android/create-avd: - avd-name: avd + avd-name: Pixel_7_Pro + system-image: system-images;android-30;google_apis;x86 install: true - system-image: system-images;android-29;default;x86 + + - run: + name: Start ADB server + command: adb start-server + - android/start-emulator: - avd-name: avd + avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 - memory: 4096 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + memory: 4096 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + + - run: + name: Wait for Emulator to be Ready + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + + - run: + name: Restart ADB server + command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + - android/save-gradle-cache: cache-prefix: v1 + - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results + - store_artifacts: name: Store Test Reports path: services_app/build/reports @@ -44,24 +63,32 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/restore-gradle-cache: cache-prefix: v1 + - run: name: Download Dependencies command: ./gradlew androidDependencies + - android/save-gradle-cache: cache-prefix: v1 + - run: name: Build Services command: ./gradlew assembleSnapshotDebug + - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk + - persist_to_workspace: root: . paths: @@ -73,4 +100,4 @@ workflows: - build - test: requires: - - build + - build \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index 7279013a..ceec9cd8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -3,10 +3,8 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.replaceText; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.android.gms.common.internal.Preconditions.checkNotNull; @@ -16,39 +14,21 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.os.RemoteException; -import android.view.InputDevice; -import android.view.MotionEvent; -import android.view.View; -import android.widget.CheckBox; -import android.widget.Checkable; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.preference.CheckBoxPreference; import android.view.View; import android.widget.Checkable; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.PerformException; import androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction; -import androidx.test.espresso.action.GeneralClickAction; -import androidx.test.espresso.action.Press; -import androidx.test.espresso.action.Tap; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; -import androidx.test.espresso.matcher.ViewMatchers; -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Rule; -import org.opendatakit.services.R; -import androidx.test.espresso.intent.Intents; -import androidx.test.espresso.matcher.BoundedMatcher; +import androidx.test.espresso.util.HumanReadables; +import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.GrantPermissionRule; @@ -57,14 +37,18 @@ import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; +import org.opendatakit.services.R; import org.opendatakit.utilities.LocalizationUtils; import org.opendatakit.utilities.ODKFileUtils; import java.io.File; +import java.util.concurrent.TimeoutException; public abstract class BaseUITest { + private static boolean isInitialized = false; protected final static String APP_NAME = "testAppName"; protected final static String TEST_SERVER_URL = "https://testUrl.com"; protected final static String TEST_PASSWORD = "testPassword"; @@ -78,34 +62,46 @@ public abstract class BaseUITest { protected ActivityScenario activityScenario; @Rule - public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule .grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); + public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); @Rule - public GrantPermissionRule readtimePermissionRule = GrantPermissionRule .grant(Manifest.permission.READ_EXTERNAL_STORAGE); + public GrantPermissionRule readtimePermissionRule = GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); @Before public void setUp() { - Intents.init(); + if (!isInitialized) { + System.out.println("Intents.init() called"); + Intents.init(); + isInitialized = true; + } + activityScenario = ActivityScenario.launch(getLaunchIntent()); setUpPostLaunch(); } - protected abstract void setUpPostLaunch(); - protected abstract Intent getLaunchIntent(); - @After public void tearDown() throws Exception { - if (activityScenario != null) activityScenario.close(); - Intents.release(); + if (activityScenario != null) { + activityScenario.close(); + activityScenario = null; + } + + if (isInitialized) { + System.out.println("Intents.release() called"); + Intents.release(); + isInitialized = false; + } } + + protected abstract void setUpPostLaunch(); + protected abstract Intent getLaunchIntent(); protected Context getContext() { return InstrumentationRegistry.getInstrumentation().getTargetContext(); } public void resetConfiguration() { - PropertiesSingleton mProps = CommonToolProperties.get(getContext() - , APP_NAME); + PropertiesSingleton mProps = CommonToolProperties.get(getContext(), APP_NAME); mProps.clearSettings(); LocalizationUtils.clearTranslations(); File f = new File(ODKFileUtils.getTablesInitializationCompleteMarkerFile(APP_NAME)); @@ -172,23 +168,62 @@ protected boolean matchesSafely(final RecyclerView view) { } }; } + public static ViewAction waitFor(long delay) { return new ViewAction() { - @Override public Matcher getConstraints() { - return ViewMatchers.isRoot(); + @Override + public Matcher getConstraints() { + return isRoot(); } - @Override public String getDescription() { - return "wait for " + delay + "milliseconds"; + @Override + public String getDescription() { + return "wait for " + delay + " milliseconds"; } - @Override public void perform(UiController uiController, View view) { + @Override + public void perform(UiController uiController, View view) { uiController.loopMainThreadForAtLeast(delay); } }; } - public static void enableAdminMode() { + public static ViewAction waitForView(final Matcher viewMatcher, final long millis) { + return new ViewAction() { + @Override + public Matcher getConstraints() { + return isRoot(); + } + + @Override + public String getDescription() { + return "Wait for a specific view with id <" + viewMatcher + "> during " + millis + " millis."; + } + + @Override + public void perform(final UiController uiController, final View view) { + final long startTime = System.currentTimeMillis(); + final long endTime = startTime + millis; + + do { + for (View child : TreeIterables.breadthFirstViewTraversal(view)) { + if (viewMatcher.matches(child)) { + return; + } + } + + uiController.loopMainThreadForAtLeast(50); + } while (System.currentTimeMillis() < endTime); + + throw new PerformException.Builder() + .withActionDescription(this.getDescription()) + .withViewDescription(HumanReadables.describe(view)) + .withCause(new TimeoutException()) + .build(); + } + }; + } + public static void enableAdminMode() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.user_restrictions)), click())); @@ -202,9 +237,7 @@ public static void enableAdminMode() { protected Activity getActivity() { final Activity[] activity1 = new Activity[1]; - activityScenario.onActivity(activity -> activity1[0] =activity); + activityScenario.onActivity(activity -> activity1[0] = activity); return activity1[0]; } - -} - +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java index e2585185..78237649 100644 --- a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java +++ b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java @@ -1,3 +1,4 @@ + package org.opendatakit; /** @@ -5,4 +6,7 @@ */ public class TestConsts { public static final String APPNAME = "unittestTMP"; + + public static final long WAIT_TIME = 2000; + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index f048dd1d..58e26532 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -1,27 +1,29 @@ package org.opendatakit.activites.LoginActivity; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; -import android.Manifest; import android.content.Intent; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import androidx.test.rule.GrantPermissionRule; +import androidx.test.rule.ActivityTestRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -35,10 +37,14 @@ public class GeneralStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(LoginActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -47,12 +53,13 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + onView(withId(R.id.tvTitleLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnAnonymousSignInLogin)).check(matches(withText(R.string.anonymous_user))); onView(withId(R.id.btnUserSignInLogin)).check(matches(withText(R.string.authenticated_user))); @@ -60,36 +67,37 @@ public void verifyValuesTest() { onView(withId(R.id.btnUserSignInLogin)).check(matches(isEnabled())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } - @Ignore // OUTREACHY-BROKEN-TEST + @Test public void checkDrawerServerLoginTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_server_login)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_server_login)).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(TEST_SERVER_URL))); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void checkDrawerSettingsClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_settings)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_settings)).perform(click()); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -99,4 +107,4 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java index a8672970..316fd212 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.activites.LoginActivity; import static androidx.test.espresso.Espresso.onView; @@ -6,7 +7,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; - import static com.google.common.truth.Truth.assertThat; import android.content.Intent; @@ -14,7 +14,6 @@ import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -44,13 +43,11 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { onView(withId(R.id.tvServerUrlLogin)).check(matches(withText(TEST_SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index 86ad1381..e7b0ea0e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -1,25 +1,40 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + +import android.content.Context; import android.content.Intent; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -59,7 +74,6 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -70,12 +84,11 @@ public void checkFirstStartupTest() { activity.recreate(); }); - onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(ViewActions.click()); + onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.action_sync)).check(matches(isDisplayed())); @@ -84,7 +97,7 @@ public void verifyVisibilityTest() { onView(withId(R.id.tvLastSyncTimeMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); onView(withId(R.id.btnSignInMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(withId(R.id.drawer_resolve_conflict)).check(matches(isDisplayed())); onView(withId(R.id.drawer_switch_sign_in_type)).check(matches(isDisplayed())); @@ -117,22 +130,24 @@ public void verifyLastSyncTimeTest() { @Test public void verifyToolbarSyncItemClick() { - onView(withId(R.id.action_sync)).perform(ViewActions.click()); + onView(withId(R.id.action_sync)).perform(click()); Intents.intended(IntentMatchers.hasComponent(SyncActivity.class.getName())); } @Test public void verifyDrawerResolveConflictsClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); + + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_resolve_conflict)).perform(click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSwitchSignInTypeClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_switch_sign_in_type)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_switch_sign_in_type)).perform(click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); @@ -141,10 +156,13 @@ public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.inputUsernameLogin)).check(matches(isDisplayed())); } - @Ignore // OUTREACHY-BROKEN-TEST + + @Ignore @Test public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); @@ -153,10 +171,13 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), MainActivity.class); intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index eb6e8b53..303b3f76 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -1,10 +1,12 @@ package org.opendatakit.activites.MainActivity; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -12,17 +14,16 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -188,16 +189,19 @@ public void verifyDrawerUpdateCredentialsClick() { onView(withId(R.id.inputTextUsername)).check(matches(withText(TEST_USERNAME))); onView(withId(R.id.inputTextPassword)).check(matches(withText(""))); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void verifyDrawerSignOutButtonClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); + onView(withId(R.id.btnDrawerLogin)).perform(click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index aed7dc9f..a9108601 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -5,23 +5,23 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -61,7 +61,6 @@ protected Intent getLaunchIntent() { return intent; } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -89,9 +88,12 @@ public void checkToolbarVerifyBtnClick() { Intents.intended(IntentMatchers.hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Ignore @Test public void checkToolbarSettingsBtnClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -123,4 +125,5 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } -} + +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 500066f7..90e13cb1 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -1,9 +1,11 @@ + package org.opendatakit.activites.MainActivity; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -11,17 +13,16 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -104,12 +105,16 @@ public void verifySignInButtonClickTest() { onView(withId(R.id.btnSignInMain)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } - - @Ignore // OUTREACHY-BROKEN-TEST + @Ignore @Test public void verifyDrawerSignInButtonClickTest() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java index eb97f186..82f9411a 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java @@ -17,15 +17,15 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -46,10 +46,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -62,8 +65,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -113,7 +117,6 @@ public void verifyLastSyncTimeTest() { onView(withId(R.id.tvLastSyncTimeSync)).check(matches(withText(DateTimeUtil.getDisplayDate(currentTime)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); @@ -155,4 +158,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvSignInWarnHeadingSync)).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java index 50165065..eb986c8c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java @@ -17,15 +17,15 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -47,10 +47,13 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -63,8 +66,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -102,7 +106,6 @@ public void verifyValuesTest() { onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_out_button_text)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); @@ -189,4 +192,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvSignInWarnHeadingSync)).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index fb9f35e7..24d6cb08 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -11,16 +11,17 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -36,10 +37,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -52,9 +56,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); - + Espresso.onIdle(); } @Override @@ -89,10 +93,25 @@ public void verifyValuesTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } + @Test public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); @@ -113,4 +132,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvUserHeadingVerifySettings)).check(matches(withText(getContext().getString(R.string.user_logged_out_label)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index 15ec28be..3e07e0c5 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -12,16 +12,17 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; -import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -40,10 +41,14 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -56,8 +61,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -108,7 +114,21 @@ public void verifyLastSyncTimeTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(TestConsts.WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @@ -165,4 +185,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.tvUserHeadingVerifySettings)).check(matches(withText(getContext().getString(R.string.user_logged_out_label)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 436346e4..2c776ea8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -5,22 +5,22 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -69,9 +69,11 @@ public void verifyValuesTest() { @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); @@ -100,4 +102,4 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java index dd91cb2a..395fc01f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java @@ -10,14 +10,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -83,4 +80,4 @@ public void verifyDrawerSignInButtonClick() { onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java index e1113e69..024e1bcf 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java @@ -37,7 +37,7 @@ protected void setUpPostLaunch() { enableAdminMode(); Espresso.pressBack(); } - + @Ignore @Test public void checkIfChangeAdminPasswordScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(3, scrollTo())) @@ -46,7 +46,7 @@ public void checkIfChangeAdminPasswordScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 3), isDisplayed())).check(matches(withText(R.string.admin_password_enabled))); } - + @Ignore @Test public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(8, scrollTo())) @@ -56,7 +56,7 @@ public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.restrict_server_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(9, scrollTo())) @@ -65,7 +65,7 @@ public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 9), isDisplayed())).check(matches(withText(R.string.restrict_device_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(10, scrollTo())) @@ -75,6 +75,7 @@ public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.admin_tool_tables_settings_summary))); } + @Ignore @Test public void checkIfResetConfigurationScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(6, scrollTo())) @@ -84,6 +85,7 @@ public void checkIfResetConfigurationScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.clear_configuration_settings))); } + @Ignore @Test public void checkIfExitAdminModeScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(11, scrollTo())) diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java index 1c074ad3..72ce6f3a 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; import static androidx.test.espresso.Espresso.onView; @@ -21,9 +22,9 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -102,7 +103,7 @@ private void launchDeviceSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.preferences)), @@ -120,4 +121,3 @@ public void setCheckboxValue(boolean checked) { } - diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java index 3a12d59a..21af2357 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java @@ -2,9 +2,7 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.action.ViewActions.replaceText; import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isClickable; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -20,13 +18,12 @@ import android.content.Intent; import androidx.test.espresso.Espresso; -import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -117,7 +114,7 @@ public void launchServerSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.server)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java index 17a8fffb..7ec2829f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; @@ -22,9 +23,9 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -94,7 +95,7 @@ private void launchTableServerSettingPreferenceScreen() { .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.odkx_tables)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java index 48370f24..0c4e44e7 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java @@ -1,3 +1,4 @@ + package org.opendatakit.services.preferences.fragments; import static androidx.test.espresso.Espresso.onView; @@ -17,7 +18,6 @@ import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -41,6 +41,7 @@ protected void setUpPostLaunch() { } + @Test public void whenTextFontSizeIsClicked_doChangeFontSize_checkIfSizeIsExtraLarge() { onView(withId(androidx.preference.R.id.recycler_view)) @@ -112,4 +113,4 @@ protected Intent getLaunchIntent() { return intent; } -} \ No newline at end of file +} diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 1780ff5c..a2e4ea4f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -8,19 +8,19 @@ import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.allOf; import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -47,19 +47,28 @@ public void whenVerifyUserPermissionScreenIsClicked_launchVerifyServerSettingsAc intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Test public void whenVerifyUserPermissionIsClicked_configureServerUrl() { resetConfiguration(); - onView(withId(androidx.preference.R.id.recycler_view)) - .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.verify_server_settings_header)), - click())); + + onView(withId(androidx.preference.R.id.recycler_view)).check(matches(isDisplayed())); + onView(withId(androidx.preference.R.id.recycler_view)).perform(RecyclerViewActions.actionOnItem( + hasDescendant(withText(R.string.verify_server_settings_header)), click())); + + onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), TestConsts.WAIT_TIME)); onView(withText(R.string.configure_server_settings)) .inRoot(isDialog()) .check(matches(isDisplayed())); + + onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), TestConsts.WAIT_TIME)); onView(allOf(withId(android.R.id.button1), withText(R.string.yes))).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), AppPropertiesActivity.class); @@ -67,4 +76,4 @@ protected Intent getLaunchIntent() { return intent; } -} +} \ No newline at end of file