blob: 763dd6932e8ff77bef9292d51122571e4d1efe01 [file] [log] [blame]
package com.xtremelabs.robolectric.shadows;
import android.app.Activity;
import android.content.Context;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(WithTestDefaultsRunner.class)
public class ContextTest {
private Context context;
@Before public void setUp() throws Exception {
context = new Activity();
}
@Test
public void shouldStubThemeStuff() throws Exception {
assertThat(context.obtainStyledAttributes(null), not(nullValue()));
assertThat(context.obtainStyledAttributes(0, null), not(nullValue()));
assertThat(context.obtainStyledAttributes(null, null), not(nullValue()));
assertThat(context.obtainStyledAttributes(null, null, 0, 0), not(nullValue()));
}
@Test
public void getCacheDir_shouldCreateDirectory() throws Exception {
assertTrue(context.getCacheDir().exists());
}
@Test
public void getFilesDir_shouldCreateDirectory() throws Exception {
assertTrue(context.getFilesDir().exists());
}
}