Skip to content

Commit 844b2c8

Browse files
authored
chore(adb): lint the driver (#4696)
1 parent ad5309c commit 844b2c8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bin/android-driver.apk

-3.65 KB
Binary file not shown.

src/server/android/driver/app/src/androidTest/java/com/microsoft/playwright/androiddriver/InstrumentedTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) Microsoft Corporation.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,12 +16,10 @@
1616

1717
package com.microsoft.playwright.androiddriver;
1818

19-
import android.bluetooth.BluetoothClass;
2019
import android.graphics.Point;
2120
import android.graphics.Rect;
2221
import android.net.LocalServerSocket;
2322
import android.net.LocalSocket;
24-
import android.os.Bundle;
2523
import android.view.accessibility.AccessibilityNodeInfo;
2624

2725
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -32,7 +30,6 @@
3230
import androidx.test.uiautomator.Direction;
3331
import androidx.test.uiautomator.UiDevice;
3432
import androidx.test.uiautomator.UiObject2;
35-
import androidx.test.uiautomator.UiSelector;
3633
import androidx.test.uiautomator.Until;
3734

3835
import org.json.JSONArray;
@@ -48,7 +45,6 @@
4845
import java.lang.reflect.InvocationTargetException;
4946
import java.lang.reflect.Method;
5047
import java.nio.charset.StandardCharsets;
51-
import java.util.ArrayList;
5248
import java.util.regex.Pattern;
5349

5450
/**
@@ -60,12 +56,13 @@
6056
@SdkSuppress(minSdkVersion = 21)
6157
public class InstrumentedTest {
6258

59+
@SuppressWarnings("ConstantConditions")
6360
private static BySelector parseSelector(JSONObject param) throws JSONException{
6461
JSONObject selector = param.getJSONObject("selector");
6562
BySelector result = null;
6663
if (selector.has("checkable")) {
6764
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);
6966
}
7067
if (selector.has("checked")) {
7168
boolean value = selector.getBoolean("checked");
@@ -146,7 +143,7 @@ private static int parseTimeout(JSONObject params) throws JSONException {
146143

147144
private static Point parsePoint(JSONObject params, String propertyName) throws JSONException {
148145
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"));
150147
}
151148

152149
private static Direction parseDirection(JSONObject params) throws JSONException {
@@ -313,6 +310,7 @@ private static AccessibilityNodeInfo getRootA11yNode(UiDevice device) {
313310
getQueryController.setAccessible(true);
314311
Object queryController = getQueryController.invoke(device);
315312

313+
assert queryController != null;
316314
Method getRootNode = queryController.getClass().getDeclaredMethod("getRootNode");
317315
getRootNode.setAccessible(true);
318316
return (AccessibilityNodeInfo) getRootNode.invoke(queryController);
@@ -343,6 +341,7 @@ public void main() {
343341
DataInputStream dis = new DataInputStream(is);
344342
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
345343

344+
//noinspection InfiniteLoopStatement
346345
while (true) {
347346
int id = 0;
348347
String method = null;
@@ -356,7 +355,7 @@ public void main() {
356355
id = message.getInt("id");
357356
method = message.getString("method");
358357
params = message.getJSONObject("params");
359-
} catch (JSONException e) {
358+
} catch (JSONException ignored) {
360359
}
361360
if (method == null)
362361
continue;
@@ -365,6 +364,7 @@ public void main() {
365364
response.put("id", id);
366365
response.put("result", params);
367366
try {
367+
assert params != null;
368368
switch (method) {
369369
case "wait":
370370
wait(device, params);

0 commit comments

Comments
 (0)