Skip to content

Instantly share code, notes, and snippets.

View ecgreb's full-sized avatar

Chuck Greb ecgreb

View GitHub Profile
class TestLayoutInflater extends LayoutInflater {
private int resource;
private ViewGroup root;
TestLayoutInflater(Context context) {
super(context);
}
@Override public View inflate(int resource, ViewGroup root) {
this.resource = resource;
public class MapView extends RelativeLayout {
private static final String MAPZEN_RIGHTS = "https://mapzen.com/rights/";
public static final int OVERLAY_MODE_SDK = 0;
public static final int OVERLAY_MODE_CLASSIC = 1;
@Inject MapInitializer mapInitializer;
// ...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr format="enum" name="overlayMode">
<enum name="sdk" value="0"/>
<enum name="classic" value="1"/>
</attr>
<declare-styleable name="MapView">
<attr name="overlayMode" />
</declare-styleable>
// TODO: Implement put/get for non-String values.
public class TestSharedPreferences implements SharedPreferences {
private static TestSharedPreferences instance = new TestSharedPreferences();
public static SharedPreferences instance() {
return instance;
}
private TestSharedPreferences() {
public class AccountStoreTest {
private AccountStore accountStore = new TestAccountStore(new Activity());
@Test public void shouldNotBeNull() throws Exception {
assertThat(accountStore).isNotNull();
}
@Test
public void shouldStoreCredentials() throws Exception {
public class AccountStore {
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
private final Context context;
public AccountStore(Context context) {
this.context = context;
}
java.lang.NullPointerException
at com.example.ecgreb.mvpc.model.AccountStore.storeCredentials(AccountStore.java:21)
at com.example.ecgreb.mvpc.model.AccountStoreTest.shouldStoreCredentials(AccountStoreTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
public class AccountStoreTest {
private AccountStore accountStore = new AccountStore(new Activity());
@Test public void shouldNotBeNull() throws Exception {
assertThat(accountStore).isNotNull();
}
@Test
public void shouldStoreCredentials() throws Exception {
public class AccountStore {
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
private final Context context;
public AccountStore(Context context) {
this.context = context;
}
@Test public void setRequest_shouldRegisterGpsAndNetworkIfPriorityHighAccuracy()
throws Exception {
FusionEngine fusionEngine =
new FusionEngine(application, new TestCallback());
fusionEngine.setRequest(LocationRequest.create()
.setPriority(PRIORITY_HIGH_ACCURACY));
Collection<String> providers = shadowLocationManager
.getProvidersForListener(fusionEngine);