use of mortar.bundler.BundleServiceRunner in project mortar by square.
the class PresenterTest method childPresentersGetTheirOwnBundles.
@Test
public void childPresentersGetTheirOwnBundles() {
BundleServiceRunner bundleServiceRunner = BundleServiceRunner.getBundleServiceRunner(activityScope);
bundleServiceRunner.onCreate(null);
ParentPresenter presenter = new ParentPresenter();
SomeView view = new SomeView();
presenter.takeView(view);
Bundle bundle = new Bundle();
bundleServiceRunner.onSaveInstanceState(bundle);
presenter.dropView(view);
bundleServiceRunner.onCreate(bundle);
presenter.takeView(view);
/**
* Assertions in {@link ChildPresenter#onLoad(android.os.Bundle)} are the real test,
* but let's check that the were run
*/
assertThat(presenter.childOne.loaded).isTrue();
assertThat(presenter.childTwo.loaded).isTrue();
}
use of mortar.bundler.BundleServiceRunner in project mortar by square.
the class PresenterTest method setUp.
@Before
public void setUp() {
root = MortarScope.buildRootScope().build("Root");
activityScope = root.buildChild().withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()).build("name");
}
use of mortar.bundler.BundleServiceRunner in project mortar by square.
the class MortarDemoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GsonParceler parceler = new GsonParceler(new Gson());
@SuppressWarnings("deprecation") FlowDelegate.NonConfigurationInstance nonConfig = (FlowDelegate.NonConfigurationInstance) getLastNonConfigurationInstance();
MortarScope parentScope = MortarScope.getScope(getApplication());
String scopeName = getLocalClassName() + "-task-" + getTaskId();
activityScope = parentScope.findChild(scopeName);
if (activityScope == null) {
activityScope = parentScope.buildChild().withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()).build(scopeName);
}
ObjectGraphService.inject(this, this);
getBundleServiceRunner(activityScope).onCreate(savedInstanceState);
actionBarOwner.takeView(this);
setContentView(R.layout.root_layout);
container = (PathContainerView) findViewById(R.id.container);
containerAsHandlesBack = (HandlesBack) container;
flowDelegate = FlowDelegate.onCreate(nonConfig, getIntent(), savedInstanceState, parceler, History.single(new ChatListScreen()), this);
}
use of mortar.bundler.BundleServiceRunner in project mortar by square.
the class PopupPresenterTest method newProcess.
/** Simulate a new proecess by creating brand new scope instances. */
private void newProcess() {
root = MortarScope.buildRootScope().build("Root");
activityScope = root.buildChild().withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()).build("activity");
}
Aggregations