Commit 03fc8301 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

feedv2: populate feed after clear

Bug: 1111806
Change-Id: I7662de6b7117a5434417a7b430b54bc042817175
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333995Reviewed-by: default avatarCathy Li <chili@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795033}
parent fd32fb67
...@@ -168,8 +168,10 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -168,8 +168,10 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
* Clear all the data related to all surfaces. * Clear all the data related to all surfaces.
*/ */
public static void clearAll() { public static void clearAll() {
FeedStreamSurface[] surfaces = null;
if (sSurfaces != null) { if (sSurfaces != null) {
for (FeedStreamSurface surface : sSurfaces) { surfaces = sSurfaces.toArray(new FeedStreamSurface[sSurfaces.size()]);
for (FeedStreamSurface surface : surfaces) {
surface.surfaceClosed(); surface.surfaceClosed();
} }
sSurfaces = null; sSurfaces = null;
...@@ -179,6 +181,12 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -179,6 +181,12 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
if (processScope != null) { if (processScope != null) {
processScope.resetAccount(); processScope.resetAccount();
} }
if (surfaces != null) {
for (FeedStreamSurface surface : surfaces) {
surface.surfaceOpened();
}
}
} }
/** /**
......
...@@ -38,6 +38,7 @@ import org.junit.runner.RunWith; ...@@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.InOrder;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
...@@ -590,12 +591,17 @@ public class FeedStreamSurfaceTest { ...@@ -590,12 +591,17 @@ public class FeedStreamSurfaceTest {
@SmallTest @SmallTest
public void testClearAll() { public void testClearAll() {
FeedStreamSurface.startup(); FeedStreamSurface.startup();
InOrder order = Mockito.inOrder(mFeedStreamSurfaceJniMock, mProcessScope);
mFeedStreamSurface.surfaceOpened(); mFeedStreamSurface.surfaceOpened();
verify(mFeedStreamSurfaceJniMock).surfaceOpened(anyLong(), any(FeedStreamSurface.class)); order.verify(mFeedStreamSurfaceJniMock)
.surfaceOpened(anyLong(), any(FeedStreamSurface.class));
FeedStreamSurface.clearAll(); FeedStreamSurface.clearAll();
verify(mFeedStreamSurfaceJniMock).surfaceClosed(anyLong(), any(FeedStreamSurface.class)); order.verify(mFeedStreamSurfaceJniMock)
verify(mProcessScope).resetAccount(); .surfaceClosed(anyLong(), any(FeedStreamSurface.class));
order.verify(mProcessScope).resetAccount();
order.verify(mFeedStreamSurfaceJniMock)
.surfaceOpened(anyLong(), any(FeedStreamSurface.class));
} }
@Test @Test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment