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

Commit

Permalink
Merge pull request #27 from grandcentrix/bugfix/view_is_null_before_s…
Browse files Browse the repository at this point in the history
…ubscriptions_are_unsubscribed

Fix view beeing null before unsubscribing from Subscriptions
  • Loading branch information
StefMa authored Nov 4, 2016
2 parents e3e7718 + d5e62a6 commit ef4ed67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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]);
}
}

0 comments on commit ef4ed67

Please sign in to comment.