Skip to content

Instantly share code, notes, and snippets.

@esmasui
Created August 31, 2012 09:31
Show Gist options
  • Select an option

  • Save esmasui/3550795 to your computer and use it in GitHub Desktop.

Select an option

Save esmasui/3550795 to your computer and use it in GitHub Desktop.
ActionBarSherlock4.1でActivituUnitTestCaseがエラーになる件
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.test.ActivityUnitTestCase;
public class MainActivityUnitTest extends ActivityUnitTestCase<MainActivity> {
private Intent _startIntent;
public MainActivityUnitTest() {
super(MainActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
Context targetContext = getInstrumentation().getTargetContext();
//Set your theme
targetContext.setTheme(R.style.AppTheme);
setActivityContext(targetContext);
_startIntent = new Intent(Intent.ACTION_MAIN);
}
public void testPreconditions() {
startActivity(_startIntent, null, null);
assertNotNull(getActivity());
}
}
@esmasui
Copy link
Author

esmasui commented Aug 31, 2012

Manifestでtheme設定してる場合。
Activity#onCreate()でsetTheme()してる場合は関係ないです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment