parent
b2a1ba777d
commit
c3b65d286f
@ -0,0 +1,31 @@
|
||||
package eu.kanade.mangafeed;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
|
||||
import static org.robolectric.util.FragmentTestUtil.startFragment;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import eu.kanade.mangafeed.BuildConfig;
|
||||
import eu.kanade.mangafeed.ui.fragment.LibraryFragment;
|
||||
import eu.kanade.mangafeed.util.DefaultConfig;
|
||||
|
||||
/**
|
||||
* Created by len on 1/10/15.
|
||||
*/
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = DefaultConfig.EMULATE_SDK)
|
||||
public class LibraryFragmentTest {
|
||||
|
||||
@Test
|
||||
public void mangaList_shouldNotBeEmpty() {
|
||||
LibraryFragment fragment = LibraryFragment.newInstance();
|
||||
startFragment(fragment);
|
||||
assertNotNull(fragment);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package eu.kanade.mangafeed;
|
||||
|
||||
/**
|
||||
* Created by len on 1/10/15.
|
||||
*/
|
||||
import android.os.Build;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import eu.kanade.mangafeed.ui.activity.MainActivity;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
public class MainActivityTest {
|
||||
private MainActivity activity;
|
||||
|
||||
// @Before => JUnit 4 annotation that specifies this method should run before each test is run
|
||||
// Useful to do setup for objects that are needed in the test
|
||||
@Before
|
||||
public void setup() {
|
||||
// Convenience method to run MainActivity through the Activity Lifecycle methods:
|
||||
// onCreate(...) => onStart() => onPostCreate(...) => onResume()
|
||||
activity = Robolectric.setupActivity(MainActivity.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validate() {
|
||||
Toolbar toolbar = (Toolbar)activity.findViewById(R.id.toolbar);
|
||||
assertNotNull(toolbar);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package eu.kanade.mangafeed;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Created by len on 1/10/15.
|
||||
*/
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UseModule {
|
||||
Class value();
|
||||
}
|
Loading…
Reference in new issue