Created
December 2, 2013 16:55
-
-
Save moltak/7752613 to your computer and use it in GitHub Desktop.
MainActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gradle.app; | |
import android.content.res.Resources; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentActivity; | |
import android.widget.TextView; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.robolectric.Robolectric; | |
import static junit.framework.Assert.*; | |
/** | |
* Created by moltak on 12/2/13. | |
*/ | |
@RunWith(RobolectricGradleTestRunner.class) | |
public class MainActivityTest { | |
@Test | |
public void testInitialize() { | |
// activity get | |
FragmentActivity a = Robolectric.buildActivity(MainActivity.class).create().start().resume().get(); | |
// fragment not check | |
Fragment f1 = a.getSupportFragmentManager().findFragmentByTag("placeholderFragment"); | |
assertNotNull(f1); | |
// resource check | |
Resources r = a.getResources(); | |
String s = r.getString(R.string.hello_world); | |
TextView textView = (TextView)f1.getView().findViewById(R.id.textview); | |
String ts = textView.getText().toString(); | |
assertEquals(s, ts); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment