aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/activity/ProgressTest.java
blob: db2b9d952c475faba1efaa02c6dc9ddeebac9e49 (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
package cgeo.geocaching.activity;

import static org.assertj.core.api.Assertions.assertThat;

import cgeo.geocaching.AboutActivity;

import android.annotation.TargetApi;
import android.test.ActivityInstrumentationTestCase2;

/**
 * This test uses the about activity to avoid side effects like network and GPS being triggered by the main activity.
 *
 */
@TargetApi(8)
public class ProgressTest extends ActivityInstrumentationTestCase2<AboutActivity> {
    public ProgressTest() {
        super(AboutActivity.class);
    }

    public void testProgressWrapper() {
        final Progress progress = new Progress();

        assertThat(progress.isShowing()).isFalse(); // nothing shown initially

        progress.show(getActivity(), "Title", "Message", true, null);
        assertThat(progress.isShowing()).isTrue();

        progress.setMessage("Test");
        assertThat(progress.isShowing()).isTrue();

        for (int i = 0; i < 2; i++) { // fault tolerant when dismissing to often
            progress.dismiss();
            assertThat(progress.isShowing()).isFalse();
        }
    }
}