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. Unlike host-side JUnit tests below, instrumentation tests cannot run without an active device.
To start the recommended local development emulator (x64 image, emulator window, and networking enabled):
tools/android/avd/avd.py start -v \ --avd-config tools/android/avd/proto/android_google_apis_x64_local.textpb \ --emulator-window --no-read-only --enable-network
For more options and configuration details, see:
Clank Noogler Guide: Step 5 - Start an emulator (Google internal)
Clank Android Emulator Tips (Google internal)
TWA and General Webapp UI/Lifecycle:
chrome/android/javatests/src/org/chromium/chrome/browser/webapps/Trusted Web Activities (TWA) & Permission Delegation:
chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/ (and subdirectories like permissiondelegation/)How to Run: Use tools/autotest.py to automatically compile and execute a test file:
tools/autotest.py -C out/Android chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappActivityTest.java
Or build and run all tests in a directory via the test runner script:
autoninja -C out/Android chrome_public_test_apk out/Android/bin/run_chrome_public_test_apk -f "org.chromium.chrome.browser.webapps.*" out/Android/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 an emulator or 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, and WebappDataStorage.How to Run: Use tools/autotest.py:
tools/autotest.py -C out/Android chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappAuthenticatorTest.java
Or build and run via the test runner script:
autoninja -C out/Android chrome_junit_tests out/Android/bin/run_chrome_junit_tests -f "org.chromium.chrome.browser.webapps.*" out/Android/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*"