1
- /**
1
+ /*
2
2
* Copyright (c) Microsoft Corporation.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
16
16
17
17
package com .microsoft .playwright .androiddriver ;
18
18
19
- import android .bluetooth .BluetoothClass ;
20
19
import android .graphics .Point ;
21
20
import android .graphics .Rect ;
22
21
import android .net .LocalServerSocket ;
23
22
import android .net .LocalSocket ;
24
- import android .os .Bundle ;
25
23
import android .view .accessibility .AccessibilityNodeInfo ;
26
24
27
25
import androidx .test .ext .junit .runners .AndroidJUnit4 ;
32
30
import androidx .test .uiautomator .Direction ;
33
31
import androidx .test .uiautomator .UiDevice ;
34
32
import androidx .test .uiautomator .UiObject2 ;
35
- import androidx .test .uiautomator .UiSelector ;
36
33
import androidx .test .uiautomator .Until ;
37
34
38
35
import org .json .JSONArray ;
48
45
import java .lang .reflect .InvocationTargetException ;
49
46
import java .lang .reflect .Method ;
50
47
import java .nio .charset .StandardCharsets ;
51
- import java .util .ArrayList ;
52
48
import java .util .regex .Pattern ;
53
49
54
50
/**
60
56
@ SdkSuppress (minSdkVersion = 21 )
61
57
public class InstrumentedTest {
62
58
59
+ @ SuppressWarnings ("ConstantConditions" )
63
60
private static BySelector parseSelector (JSONObject param ) throws JSONException {
64
61
JSONObject selector = param .getJSONObject ("selector" );
65
62
BySelector result = null ;
66
63
if (selector .has ("checkable" )) {
67
64
boolean value = selector .getBoolean ("checkable" );
68
- result = result != null ? result .checkable (value ) : By .checkable (value );
65
+ result = result != null ? result .checked (value ) : By .checkable (value );
69
66
}
70
67
if (selector .has ("checked" )) {
71
68
boolean value = selector .getBoolean ("checked" );
@@ -146,7 +143,7 @@ private static int parseTimeout(JSONObject params) throws JSONException {
146
143
147
144
private static Point parsePoint (JSONObject params , String propertyName ) throws JSONException {
148
145
JSONObject point = params .getJSONObject (propertyName );
149
- return new Point (params .getInt ("x" ), params .getInt ("y" ));
146
+ return new Point (point .getInt ("x" ), point .getInt ("y" ));
150
147
}
151
148
152
149
private static Direction parseDirection (JSONObject params ) throws JSONException {
@@ -313,6 +310,7 @@ private static AccessibilityNodeInfo getRootA11yNode(UiDevice device) {
313
310
getQueryController .setAccessible (true );
314
311
Object queryController = getQueryController .invoke (device );
315
312
313
+ assert queryController != null ;
316
314
Method getRootNode = queryController .getClass ().getDeclaredMethod ("getRootNode" );
317
315
getRootNode .setAccessible (true );
318
316
return (AccessibilityNodeInfo ) getRootNode .invoke (queryController );
@@ -343,6 +341,7 @@ public void main() {
343
341
DataInputStream dis = new DataInputStream (is );
344
342
DataOutputStream dos = new DataOutputStream (socket .getOutputStream ());
345
343
344
+ //noinspection InfiniteLoopStatement
346
345
while (true ) {
347
346
int id = 0 ;
348
347
String method = null ;
@@ -356,7 +355,7 @@ public void main() {
356
355
id = message .getInt ("id" );
357
356
method = message .getString ("method" );
358
357
params = message .getJSONObject ("params" );
359
- } catch (JSONException e ) {
358
+ } catch (JSONException ignored ) {
360
359
}
361
360
if (method == null )
362
361
continue ;
@@ -365,6 +364,7 @@ public void main() {
365
364
response .put ("id" , id );
366
365
response .put ("result" , params );
367
366
try {
367
+ assert params != null ;
368
368
switch (method ) {
369
369
case "wait" :
370
370
wait (device , params );
0 commit comments