package de.blau.android;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.orhanobut.mockwebserverplus.MockWebServerPlus;
import android.app.Activity;
import android.app.Instrumentation;
import android.app.Instrumentation.ActivityMonitor;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import de.blau.android.prefs.AdvancedPrefDatabase;
import de.blau.android.prefs.Preferences;
import de.blau.android.resources.TileLayerServer;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class HelpViewerTest {
MockWebServerPlus mockServer = null;
Context context = null;
ActivityMonitor monitor = null;
AdvancedPrefDatabase prefDB = null;
Instrumentation instrumentation = null;
Main main = null;
@Rule
public ActivityTestRule<Main> mActivityRule = new ActivityTestRule<>(Main.class);
@Before
public void setup() {
instrumentation = InstrumentationRegistry.getInstrumentation();
context = instrumentation.getTargetContext();
monitor = instrumentation.addMonitor(HelpViewer.class.getName(), null, false);
main = (Main)mActivityRule.getActivity();
Preferences prefs = new Preferences(context);
prefs.setBackGroundLayer(TileLayerServer.LAYER_NONE); // try to avoid downloading tiles
main.getMap().setPrefs(main, prefs);
}
@After
public void teardown() {
instrumentation.removeMonitor(monitor);
}
@Test
public void startHelp() {
HelpViewer.start(main, R.string.help_main);
Activity helpViewer = instrumentation.waitForMonitorWithTimeout(monitor, 30000);
Assert.assertTrue(helpViewer instanceof HelpViewer);
}
}