Skip to content

Commit 5366132

Browse files
committed
tests updated.
1 parent c7c82fc commit 5366132

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

mobile/src/androidTest/java/io/syslogic/github/TestProfile.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.syslogic.github;
22

3-
import org.junit.Assert;
43
import org.junit.Before;
54
import org.junit.Test;
65
import org.junit.runner.RunWith;
@@ -12,6 +11,7 @@
1211

1312
import static org.hamcrest.CoreMatchers.equalTo;
1413
import static org.hamcrest.CoreMatchers.is;
14+
import static org.hamcrest.MatcherAssert.assertThat;
1515

1616
/**
1717
* Profile Test Case
@@ -32,6 +32,6 @@ public void startActivityFromHomeScreen() {
3232
@Test
3333
public void WebView() {
3434
UiObject2 layout = this.mDevice.findObject(By.res(this.packageName, "webview"));
35-
Assert.assertThat(true, is(equalTo(true)));
35+
assertThat(true, is(equalTo(true)));
3636
}
3737
}

mobile/src/androidTest/java/io/syslogic/github/TestRepositories.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.syslogic.github;
22

3-
import org.junit.Assert;
43
import org.junit.Before;
54
import org.junit.Test;
65
import org.junit.runner.RunWith;
@@ -12,6 +11,7 @@
1211

1312
import static org.hamcrest.CoreMatchers.equalTo;
1413
import static org.hamcrest.CoreMatchers.is;
14+
import static org.hamcrest.MatcherAssert.assertThat;
1515

1616
/**
1717
* Repositories Test Case
@@ -36,7 +36,7 @@ public void RecyclerView() {
3636
for(int page = 0; page < pages; page++) {
3737
flingUp(recyclerview, 4000, 200);
3838
}
39-
Assert.assertThat(recyclerview.getChildCount() > 0, is(equalTo(true)));
39+
assertThat(recyclerview.getChildCount() > 0, is(equalTo(true)));
4040
}
4141

4242
@Test

mobile/src/androidTest/java/io/syslogic/github/TestRepository.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.syslogic.github;
22

3-
import org.junit.Assert;
43
import org.junit.Before;
54
import org.junit.Test;
65
import org.junit.runner.RunWith;
@@ -12,6 +11,7 @@
1211

1312
import static org.hamcrest.CoreMatchers.equalTo;
1413
import static org.hamcrest.CoreMatchers.is;
14+
import static org.hamcrest.MatcherAssert.assertThat;
1515

1616
/**
1717
* Repository Test Case
@@ -34,7 +34,7 @@ public void startActivityFromHomeScreen() {
3434
public void ButtonDownload() {
3535

3636
UiObject2 view = this.mDevice.findObject(By.res(this.packageName, "button_download"));
37-
Assert.assertThat(view.isClickable(), is(equalTo(true)));
37+
assertThat(view.isClickable(), is(equalTo(true)));
3838
view.click();
3939

4040
sleep(1000);

mobile/src/androidTest/java/io/syslogic/github/TestSuite.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.List;
1717

18+
import androidx.annotation.NonNull;
1819
import androidx.test.platform.app.InstrumentationRegistry;
1920
import androidx.test.uiautomator.By;
2021
import androidx.test.uiautomator.Direction;
@@ -29,6 +30,7 @@
2930
import static org.hamcrest.CoreMatchers.equalTo;
3031
import static org.hamcrest.CoreMatchers.is;
3132
import static org.hamcrest.CoreMatchers.not;
33+
import static org.hamcrest.MatcherAssert.assertThat;
3234
import static org.hamcrest.core.IsNull.notNullValue;
3335

3436
/**
@@ -39,7 +41,6 @@
3941
@RunWith(org.junit.runners.Suite.class)
4042
@SuiteClasses({
4143
TestRepositories.class,
42-
TestRepository.class,
4344
TestProfile.class
4445
})
4546
public 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

Comments
 (0)