components/webapps/docs/android_testing_guide.md
This document describes how to test Android Web Apps (WebAPKs and TWAs) manually and via automated tests.
To test manually using an emulator:
You can use a public PWA (like https://pokedex.org) or serve one locally.
https://pokedex.org.python3 -m http.server 8000.adb reverse tcp:8000 tcp:8000.To trust a TWA or WebAPK during local testing with developer builds, you must bypass Chrome's security checks.
Chrome requires DAL verification to run a TWA in app mode. To bypass this for a test URL:
--disable-digital-asset-link-verification-for-url="https://pokedex.org"out/Default/bin/chrome_public_apk launch --args="--disable-digital-asset-link-verification-for-url=https://pokedex.org"chrome://flags):
adb shell "echo '_ --disable-digital-asset-link-verification-for-url=https://pokedex.org' > /data/local/tmp/chrome-command-line"Chrome verifies that WebAPKs are signed by the trusted WebAPK minting server. Locally built debug WebAPKs will fail this check. To bypass this:
--skip-webapk-verificationout/Default/bin/chrome_public_apk launch --args="--skip-webapk-verification"You can use Bubblewrap to
generate an APK for your test site and install it:
adb install path/to/generated.apk
To test WebAPK installation:
https://pokedex.org).Chromium has several test suites that cover Web App functionality on Android. To keep this guide maintainable, tests are grouped by directory and feature area.
These tests run on an emulator or physical device to test UI, integration, and lifecycle.
chrome/android/javatests/src/org/chromium/chrome/browser/webapps/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/
(and subdirectories like permissiondelegation/)How to Run: Build the test APK:
autoninja -C out/Default chrome_public_test_apk
Run all tests in a directory:
out/Default/bin/run_chrome_public_test_apk -f "org.chromium.chrome.browser.webapps.*"
out/Default/bin/run_chrome_public_test_apk -f "org.chromium.chrome.browser.browserservices.*"
These unit tests run on the development host JVM and test business logic, storage, and utility classes without requiring a device.
chrome/android/junit/src/org/chromium/chrome/browser/webapps/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/
(including permissiondelegation/ and ui/)InstalledWebappRegistrar, InstalledWebappDataRegister,
WebappDataStorage, and WebApkSyncService.How to Run:
out/Default/bin/run_chrome_junit_tests -f "org.chromium.chrome.browser.webapps.*"
out/Default/bin/run_chrome_junit_tests -f "org.chromium.chrome.browser.browserservices.*"
These tests focus on the WebAPK client-side library and the shell APK code.
chrome/android/webapk/libs/client/junit/
(Host-side JUnit)chrome/android/webapk/libs/runtime_library/javatests/
(Instrumentation)chrome/android/webapk/shell_apk/junit/
(Host-side JUnit)chrome/android/webapk/shell_apk/javatests/
(Instrumentation)How to Run: Check
chrome/android/webapk/README.md
for instructions on running these specialized tests.
These tests cover the shared native code integration.
components/webapps/browser/android/components/webapps/browser/banners/ (Shared, but
relevant to Android promotion)components/webapps/browser/installable/
(Shared, but relevant to Android installability)Add-to-homescreen data fetching, WebAPK proto building, icon
hashing, and install prompt settings.How to Run: Build and run components_unittests on Android:
autoninja -C out/Default components_unittests
out/Default/bin/run_components_unittests --gtest_filter="*AddToHomescreen*"