Skip to content

Commit

Permalink
Merge branch 'dev/design-update' of github.com:ooni/probe-android int…
Browse files Browse the repository at this point in the history
…o issues/2594
  • Loading branch information
aanorbel committed Feb 14, 2024
2 parents 7a2f1d8 + 0060c85 commit b78e42f
Show file tree
Hide file tree
Showing 22 changed files with 376 additions and 249 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/firebase-app-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,30 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
- name: Resolve PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
# Can be "open", "closed", or "all". Defaults to "open".
state: open
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: build release
- name: Build `DevFullDebug` variant
if: success() && steps.findPr.outputs.number
run: ./gradlew clean assembleDevFullDebug
- name: upload artifact to Firebase App Distribution
env:
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- name: Upload artifact to Firebase App Distribution
uses: wzieba/[email protected]
id: uploadArtifact
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
file: app/build/outputs/apk/devFull/debug/app-dev-full-debug.apk
- name: Write Summary
run: |
echo "View this release in the Firebase console: ${{ steps.uploadArtifact.outputs.FIREBASE_CONSOLE_URI }}" >> $GITHUB_STEP_SUMMARY
26 changes: 18 additions & 8 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 Expand Up @@ -55,8 +55,8 @@ android {
dev {
dimension 'testing'
applicationIdSuffix '.dev'
versionNameSuffix "-beta.1"
versionCode versionCodeDate()
versionNameSuffix resolveVersionSuffix('beta')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-dev"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.dev'
resValue "string", "APP_NAME", "OONI Dev"
Expand All @@ -65,8 +65,8 @@ android {
experimental {
dimension 'testing'
applicationIdSuffix '.experimental'
versionNameSuffix "-experimental.1"
versionCode versionCodeDate()
versionNameSuffix resolveVersionSuffix('experimental')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-experimental"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.experimental'
resValue "string", "APP_NAME", "OONI Exp"
Expand Down Expand Up @@ -144,7 +144,7 @@ dependencies {
fullImplementation libs.google.play.core

// Dependency Injection
implementation libs.google.dagger
implementation libs.google.dagger.lib
kapt libs.google.dagger.compiler

// Logger
Expand Down Expand Up @@ -178,10 +178,20 @@ dependencies {
kaptAndroidTest libs.google.dagger.compiler
}

static def versionCodeDate() {
static def resolveVersionCode() {
if(System.getenv("PR_NUMBER") != null) {
return System.getenv("PR_NUMBER").toInteger()
}
return new Date().format("yyyyMMdd").toInteger()
}

static def resolveVersionSuffix(String variant) {
if(System.getenv("PR_NUMBER") != null){
return "-${variant}.${System.getenv("PR_NUMBER")}"
}
return "-${variant}.1"
}

if (!getGradle().getStartParameter().getTaskRequests()
.toString().contains("Fdroid")){
apply plugin: 'com.google.gms.google-services'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,41 +109,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(OONITests.CIRCUMVENTION.toOONIDescriptor(c), 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(OONITests.CIRCUMVENTION.toOONIDescriptor(c), 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 @@ -19,6 +19,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 @@ -28,6 +29,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 @@ -65,12 +67,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 @@ -84,7 +85,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 @@ -100,7 +101,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 @@ -3,6 +3,7 @@
import static org.openobservatory.ooniprobe.activity.overview.OverviewViewModel.SELECT_ALL;
import static org.openobservatory.ooniprobe.activity.overview.OverviewViewModel.SELECT_NONE;
import static org.openobservatory.ooniprobe.activity.overview.OverviewViewModel.SELECT_SOME;
import static org.openobservatory.ooniprobe.common.PreferenceManagerExtensionKt.resolveStatus;

import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -83,8 +84,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setThemeColor(descriptor.getColor());
binding.icon.setImageResource(descriptor.getDisplayIcon(this));
binding.customUrl.setVisibility(descriptor.getName().equals(OONITests.WEBSITES.getLabel()) ? View.VISIBLE : View.GONE);
Markwon markwon = Markwon.builder(this).usePlugin(new ReadMorePlugin(getString(R.string.OONIRun_ReadMore), getString(R.string.OONIRun_ReadLess))).build();
if (descriptor.getName().equals(OONITests.EXPERIMENTAL.name())) {
Markwon markwon = Markwon.builder(this)
.usePlugin(new ReadMorePlugin(getString(R.string.OONIRun_ReadMore), getString(R.string.OONIRun_ReadLess), 400))
.build();
if (Objects.equals(descriptor.getName(), OONITests.EXPERIMENTAL.name())) {
markwon.setMarkdown(binding.desc, descriptor.getDescription());
if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) {
binding.desc.setTextDirection(View.TEXT_DIRECTION_RTL);
Expand Down Expand Up @@ -133,14 +136,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
});

if (adapter.isSelectedAllItems()) {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_CHECKED);
} else if (adapter.isNotSelectedAnyGroupItem()) {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_UNCHECKED);
if (descriptor.getName().equals(OONITests.EXPERIMENTAL.getLabel())) {
binding.switchTests.setChecked(resolveStatus(preferenceManager, descriptor.getName(), descriptor.preferencePrefix(), true));
} else {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_INDETERMINATE);
if (adapter.isSelectedAllItems()) {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_CHECKED);
} else if (adapter.isNotSelectedAnyGroupItem()) {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_UNCHECKED);
} else {
binding.switchTests.setCheckedState(MaterialCheckBox.STATE_INDETERMINATE);
}
}
binding.switchTests.setEnabled(descriptor.hasPreferencePrefix());
// Expand all groups
for (int i = 0; i < adapter.getGroupCount(); i++) {
binding.expandableListView.expandGroup(i);
Expand Down
Loading

0 comments on commit b78e42f

Please sign in to comment.