fix(android): fix android tests (#8209)
This commit is contained in:
parent
39f663834f
commit
bdb772d710
|
|
@ -52,14 +52,18 @@ export const androidFixtures: Fixtures<PageTestFixtures, AndroidWorkerFixtures &
|
|||
isElectron: false,
|
||||
|
||||
androidContext: [ async ({ androidDevice }, run) => {
|
||||
await run(await androidDevice.launchBrowser());
|
||||
const context = await androidDevice.launchBrowser();
|
||||
const [ page ] = context.pages();
|
||||
await page.goto('data:text/html,Default page');
|
||||
await run(context);
|
||||
}, { scope: 'worker' } ],
|
||||
|
||||
page: async ({ androidContext }, run) => {
|
||||
// Retain default page, otherwise Clank will re-create it.
|
||||
while (androidContext.pages().length > 1)
|
||||
await androidContext.pages()[1].close();
|
||||
const page = await androidContext.newPage();
|
||||
await run(page);
|
||||
for (const page of androidContext.pages())
|
||||
await page.close();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
import { androidTest as test, expect } from './androidTest';
|
||||
|
||||
test('androidDevice.model', async function({ androidDevice }) {
|
||||
expect(androidDevice.model()).toBe('sdk_gphone_x86_arm');
|
||||
expect(androidDevice.model()).toBe('sdk_gphone64_x86_64');
|
||||
});
|
||||
|
||||
test('androidDevice.launchBrowser', async function({ androidDevice }) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ mkdir ${SDKDIR}/cmdline-tools
|
|||
echo Downloading Android SDK...
|
||||
cd ${SDKDIR}/cmdline-tools
|
||||
COMMAND_LINE_TOOLS_ZIP=${SDKDIR}/commandlinetools.zip
|
||||
curl https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip -o ${COMMAND_LINE_TOOLS_ZIP}
|
||||
curl https://dl.google.com/android/repository/commandlinetools-mac-7583922_latest.zip -o ${COMMAND_LINE_TOOLS_ZIP}
|
||||
unzip ${COMMAND_LINE_TOOLS_ZIP}
|
||||
rm ${COMMAND_LINE_TOOLS_ZIP}
|
||||
mv cmdline-tools latest
|
||||
|
|
@ -23,7 +23,7 @@ echo Installing emulator...
|
|||
yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install platform-tools emulator
|
||||
|
||||
echo Installing platform SDK...
|
||||
yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install "platforms;android-30"
|
||||
yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install "platforms;android-31"
|
||||
|
||||
echo Starting ADB...
|
||||
${ANDROID_HOME}/platform-tools/adb devices
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ if [[ -z "${ANDROID_HOME}" ]]; then
|
|||
export ANDROID_SDK_ROOT=${SDKDIR}
|
||||
fi
|
||||
|
||||
${ANDROID_HOME}/tools/bin/avdmanager delete avd --name android30 || true
|
||||
echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-30;google_apis;x86"
|
||||
echo "no" | ${ANDROID_HOME}/tools/bin/avdmanager create avd --force --name android30 --device "Nexus 5X" --package "system-images;android-30;google_apis;x86"
|
||||
${ANDROID_HOME}/tools/bin/avdmanager delete avd --name android31 || true
|
||||
echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-31;google_apis;x86_64"
|
||||
echo "no" | ${ANDROID_HOME}/tools/bin/avdmanager create avd --force --name android31 --device "Nexus 5X" --package "system-images;android-31;google_apis;x86_64"
|
||||
${ANDROID_HOME}/emulator/emulator -list-avds
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ echo "Killing previous emulators"
|
|||
${ANDROID_HOME}/platform-tools/adb devices | grep emulator | cut -f1 | while read line; do ${ANDROID_HOME}/platform-tools/adb -s $line emu kill; done
|
||||
|
||||
echo "Starting emulator"
|
||||
nohup ${ANDROID_HOME}/emulator/emulator -avd android30 -no-audio -gpu swiftshader &
|
||||
nohup ${ANDROID_HOME}/emulator/emulator -avd android31 -no-audio &
|
||||
${ANDROID_HOME}/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
|
||||
${ANDROID_HOME}/platform-tools/adb devices
|
||||
echo "Emulator started"
|
||||
Loading…
Reference in a new issue