Skip to content

Commit d6cb21f

Browse files
brettchabotcopybara-androidxtest
authored andcommitted
Clean up or ignore various lint warnings.
PiperOrigin-RevId: 608987968
1 parent a1c4dbe commit d6cb21f

File tree

55 files changed

+272
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+272
-226
lines changed

build_extensions/jetify.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
1+
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
22

3-
def jetify_android_library(**kwargs):
3+
def jetify_android_library(jetify_sources = False, **kwargs):
44
# ignore, not supported in bazel
55
android_library(**kwargs)
6+
7+
def jetify_android_binary(jetify_sources = False, **kwargs):
8+
# ignore, not supported in bazel
9+
android_binary(**kwargs)

espresso/contrib/java/androidx/test/espresso/contrib/BUILD

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
1+
load("//build_extensions:api_checks.bzl", "api_checks")
2+
load("//build_extensions:dackka_test.bzl", "dackka_test")
23
load("//build_extensions/maven:axt_android_aar.bzl", "axt_android_aar")
34
load("//build_extensions/maven:maven_artifact.bzl", "maven_artifact")
4-
load("//build_extensions:dackka_test.bzl", "dackka_test")
5-
load("//build_extensions:api_checks.bzl", "api_checks")
5+
load("//build_extensions:jetify.bzl", "jetify_android_library")
6+
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
67

78
# Description:
89
# Contributed / non-core functionality of Espresso. Tools which add on to
@@ -66,14 +67,16 @@ COMMON_JAVACOPTS = [
6667
"-Xep:ObjectToString:OFF", # See http://go/objecttostring-lsc
6768
]
6869

69-
android_library(
70+
jetify_android_library(
7071
name = "recycler_view",
7172
srcs = ["RecyclerViewActions.java"],
7273
javacopts = COMMON_JAVACOPTS,
74+
jetify_sources = True,
7375
visibility = ["//visibility:public"],
7476
deps = [
7577
"//espresso/core/java/androidx/test/espresso",
7678
"//espresso/core/java/androidx/test/espresso/matcher",
79+
"//opensource/androidx:annotation",
7780
"//runner/monitor",
7881
"@maven//:androidx_recyclerview_recyclerview",
7982
"@maven//:org_hamcrest_hamcrest_core",

espresso/contrib/java/androidx/test/espresso/contrib/RecyclerViewActions.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@
2222
import static androidx.test.internal.util.Checks.checkNotNull;
2323
import static org.hamcrest.Matchers.allOf;
2424

25-
import androidx.recyclerview.widget.RecyclerView;
26-
import androidx.recyclerview.widget.RecyclerView.Adapter;
27-
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
2825
import android.util.SparseArray;
2926
import android.view.View;
3027
import android.widget.AdapterView;
3128
import androidx.annotation.NonNull;
29+
import androidx.recyclerview.widget.RecyclerView;
30+
import androidx.recyclerview.widget.RecyclerView.Adapter;
31+
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
3232
import androidx.test.espresso.Espresso;
3333
import androidx.test.espresso.PerformException;
3434
import androidx.test.espresso.UiController;
3535
import androidx.test.espresso.ViewAction;
3636
import androidx.test.espresso.util.HumanReadables;
3737
import java.util.ArrayList;
3838
import java.util.List;
39+
import java.util.Locale;
3940
import org.hamcrest.Description;
4041
import org.hamcrest.Matcher;
4142
import org.hamcrest.TypeSafeMatcher;
@@ -211,13 +212,18 @@ public PositionableRecyclerViewAction atPosition(int position) {
211212
public String getDescription() {
212213
if (atPosition == NO_POSITION) {
213214
return String.format(
215+
Locale.ROOT,
214216
"performing ViewAction: %s on item matching: %s",
215-
viewAction.getDescription(), viewHolderMatcher);
217+
viewAction.getDescription(),
218+
viewHolderMatcher);
216219

217220
} else {
218221
return String.format(
222+
Locale.ROOT,
219223
"performing ViewAction: %s on %d-th item matching: %s",
220-
viewAction.getDescription(), atPosition, viewHolderMatcher);
224+
viewAction.getDescription(),
225+
atPosition,
226+
viewHolderMatcher);
221227
}
222228
}
223229

@@ -350,7 +356,10 @@ public String getDescription() {
350356
return "scroll RecyclerView to: " + viewHolderMatcher;
351357
} else {
352358
return String.format(
353-
"scroll RecyclerView to the: %dth matching %s.", atPosition, viewHolderMatcher);
359+
Locale.ROOT,
360+
"scroll RecyclerView to the: %dth matching %s.",
361+
atPosition,
362+
viewHolderMatcher);
354363
}
355364
}
356365

espresso/contrib/java/androidx/test/espresso/contrib/api/3.5.0_public.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ package androidx.test.espresso.contrib {
3939
}
4040

4141
public final class RecyclerViewActions {
42-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! actionOnHolderItem(org.hamcrest.Matcher<VH!>!, androidx.test.espresso.ViewAction!);
43-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! actionOnItem(org.hamcrest.Matcher<android.view.View!>!, androidx.test.espresso.ViewAction!);
44-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction! actionOnItemAtPosition(int, androidx.test.espresso.ViewAction!);
45-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! scrollTo(org.hamcrest.Matcher<android.view.View!>!);
46-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! scrollToHolder(org.hamcrest.Matcher<VH!>!);
47-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction scrollToLastPosition();
48-
method public static <VH extends android.support.v7.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction! scrollToPosition(int);
42+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! actionOnHolderItem(org.hamcrest.Matcher<VH!>!, androidx.test.espresso.ViewAction!);
43+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! actionOnItem(org.hamcrest.Matcher<android.view.View!>!, androidx.test.espresso.ViewAction!);
44+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction! actionOnItemAtPosition(int, androidx.test.espresso.ViewAction!);
45+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! scrollTo(org.hamcrest.Matcher<android.view.View!>!);
46+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction! scrollToHolder(org.hamcrest.Matcher<VH!>!);
47+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction scrollToLastPosition();
48+
method public static <VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> androidx.test.espresso.ViewAction! scrollToPosition(int);
4949
}
5050

5151
public static interface RecyclerViewActions.PositionableRecyclerViewAction extends androidx.test.espresso.ViewAction {

espresso/contrib/javatests/androidx/test/espresso/contrib/BUILD

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ licenses(["notice"])
1313
## Android tests
1414

1515
jetify_android_library(
16-
name = "recycler_view_test_baseclass",
16+
name = "recycler_view_tests",
1717
testonly = 1,
18-
srcs = ["RecyclerViewIntegrationTest.java"],
18+
srcs = [
19+
"RecyclerViewGridLayoutManagerTest.java",
20+
"RecyclerViewIntegrationTest.java",
21+
"RecyclerViewLinearLayoutManagerTest.java",
22+
"RecyclerViewStaggeredGridLayoutManagerTest.java",
23+
],
24+
jetify_sources = True,
1925
deps = [
2026
"//core",
2127
"//espresso/contrib/java/androidx/test/espresso/contrib:recycler_view",
@@ -24,10 +30,12 @@ jetify_android_library(
2430
"//espresso/core/java/androidx/test/espresso/action",
2531
"//espresso/core/java/androidx/test/espresso/assertion",
2632
"//espresso/core/java/androidx/test/espresso/matcher",
33+
"//ext/junit",
2734
"//runner/android_junit_runner",
2835
"//testapps/ui_testapp/java/androidx/test/ui/app:lib",
2936
"//testapps/ui_testapp/javatests/androidx/test/ui/app:test_resources",
3037
"@maven//:androidx_recyclerview_recyclerview",
38+
"@maven//:com_google_truth_truth",
3139
"@maven//:junit_junit",
3240
"@maven//:org_hamcrest_hamcrest_core",
3341
"@maven//:org_hamcrest_hamcrest_library",
@@ -104,10 +112,8 @@ axt_android_library_test(
104112

105113
axt_android_library_test(
106114
name = "RecyclerViewGridLayoutManagerTest",
107-
srcs =
108-
["RecyclerViewGridLayoutManagerTest.java"],
109115
deps = [
110-
":recycler_view_test_baseclass",
116+
":recycler_view_tests",
111117
"//espresso/contrib/java/androidx/test/espresso/contrib:recycler_view",
112118
"//espresso/core/java/androidx/test/espresso",
113119
"//ext/junit",
@@ -119,10 +125,8 @@ axt_android_library_test(
119125

120126
axt_android_library_test(
121127
name = "RecyclerViewLinearLayoutManagerTest",
122-
srcs =
123-
["RecyclerViewLinearLayoutManagerTest.java"],
124128
deps = [
125-
":recycler_view_test_baseclass",
129+
":recycler_view_tests",
126130
"//espresso/contrib/java/androidx/test/espresso/contrib:recycler_view",
127131
"//espresso/core/java/androidx/test/espresso",
128132
"//ext/junit",
@@ -136,10 +140,8 @@ axt_android_library_test(
136140

137141
axt_android_library_test(
138142
name = "RecyclerViewStaggeredGridLayoutManagerTest",
139-
srcs =
140-
["RecyclerViewStaggeredGridLayoutManagerTest.java"],
141143
deps = [
142-
":recycler_view_test_baseclass",
144+
":recycler_view_tests",
143145
"//espresso/contrib/java/androidx/test/espresso/contrib:recycler_view",
144146
"//espresso/core/java/androidx/test/espresso",
145147
"//ext/junit",

espresso/contrib/javatests/androidx/test/espresso/contrib/RecyclerViewIntegrationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
import static org.hamcrest.Matchers.startsWith;
3838
import static org.junit.Assert.fail;
3939

40-
import androidx.recyclerview.widget.RecyclerView;
4140
import android.text.TextUtils;
4241
import android.view.View;
42+
import androidx.recyclerview.widget.RecyclerView;
4343
import androidx.test.core.app.ActivityScenario;
4444
import androidx.test.core.app.ActivityScenario.ActivityAction;
4545
import androidx.test.espresso.PerformException;
@@ -362,7 +362,9 @@ public void testActionsOnItem_clickMultipleItems() throws InterruptedException {
362362
onView(withId(selectedItemId)).check(matches(withText(expectedItem0Text)));
363363
}
364364

365-
/** @return the layout id of the {@link androidx.recyclerview.widget.RecyclerView} used. */
365+
/**
366+
* @return the layout id of the {@link androidx.recyclerview.widget.RecyclerView} used.
367+
*/
366368
protected abstract int getRVLayoutId();
367369

368370
/** @return the view id of the selected item {@link android.widget.TextView} */

espresso/contrib/javatests/androidx/test/espresso/contrib/RecyclerViewLinearLayoutManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import org.junit.runner.RunWith;
3434

3535
/**
36-
* {@link RecyclerViewIntegrationTest}s for {@link androidx.recyclerview.widget.RecyclerView} using a
37-
* {@link androidx.recyclerview.widget.LinearLayoutManager}
36+
* {@link RecyclerViewIntegrationTest}s for {@link androidx.recyclerview.widget.RecyclerView} using
37+
* a {@link androidx.recyclerview.widget.LinearLayoutManager}
3838
*/
3939
@RunWith(AndroidJUnit4.class)
4040
@LargeTest

espresso/contrib/javatests/androidx/test/espresso/contrib/RecyclerViewStaggeredGridLayoutManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.junit.runner.RunWith;
3131

3232
/**
33-
* {@link RecyclerViewIntegrationTest}s for {@link androidx.recyclerview.widget.RecyclerView} using a
34-
* {@link androidx.recyclerview.widget.StaggeredGridLayoutManager}
33+
* {@link RecyclerViewIntegrationTest}s for {@link androidx.recyclerview.widget.RecyclerView} using
34+
* a {@link androidx.recyclerview.widget.StaggeredGridLayoutManager}
3535
*/
3636
@RunWith(AndroidJUnit4.class)
3737
@LargeTest

espresso/core/java/androidx/test/espresso/action/ScrollToAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Matcher<View> getConstraints() {
6262
isAssignableFrom(HorizontalScrollView.class),
6363
isAssignableFrom(ListView.class),
6464
isAssignableFromClassName("androidx.core.widget.NestedScrollView"),
65-
isAssignableFromClassName("androidx.recyclerview.widget.RecyclerView"),
65+
isAssignableFromClassName("android.support.v7.widget.RecyclerView"),
6666
isAssignableFromClassName("androidx.recyclerview.widget.RecyclerView"))));
6767
}
6868

runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private static Class<?> getMultiDexClass() throws ClassNotFoundException {
231231
return Class.forName("androidx.multidex.MultiDex");
232232
} catch (ClassNotFoundException e) {
233233
// check for support multidex
234-
return Class.forName("androidx.multidex.MultiDex");
234+
return Class.forName("android.support.multidex.MultiDex");
235235
}
236236
}
237237

0 commit comments

Comments
 (0)