Skip to content

Commit

Permalink
Merge branches 'issues/1430' and 'master' of github.com:ooni/probe-an…
Browse files Browse the repository at this point in the history
…droid into issues/1430
  • Loading branch information
aanorbel committed Feb 9, 2024
2 parents 30b50e1 + 6af25fd commit c335a1e
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 124 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/firebase-app-distribution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build & upload to Firebase App Distribution

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: build release
run: ./gradlew clean assembleDevFullDebug
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1.7.0
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: app/build/outputs/apk/devFull/debug/app-dev-full-debug.apk
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'
versionCode 107
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ public void onReceive(Context context, Intent intent) {
) {
return;
}
// If key is null, do nothing
if (key == null) {
return;
}
switch (key) {
case TestAsyncTask.RUN:
Log.d(TAG, "TestAsyncTask.RUN");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public TestRunBroadRequestReceiver(PreferenceManager preferenceManager, EventLis
public void onReceive(Context context, Intent intent) {
String key = intent.getStringExtra("key");
String value = intent.getStringExtra("value");
// If key is null, do nothing
if (key == null) {
return;
}
switch (key) {
case TestAsyncTask.START:
listener.onStart(service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,18 @@ private void downloadURLs() {

currentTest.setInputs(inputs);

if (currentTest.getMax_runtime() == null)
/*
* Set the maximum runtime if the test doesn't yet have it. This is only done if the test is not unattended.
* Previously, this was not required, because the code path for unattended tests
* did not call this method. However, now that we are using the same code path as of https://github.com/ooni/probe-android/pull/572,
* This is now required to ensure the manual tests follow the preference set by the user,
* while the unattended tests doesn't.
*
* See https://github.com/ooni/probe/issues/2644.
*/
if (currentTest.getMax_runtime() == null && !unattended) {
currentTest.setMax_runtime(app.getPreferenceManager().getMaxRuntime());
}
publishProgress(URL);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit c335a1e

Please sign in to comment.