blob: a7e9b3b8f11aeb15eb8f8f588d07a2f70323e63a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from head.js */
async function checkAdbNotRunning() {
info("Check if ADB is already running before the test starts");
const {
check,
} = require("devtools/client/shared/remote-debugging/adb/adb-running-checker");
const isAdbAlreadyRunning = await check();
if (isAdbAlreadyRunning) {
throw new Error(
"The ADB process is already running on this machine, it should be " +
"stopped before running this test"
);
}
}
/* exported checkAdbNotRunning */
// Returns a promise that resolves when the adb process exists and is running.
async function waitForAdbStart() {
info("Wait for ADB to start");
const {
adbProcess,
} = require("devtools/client/shared/remote-debugging/adb/adb-process");
const {
check,
} = require("devtools/client/shared/remote-debugging/adb/adb-running-checker");
return asyncWaitUntil(async () => {
const isProcessReady = adbProcess.ready;
const isRunning = await check();
return isProcessReady && isRunning;
});
}
/* exported waitForAdbStart */
// Attempt to stop ADB. Will only work if ADB was started by the current Firefox instance.
// Returns a promise that resolves when the adb process is no longer running.
async function stopAdbProcess() {
info("Attempt to stop ADB");
const {
adbProcess,
} = require("devtools/client/shared/remote-debugging/adb/adb-process");
await adbProcess.stop();
info("Wait for ADB to stop");
const {
check,
} = require("devtools/client/shared/remote-debugging/adb/adb-running-checker");
return asyncWaitUntil(async () => {
const isProcessReady = adbProcess.ready;
const isRunning = await check();
return !isProcessReady && !isRunning;
});
}
/* exported stopAdbProcess */
|