use of proton.inject.MockContext in project AndroidTraining by mixi-inc.
the class FieldListenerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mMockApplication = new MockApplication();
Proton.initialize(mMockApplication, new DefaultModule() {
@Override
protected void configure() {
super.configure();
bindFieldListener(TestAnnotation.class, FieldListenerTest.this);
}
});
mInjector = Proton.getInjector(new MockContext(mMockApplication));
}
use of proton.inject.MockContext in project AndroidTraining by mixi-inc.
the class ProviderListenerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mMockApplication = new MockApplication();
Proton.initialize(mMockApplication, new DefaultModule() {
@Override
protected void configure() {
super.configure();
bindProviderListener(ProviderListenerTest.this);
bind(Aaa.class);
}
});
mInjector = Proton.getInjector(new MockContext(mMockApplication));
}
use of proton.inject.MockContext in project AndroidTraining by mixi-inc.
the class ObserverTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mMockApplication = new MockApplication();
Proton.initialize(mMockApplication, new DefaultModule() {
@Override
protected void configure() {
super.configure();
bind(Observer.class);
}
});
mInjector = Proton.getInjector(new MockContext(mMockApplication));
}
use of proton.inject.MockContext in project AndroidTraining by mixi-inc.
the class StateRecoveryTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mMockApplication = new MockApplication();
Proton.initialize(mMockApplication, new DefaultModule() {
@Override
protected void configure() {
super.configure();
bind(Aaa.class);
}
});
mInjector = Proton.getInjector(new MockContext(mMockApplication));
mObserverManager = mInjector.getInstance(ObserverManager.class);
mStateEventObserver = mInjector.getInstance(StateEventObserver.class);
}
use of proton.inject.MockContext in project AndroidTraining by mixi-inc.
the class StateRecoveryTest method testRecovery.
public void testRecovery() {
mObserverManager.fire(new OnCreateEvent(null));
Aaa a1 = mInjector.getInstance(Aaa.class);
a1.intState = 1;
a1.integerState = Integer.valueOf(1);
a1.intArrayState[0] = 1;
ArrayList<Integer> integerList = new ArrayList<Integer>();
integerList.add(1);
a1.integerListState = integerList;
a1.stringState = "a";
a1.stringArrayState = new String[] { "aa" };
ParcelableClass parcelable = new ParcelableClass("a");
a1.parcelableState = parcelable;
ParcelableClass[] parcelableArray = new ParcelableClass[1];
parcelableArray[0] = new ParcelableClass("a");
a1.parcelableArrayState = parcelableArray;
Bundle outState = new Bundle();
mObserverManager.fire(new OnSaveInstanceStateEvent(outState));
mObserverManager.fire(new OnDestroyEvent());
Injector injector = Proton.getInjector(new MockContext(mMockApplication));
injector.getInstance(StateEventObserver.class);
injector.getInstance(ObserverManager.class).fire(new OnCreateEvent(outState));
Aaa a2 = injector.getInstance(Aaa.class);
assertNotSame(a1, a2);
assertEquals(1, a2.intState);
assertEquals(Integer.valueOf(1), a2.integerState);
assertEquals(1, a2.intArrayState[0]);
assertEquals("a", a2.stringState);
assertEquals("aa", a2.stringArrayState[0]);
assertEquals(integerList, a2.integerListState);
assertEquals("a", a2.parcelableState.string);
assertEquals("a", a2.parcelableArrayState[0].string);
injector.getInstance(ObserverManager.class).fire(new OnDestroyEvent());
}
Aggregations