Skip to content

Commit

Permalink
androidx orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
sugarmanz committed Dec 1, 2023
1 parent 9d68dac commit d58ad34
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 27 deletions.
38 changes: 13 additions & 25 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ workspace(
},
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
Expand Down Expand Up @@ -106,30 +106,6 @@ load("@grab_bazel_common//android:initialize.bzl", "bazel_common_initialize")
bazel_common_initialize(
pinned_maven_install = False,
)
#
#load("@grab_bazel_common//android:maven.bzl", "pin_bazel_common_artifacts")
#
#pin_bazel_common_artifacts()

# Optional patched Android Tools
#load("@grab_bazel_common//:workspace_defs.bzl", "android_tools")
#
#android_tools(
# commit = grab_commit,
# remote = grab_remote,
# shallow_since = "1654123549 -0400",
#)

#DAGGER_TAG = "2.43.2"
#
#DAGGER_SHA = "f7fbc3e417b3cdc10e76e818a6854ada777ad6d408408b65c23a096f3ff6daf7"
#
#http_archive(
# name = "dagger",
# sha256 = DAGGER_SHA,
# strip_prefix = "dagger-dagger-%s" % DAGGER_TAG,
# url = "https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG,
#)

http_archive(
name = "robolectric",
Expand All @@ -142,6 +118,18 @@ load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")

robolectric_repositories()

ANDROIDX_TEST_VERSION = "1.4.2"

http_file(
name = "android_test_orchestrator_apk",
url = "https://dl.google.com/android/maven2/androidx/test/orchestrator/1.4.2/orchestrator-1.4.2.apk",
)

http_file(
name = "android_test_services_apk",
url = "https://dl.google.com/android/maven2/androidx/test/services/test-services/1.4.2/test-services-1.4.2.apk",
)

http_archive(
name = "build_bazel_rules_android",
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
Expand Down
2 changes: 2 additions & 0 deletions android/demo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ sh_test(
data = [
":demo",
":demo_test_app",
"@android_test_orchestrator_apk//file",
"@android_test_services_apk//file",
],
)

Expand Down
28 changes: 26 additions & 2 deletions android/demo/scripts/androidtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,29 @@

set -u -e -o pipefail

# Install app to test
adb install android/demo/demo.apk

# Install test app
adb install android/demo/demo_test_app.apk

DEVICE_API_LEVEL=$(adb shell getprop ro.build.version.sdk)

FORCE_QUERYABLE_OPTION=""
if [[ $DEVICE_API_LEVEL -ge 30 ]]; then
FORCE_QUERYABLE_OPTION="--force-queryable"
fi

# TODO: Hooks up properly to runfiles
cp external/android_test_orchestrator_apk/file/downloaded orchestrator.apk
cp external/android_test_services_apk/file/downloaded test_services.apk

# Install the test orchestrator.
adb install $FORCE_QUERYABLE_OPTION -r orchestrator.apk

# Install test services.
adb install $FORCE_QUERYABLE_OPTION -r test_services.apk

adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
Expand All @@ -31,10 +51,14 @@ t.dameon = True
t.start()
def run():
os.system('adb wait-for-device')
p = sp.Popen('adb shell am instrument -w com.intuit.player.android.reference.demo.test/androidx.test.runner.AndroidJUnitRunner',
p = sp.Popen("""adb shell 'CLASSPATH=\$(pm path androidx.test.services) app_process / \
androidx.test.services.shellexecutor.ShellMain am instrument -w -e clearPackageData true \
-e targetInstrumentation com.intuit.player.android.reference.demo.test/androidx.test.runner.AndroidJUnitRunner \
androidx.test.orchestrator/.AndroidTestOrchestrator'""",
shell=True, stdout=sp.PIPE, stderr=sp.PIPE, stdin=sp.PIPE)
return p.communicate()
success = re.compile(r'OK \(\d+ tests\)')
success = re.compile(r'OK \(\d+ test(s)?\)')
stdout, stderr = run()
done = True
print stderr
Expand Down

0 comments on commit d58ad34

Please sign in to comment.