Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Fix view beeing null before unsubscribing from Subscriptions #27

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ public final void detachView() {
+ " did not call through to super.onDetachView()");
}

mView = null;
moveToState(State.VIEW_DETACHED, true);
mView = null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -161,7 +162,7 @@ public void testSleep() throws Exception {
@Override
public void onChange(final TiPresenter.State state,
final boolean beforeLifecycleEvent) {
states.add(new Object[]{state, beforeLifecycleEvent});
states.add(new Object[]{state, beforeLifecycleEvent, mPresenter.getView()});
}
});

Expand All @@ -172,10 +173,12 @@ public void onChange(final TiPresenter.State state,
final Object[] beforeLast = states.get(states.size() - 2);
assertEquals(beforeLast[0], TiPresenter.State.VIEW_DETACHED);
assertEquals(beforeLast[1], false);
assertNotNull(beforeLast[2]);

final Object[] last = states.get(states.size() - 1);
assertEquals(last[0], TiPresenter.State.VIEW_DETACHED);
assertEquals(last[1], true);
assertNotNull(last[2]);
}

@Test
Expand All @@ -185,7 +188,7 @@ public void testWakeup() throws Exception {
@Override
public void onChange(final TiPresenter.State state,
final boolean beforeLifecycleEvent) {
states.add(new Object[]{state, beforeLifecycleEvent});
states.add(new Object[]{state, beforeLifecycleEvent, mPresenter.getView()});
}
});

Expand All @@ -195,9 +198,11 @@ public void onChange(final TiPresenter.State state,
final Object[] beforeLast = states.get(states.size() - 2);
assertEquals(beforeLast[0], TiPresenter.State.VIEW_ATTACHED);
assertEquals(beforeLast[1], false);
assertNotNull(beforeLast[2]);

final Object[] last = states.get(states.size() - 1);
assertEquals(last[0], TiPresenter.State.VIEW_ATTACHED);
assertEquals(last[1], true);
assertNotNull(last[2]);
}
}