Skip to content

Commit a5e3b35

Browse files
committed
fixes #31
1 parent e9c79da commit a5e3b35

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

measure/scripts/measure.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ const TESTS = {
1717
renderdeep: /RenderDeepResult:(\d+)/
1818
};
1919

20+
const density = getDensity();
21+
console.log(`Device density: ${density}`);
22+
const scale = density / 120;
23+
const [width, height] = getScreenSize();
24+
console.log(`Device width: ${width}`);
25+
console.log(`Device height: ${height}`);
26+
2027
run();
2128

2229
function run() {
@@ -97,18 +104,33 @@ function killProfiler() {
97104

98105
function clickOnJsTest() {
99106
console.log(`js test`);
100-
exec.execSyncSilent(`adb shell input tap 720 1008`); // TODO replace with non-magical values
107+
const x = width / 2;
108+
const y = height / 2 - (60 * scale)
109+
exec.execSyncSilent(`adb shell input tap ${x} ${y}`);
101110
waitForLogcatMsg(`${LOGCAT_TAG}:JSProfile:Done`);
102111
}
103112

104113
function clickOnFlatRenderTest() {
105114
console.log(`flat render test`);
106-
exec.execSyncSilent(`adb shell input tap 720 1240`); // TODO replace with non-magical values
115+
const x = width / 2;
116+
const y = height / 2;
117+
exec.execSyncSilent(`adb shell input tap ${x} ${y}`);
107118
waitForLogcatMsg(`${LOGCAT_TAG}:RenderFlatResult:`);
108119
}
109120

110121
function clickOnDeepRenderTest() {
111122
console.log(`deep render test`);
112-
exec.execSyncSilent(`adb shell input tap 720 1470`);// TODO replace with non-magical values
123+
const x = width / 2;
124+
const y = height / 2 + (40 * scale);
125+
exec.execSyncSilent(`adb shell input tap ${x} ${y}`);
113126
waitForLogcatMsg(`${LOGCAT_TAG}:RenderDeepResult:`);
114127
}
128+
129+
function getDensity() {
130+
return exec.execSyncRead(`adb shell wm density | grep -Eo "[0-9]+"`, true)
131+
}
132+
133+
function getScreenSize() {
134+
const size = exec.execSyncRead(`adb shell wm size | grep -Eo "\\d+x\\d+"`, true);
135+
return size.split('x');
136+
}

0 commit comments

Comments
 (0)