Commit 78638d61 authored by Dan Harrington's avatar Dan Harrington Committed by Chromium LUCI CQ

Don't try to load feed v2 content in public apk

Without internal src, there's no way to render the content.
So just don't request the content if there's no renderer.

Change-Id: I76304b3de576b9bf9662ecbbbe7317f91aa28580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627981
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: default avatarCathy Li <chili@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843317}
parent 2e87dfe1
......@@ -97,10 +97,13 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
static final String FEEDBACK_CONTEXT = "mobile_browser";
@VisibleForTesting
static final String XSURFACE_CARD_URL = "Card URL";
// For testing some functionality in the public APK.
@VisibleForTesting
public static boolean sRequestContentWithoutRendererForTesting;
private final long mNativeFeedStreamSurface;
private final FeedListContentManager mContentManager;
private final SurfaceScope mSurfaceScope;
private final SurfaceScope mSurfaceScope;
@VisibleForTesting
RecyclerView mRootView;
private final HybridListRenderer mHybridListRenderer;
......@@ -925,7 +928,11 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
assert (mContentManager.getItemCount() == mHeaderCount);
mOpened = true;
FeedStreamSurfaceJni.get().surfaceOpened(mNativeFeedStreamSurface, FeedStreamSurface.this);
// Don't ask native to load content if there's no way to render it.
if (mSurfaceScope != null || sRequestContentWithoutRendererForTesting) {
FeedStreamSurfaceJni.get().surfaceOpened(
mNativeFeedStreamSurface, FeedStreamSurface.this);
}
mHybridListRenderer.onSurfaceOpened();
}
......@@ -949,8 +956,10 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
mScrollReporter.onUnbind();
mSliceViewTracker.clear();
FeedStreamSurfaceJni.get().surfaceClosed(mNativeFeedStreamSurface, FeedStreamSurface.this);
if (mSurfaceScope != null || sRequestContentWithoutRendererForTesting) {
FeedStreamSurfaceJni.get().surfaceClosed(
mNativeFeedStreamSurface, FeedStreamSurface.this);
}
mOpened = false;
}
......
......@@ -159,6 +159,7 @@ public class FeedV2NewTabPageTest {
public void setUp() throws Exception {
SignInPromo.setDisablePromoForTests(mDisableSigninPromoCard);
mActivityTestRule.startMainActivityWithURL("about:blank");
FeedStreamSurface.sRequestContentWithoutRendererForTesting = true;
// EULA must be accepted, and internet connectivity is required, or the Feed will not
// attempt to load.
......
......@@ -143,6 +143,7 @@ public class FeedStreamSurfaceTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
FeedStreamSurface.sRequestContentWithoutRendererForTesting = true;
mActivity = Robolectric.buildActivity(Activity.class).setup().get();
mParent = new LinearLayout(mActivity);
mocker.mock(FeedStreamSurfaceJni.TEST_HOOKS, mFeedStreamSurfaceJniMock);
......
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