summaryrefslogtreecommitdiff
path: root/app/src/androidTestNormal/java/se/leap/bitmaskclient/base/BitmaskTest.java
blob: aa437c74477f1863af59c7db1569df4f08126c52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package se.leap.bitmaskclient.base;


import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasToString;
import static utils.CustomInteractions.tryResolve;

import androidx.test.espresso.DataInteraction;
import androidx.test.espresso.NoMatchingViewException;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import org.junit.FixMethodOrder;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import se.leap.bitmaskclient.R;

@LargeTest
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class BitmaskTest extends ProviderBaseTest {

    @Override
    public boolean configureProviderIfNeeded() {
        try {
            DataInteraction linearLayout = tryResolve(onData(hasToString(containsString("riseup.net")))
                            .inAdapterView(withId(R.id.provider_list)),
                    2);
            linearLayout.perform(click());
            return true;
        } catch (NoMatchingViewException e) {
            // it might be that the provider was already configured, so we print the stack
            // trace here and try to continue
            e.printStackTrace();
        }
        return false;
    }
}