Search in sources :

Example 1 with BundleServiceRunner

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();
}
Also used : BundleServiceRunner(mortar.bundler.BundleServiceRunner) Bundle(android.os.Bundle) Test(org.junit.Test)

Example 2 with BundleServiceRunner

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");
}
Also used : BundleServiceRunner(mortar.bundler.BundleServiceRunner) Before(org.junit.Before)

Example 3 with BundleServiceRunner

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);
}
Also used : BundleServiceRunner(mortar.bundler.BundleServiceRunner) BundleServiceRunner.getBundleServiceRunner(mortar.bundler.BundleServiceRunner.getBundleServiceRunner) FlowDelegate(flow.FlowDelegate) GsonParceler(com.example.mortar.screen.GsonParceler) MortarScope(mortar.MortarScope) ChatListScreen(com.example.mortar.screen.ChatListScreen) Gson(com.google.gson.Gson)

Example 4 with BundleServiceRunner

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");
}
Also used : BundleServiceRunner(mortar.bundler.BundleServiceRunner) BundleServiceRunner.getBundleServiceRunner(mortar.bundler.BundleServiceRunner.getBundleServiceRunner)

Aggregations

BundleServiceRunner (mortar.bundler.BundleServiceRunner)4 BundleServiceRunner.getBundleServiceRunner (mortar.bundler.BundleServiceRunner.getBundleServiceRunner)2 Bundle (android.os.Bundle)1 ChatListScreen (com.example.mortar.screen.ChatListScreen)1 GsonParceler (com.example.mortar.screen.GsonParceler)1 Gson (com.google.gson.Gson)1 FlowDelegate (flow.FlowDelegate)1 MortarScope (mortar.MortarScope)1 Before (org.junit.Before)1 Test (org.junit.Test)1