1515
1616import java .util .List ;
1717
18+ import androidx .annotation .NonNull ;
1819import androidx .test .platform .app .InstrumentationRegistry ;
1920import androidx .test .uiautomator .By ;
2021import androidx .test .uiautomator .Direction ;
2930import static org .hamcrest .CoreMatchers .equalTo ;
3031import static org .hamcrest .CoreMatchers .is ;
3132import static org .hamcrest .CoreMatchers .not ;
33+ import static org .hamcrest .MatcherAssert .assertThat ;
3234import static org .hamcrest .core .IsNull .notNullValue ;
3335
3436/**
3941@ RunWith (org .junit .runners .Suite .class )
4042@ SuiteClasses ({
4143 TestRepositories .class ,
42- TestRepository .class ,
4344 TestProfile .class
4445})
4546public class TestSuite {
@@ -74,18 +75,18 @@ private String getLauncherPackageName() {
7475 }
7576
7677 /** launches the blueprint application */
77- void startTestActivity (Context context , String className ){
78+ void startTestActivity (@ NonNull Context context , @ NonNull String className ){
7879
7980 /* initialize UiDevice */
8081 this .mDevice = UiDevice .getInstance (InstrumentationRegistry .getInstrumentation ());
81- Assert . assertThat (this .mDevice , notNullValue ());
82+ assertThat (this .mDevice , notNullValue ());
8283
8384 /* start from the home screen */
8485 this .mDevice .pressHome ();
8586
8687 /* obtain the launcher package */
8788 String launcherPackage = getLauncherPackageName ();
88- Assert . assertThat (launcherPackage , notNullValue ());
89+ assertThat (launcherPackage , notNullValue ());
8990
9091 /* wait for launcher */
9192 this .mDevice .wait (Until .hasObject (By .pkg (launcherPackage ).depth (0 )), LAUNCH_TIMEOUT );
@@ -94,7 +95,7 @@ void startTestActivity(Context context, String className){
9495 this .packageName = context .getPackageName ().replace (".test" , "" );
9596 Intent intent = context .getPackageManager ().getLaunchIntentForPackage (this .packageName );
9697
97- if (intent != null ) {
98+ if (intent != null ) {
9899
99100 intent .setComponent (new ComponentName (this .packageName , this .packageName .replace ("debug" , "activity." + className )));
100101 intent .addFlags (Intent .FLAG_ACTIVITY_CLEAR_TASK | Intent .FLAG_ACTIVITY_NEW_TASK );
@@ -115,24 +116,24 @@ protected UiObject2 getItemById(String resourceId) {
115116 return this .mDevice .findObject (By .res (this .packageName , resourceId ));
116117 }
117118
118- /** it clicks spinner items by index */
119+ /** It clicks spinner items by index */
119120 public void clickSpinnerItem (String spinnerName , int itemIndex ) {
120121
121122 UiObject2 spinner = this .mDevice .findObject (By .res (this .packageName , spinnerName ));
122- Assert . assertThat (spinner .isClickable (), is (equalTo (true )));
123+ assertThat (spinner .isClickable (), is (equalTo (true )));
123124 spinner .click ();
124125 sleep (2000 );
125126
126127 List <UiObject2 > items = this .mDevice .findObjects (By .res ("android:id/text1" ));
127- Assert . assertThat (items .size () > itemIndex , is (equalTo (true )));
128+ assertThat (items .size () > itemIndex , is (equalTo (true )));
128129
129130 UiObject2 item = items .get (itemIndex );
130- Assert . assertThat (item .isClickable (), is (equalTo (true )));
131+ assertThat (item .isClickable (), is (equalTo (true )));
131132 item .click (500 );
132133 sleep (2000 );
133134 }
134135
135- /** it clicks the "Allow" button on a permission request dialog */
136+ /** It clicks the "Allow" button on a permission request dialog */
136137 void grantPermission () {
137138 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
138139 UiObject textAllow = this .mDevice .findObject (new UiSelector ().text ("Allow" ));
@@ -147,7 +148,7 @@ void grantPermission() {
147148 }
148149
149150 void flingUp (UiObject2 view , int speed , int pause ) {
150- Assert . assertThat (view , not (equalTo (null )));
151+ assertThat (view , not (equalTo (null )));
151152 try {
152153 view .fling (Direction .DOWN , speed );
153154 } catch (StaleObjectException e ) {
0 commit comments