chore(android): respect timeout, add build script (#4690)
This commit is contained in:
parent
f20518f252
commit
aa1b546bd0
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -17,3 +17,4 @@ jest-report.json
|
||||||
drivers/
|
drivers/
|
||||||
/docs/api.json
|
/docs/api.json
|
||||||
.android-sdk/
|
.android-sdk/
|
||||||
|
.gradle/
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -30,7 +30,8 @@
|
||||||
"typecheck-tests": "tsc -p ./test/",
|
"typecheck-tests": "tsc -p ./test/",
|
||||||
"roll-browser": "node utils/roll_browser.js",
|
"roll-browser": "node utils/roll_browser.js",
|
||||||
"coverage": "node test/checkCoverage.js",
|
"coverage": "node test/checkCoverage.js",
|
||||||
"check-deps": "node utils/check_deps.js"
|
"check-deps": "node utils/check_deps.js",
|
||||||
|
"build-android-driver": "./utils/build_android_driver.sh"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Microsoft Corporation"
|
"name": "Microsoft Corporation"
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export interface SocketBackend extends EventEmitter {
|
||||||
|
|
||||||
export class Android {
|
export class Android {
|
||||||
private _backend: Backend;
|
private _backend: Backend;
|
||||||
|
private _devices = new Map<string, AndroidDevice>();
|
||||||
readonly _timeoutSettings: TimeoutSettings;
|
readonly _timeoutSettings: TimeoutSettings;
|
||||||
|
|
||||||
constructor(backend: Backend) {
|
constructor(backend: Backend) {
|
||||||
|
|
@ -67,7 +68,19 @@ export class Android {
|
||||||
|
|
||||||
async devices(): Promise<AndroidDevice[]> {
|
async devices(): Promise<AndroidDevice[]> {
|
||||||
const devices = (await this._backend.devices()).filter(d => d.status === 'device');
|
const devices = (await this._backend.devices()).filter(d => d.status === 'device');
|
||||||
return await Promise.all(devices.map(d => AndroidDevice.create(this, d)));
|
const newSerials = new Set<string>();
|
||||||
|
for (const d of devices) {
|
||||||
|
newSerials.add(d.serial);
|
||||||
|
if (this._devices.has(d.serial))
|
||||||
|
continue;
|
||||||
|
const device = await AndroidDevice.create(this, d);
|
||||||
|
this._devices.set(d.serial, device);
|
||||||
|
}
|
||||||
|
for (const d of this._devices.keys()) {
|
||||||
|
if (!newSerials.has(d))
|
||||||
|
this._devices.delete(d);
|
||||||
|
}
|
||||||
|
return [...this._devices.values()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,14 @@ public class InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UiObject2 wait(UiDevice device, JSONObject params) throws JSONException {
|
private static UiObject2 wait(UiDevice device, JSONObject params) throws JSONException {
|
||||||
return device.wait(Until.findObject(parseSelector(params)), parseTimeout(params));
|
UiObject2 result = device.wait(Until.findObject(parseSelector(params)), parseTimeout(params));
|
||||||
|
if (result == null)
|
||||||
|
throw new RuntimeException("Timed out waiting for selector");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fill(UiDevice device, JSONObject params) throws JSONException {
|
private static void fill(UiDevice device, JSONObject params) throws JSONException {
|
||||||
device.wait(Until.findObject(parseSelector(params)), parseTimeout(params)).setText(params.getString("text"));
|
wait(device, params).setText(params.getString("text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void click(UiDevice device, JSONObject params) throws JSONException {
|
private static void click(UiDevice device, JSONObject params) throws JSONException {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ mkdir ${SDKDIR}/cmdline-tools
|
||||||
|
|
||||||
echo Downloading Android SDK...
|
echo Downloading Android SDK...
|
||||||
cd ${SDKDIR}/cmdline-tools
|
cd ${SDKDIR}/cmdline-tools
|
||||||
curl https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -o commandlinetools-linux-6858069_latest.zip
|
curl https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip -o commandlinetools-mac-6858069_latest.zip
|
||||||
unzip commandlinetools-linux-6858069_latest.zip
|
unzip commandlinetools-mac-6858069_latest.zip
|
||||||
mv cmdline-tools latest
|
mv cmdline-tools latest
|
||||||
|
|
||||||
echo Installing emulator...
|
echo Installing emulator...
|
||||||
|
|
|
||||||
14
utils/build_android_driver.sh
Executable file
14
utils/build_android_driver.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
(cd src/server/android/driver ; ./gradlew assemble)
|
||||||
|
if [ "$?" -ne "0" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
(cd src/server/android/driver ; ./gradlew assembleAndroidTest)
|
||||||
|
if [ "$?" -ne "0" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp src/server/android/driver/app/build/outputs/apk/debug/app-debug.apk ./bin/android-driver-target.apk
|
||||||
|
cp src/server/android/driver/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk ./bin/android-driver.apk
|
||||||
Loading…
Reference in a new issue