Commit 63daf563 authored by David Maunder's avatar David Maunder Committed by Commit Bot

Cancel share if tab is uninitialized

We now enforce tab attributes cannot be acquired
if tab is uninitialized.

Bug: 1117396
Change-Id: Ie928bbc6f23cab3ebab7d4e11fe085658010bece
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363128
Commit-Queue: David Maunder <davidjm@chromium.org>
Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799293}
parent 10dd25ba
......@@ -79,6 +79,9 @@ class ScreenshotShareSheetMediator {
* Sends the current image to the share target.
*/
private void share() {
if (!mTab.isInitialized()) {
return;
}
Bitmap bitmap = mModel.get(ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP);
WindowAndroid window = mTab.getWindowAndroid();
......
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.share.screenshot;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import android.app.Activity;
......@@ -97,6 +98,8 @@ public class ScreenshotShareSheetMediatorUnitTest {
doNothing().when(mShareCallback).showThirdPartyShareSheet(any(), any(), anyLong());
doReturn(true).when(mTab).isInitialized();
mModel = new PropertyModel(ScreenshotShareSheetViewProperties.ALL_KEYS);
mMediator = new MockScreenshotShareSheetMediator(mContext, mModel, mDeleteRunnable,
......@@ -131,6 +134,16 @@ public class ScreenshotShareSheetMediatorUnitTest {
verify(mDeleteRunnable).run();
}
@Test
public void onClickShareUninitialized() {
doReturn(false).when(mTab).isInitialized();
Callback<Integer> callback =
mModel.get(ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER);
callback.onResult(ScreenshotShareSheetViewProperties.NoArgOperation.SHARE);
Assert.assertFalse(mMediator.generateTemporaryUriFromBitmapCalled());
}
@Test
public void onClickInstall() {
Callback<Integer> callback =
......
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