@@ -17,6 +17,13 @@ const TESTS = {
17
17
renderdeep : / R e n d e r D e e p R e s u l t : ( \d + ) /
18
18
} ;
19
19
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
+
20
27
run ( ) ;
21
28
22
29
function run ( ) {
@@ -97,18 +104,33 @@ function killProfiler() {
97
104
98
105
function clickOnJsTest ( ) {
99
106
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 } ` ) ;
101
110
waitForLogcatMsg ( `${ LOGCAT_TAG } :JSProfile:Done` ) ;
102
111
}
103
112
104
113
function clickOnFlatRenderTest ( ) {
105
114
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 } ` ) ;
107
118
waitForLogcatMsg ( `${ LOGCAT_TAG } :RenderFlatResult:` ) ;
108
119
}
109
120
110
121
function clickOnDeepRenderTest ( ) {
111
122
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 } ` ) ;
113
126
waitForLogcatMsg ( `${ LOGCAT_TAG } :RenderDeepResult:` ) ;
114
127
}
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