Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ooni/probe-android into feat/pr-n…
Browse files Browse the repository at this point in the history
…umber-version-codes
  • Loading branch information
aanorbel committed Jan 25, 2024
2 parents de08458 + 6af25fd commit de8c9b8
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 122 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId 'org.openobservatory.ooniprobe'
minSdk libs.versions.minSdk.get().toInteger()
targetSdk libs.versions.targetSdk.get().toInteger()
versionName '3.8.5.1'
versionCode 108
versionName '3.8.6'
versionCode 110
testInstrumentationRunner "org.openobservatory.ooniprobe.TestAndroidJUnitRunner"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.ooni.io/"'
buildConfigField 'String', 'NOTIFICATION_SERVER', '"https://countly.ooni.io"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,41 +113,4 @@ public void testBlockedTor() {
onView(withId(R.id.authorities)).check(matches(withText(formattedAuthorities)));
assertMeasurementRuntimeAndNetwork(measurement, testResult.network);
}

@Test
public void testSuccessfulRiseUpVPN() {
// Arrange
Result testResult = ResultFactory.createAndSave(new CircumventionSuite(), 3, 0);
Measurement measurement = testResult.getMeasurement("riseupvpn");

// Act
launchDetails(testResult.id);
onView(withText("RiseupVPN Test")).check(matches(isDisplayed())).perform(click());

// Assert
assertMeasurementOutcome(true);
onView(withId(R.id.bootstrap_value)).check(matches(withText(TEST_RESULTS_AVAILABLE)));
onView(withId(R.id.openvpn_value)).check(matches(withText(TEST_RESULTS_AVAILABLE)));
onView(withId(R.id.bridges_value)).check(matches(withText(TEST_RESULTS_AVAILABLE)));
assertMeasurementRuntimeAndNetwork(measurement, testResult.network);
}

@Test
public void testBlockedRiseUpVPN() {
// Arrange
Result testResult = ResultFactory.createAndSave(new CircumventionSuite(), 0, 3);
Measurement measurement = testResult.getMeasurement("riseupvpn");

// Act
launchDetails(testResult.id);
onView(withText("RiseupVPN Test")).check(matches(isDisplayed())).perform(click());

// Assert
assertMeasurementOutcome(false);
onView(withId(R.id.bootstrap_value)).check(matches(withText("Blocked")));
onView(withId(R.id.openvpn_value)).check(matches(withText("1 blocked")));
onView(withId(R.id.bridges_value)).check(matches(withText("1 blocked")));
assertMeasurementRuntimeAndNetwork(measurement, testResult.network);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package org.openobservatory.ooniprobe.ui.resultdetails;

import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.swipeLeft;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.containsString;

import androidx.test.espresso.assertion.ViewAssertions;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.schibsted.spain.barista.rule.flaky.AllowFlaky;
Expand All @@ -20,19 +33,6 @@
import org.openobservatory.ooniprobe.test.test.Ndt;
import org.openobservatory.ooniprobe.utils.FormattingUtils;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.swipeLeft;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.openobservatory.ooniprobe.ui.utils.RecyclerViewMatcher.withRecyclerView;

@RunWith(AndroidJUnit4.class)
public class PerformanceTest extends MeasurementAbstractTest {

Expand Down Expand Up @@ -112,35 +112,34 @@ public void testListOfMeasurements() {
launchDetails(testResult.id);

// Assert
onView(withId(R.id.recyclerView))
.perform(scrollToPosition(0));

onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(0, R.id.data1))
.check(matches(withText(download + " " + downloadUnity)));
onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(0, R.id.data2))
.check(matches(withText(upload + " " + uploadUnity)));

onView(withId(R.id.recyclerView))
.perform(scrollToPosition(1));

onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(1, R.id.data1))
onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(0)
.onChildView(withId(R.id.data1))
.check(ViewAssertions.matches(withText(download + " " + downloadUnity)));

onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(0)
.onChildView(withId(R.id.data2))
.check(matches(withText(upload + " " + uploadUnity)));

onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(1)
.onChildView(withId(R.id.data1))
.check(matches(withText(videoQuality)));

onView(withId(R.id.recyclerView))
.perform(scrollToPosition(2));

onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(2, R.id.data1))
onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(2)
.onChildView(withId(R.id.data1))
.check(matches(withText(notDetected)));

onView(withId(R.id.recyclerView))
.perform(scrollToPosition(3));

onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(3, R.id.data1))
onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(3)
.onChildView(withId(R.id.data1))
.check(matches(withText(notDetected)));
}

Expand Down Expand Up @@ -174,7 +173,7 @@ public void testNDT() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(0, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(0).perform(click());

// Assert
onView(withText(download + downloadUnity)).check(matches(isDisplayed()));
Expand Down Expand Up @@ -202,7 +201,7 @@ public void testStreaming() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(1, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(1).perform(click());

// Assert
onView(withText(containsString(videoQuality))).check(matches(isDisplayed()));
Expand All @@ -219,7 +218,7 @@ public void testRequestLine() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(2, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(2).perform(click());

// Assert
onView(withText(getResourceString(R.string.TestResults_Details_Middleboxes_HTTPInvalidRequestLine_NotFound_Hero_Title))).check(matches(isDisplayed()));
Expand All @@ -234,7 +233,7 @@ public void testRequestLineDetection() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(2, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(2).perform(click());

// Assert
onView(withText(getResourceString(R.string.TestResults_Details_Middleboxes_HTTPInvalidRequestLine_Found_Hero_Title))).check(matches(isDisplayed()));
Expand All @@ -249,7 +248,7 @@ public void testFieldManipulation() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(3, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(3).perform(click());

// Assert
onView(withText(getResourceString(R.string.TestResults_Details_Middleboxes_HTTPHeaderFieldManipulation_NotFound_Hero_Title))).check(matches(isDisplayed()));
Expand All @@ -264,7 +263,7 @@ public void testFieldManipulationDetection() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(3, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(3).perform(click());

// Assert
onView(withText(getResourceString(R.string.TestResults_Details_Middleboxes_HTTPHeaderFieldManipulation_Found_Hero_Title))).check(matches(isDisplayed()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
Expand All @@ -27,6 +28,7 @@
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.containsString;
import static org.openobservatory.ooniprobe.ui.utils.RecyclerViewMatcher.withRecyclerView;
import static org.openobservatory.ooniprobe.ui.utils.ViewMatchers.waitPartialText;
Expand Down Expand Up @@ -64,12 +66,11 @@ public void checkListOfMeasurementsTest() {

// Assert
for (int i = 0; i < measurements.size(); i++) {
onView(withId(R.id.recyclerView))
.perform(scrollToPosition(i));

onView(withRecyclerView(R.id.recyclerView)
.atPositionOnView(i, R.id.text))
.check(matches(withText(containsString(measurements.get(i).getUrlString()))));
onData(anything())
.inAdapterView(withId(R.id.recyclerView))
.atPosition(i)
.onChildView(withId(R.id.text))
.check(matches(withText(containsString(measurements.get(i).getUrlString()))));
}

}
Expand All @@ -83,7 +84,7 @@ public void testSucceed() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(0, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(0).perform(click());

// Assert
onView(withText(headerOutcome)).check(matches(isDisplayed()));
Expand All @@ -99,7 +100,7 @@ public void testBlocked() {

// Act
launchDetails(testResult.id);
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(0, click()));
onData(anything()).inAdapterView(withId(R.id.recyclerView)).atPosition(0).perform(click());

// Assert
onView(withText(headerOutcome)).check(matches(isDisplayed()));
Expand Down
Loading

0 comments on commit de8c9b8

Please sign in to comment.