Commit a6a4581d authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

[Screenshotz] Flesh out MVC for upstream sharesheet.

This also adds the screenshot to the view.
https://hsv.googleplex.com/5993630915362816

Test classes for the view and mediator are also added.

Bug: 1034733
Change-Id: Iaadf3e32d87c31bf453c049b416fa2cd7bf6445f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2211050
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776167}
parent ce14e58b
......@@ -41,6 +41,7 @@ chrome_junit_test_java_sources += start_surface_junit_java_sources
chrome_junit_test_java_sources += tab_management_junit_java_sources
chrome_test_java_sources += tab_management_test_java_sources
chrome_test_java_sources += share_test_java_sources
chrome_junit_test_java_sources += share_junit_test_java_sources
if (enable_arcore) {
chrome_java_sources += [
......
......@@ -12,6 +12,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TODO (crbug.com/1034733) Fix that this button is being
partially covered by the iamgeview -->
<org.chromium.ui.widget.ChromeImageButton
android:id="@+id/close_button"
style="@style/ToolbarButton"
......@@ -19,63 +21,83 @@
android:contentDescription="@string/close"
app:tint="@color/default_icon_color_tint_list" />
<!-- TODO: Add a frame layout to hold the screenshot preview. -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp"
android:weightSum="4"
android:orientation="horizontal"
android:layout_gravity="start|bottom">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="@+id/edit"
android:text="@string/screenshot_edit_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/edit"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="end|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
<org.chromium.ui.widget.ChromeImageView
android:id="@+id/screenshot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:padding="16dp" />
<TextView
android:id="@+id/delete"
android:text="@string/screenshot_delete_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/delete"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
</FrameLayout>
<TextView
android:id="@+id/save"
android:text="@string/screenshot_save_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/save"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp"
android:weightSum="4"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_gravity="start|bottom">
<TextView
android:id="@+id/share"
android:text="@string/screenshot_share_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/share"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="start|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
<TextView
android:id="@+id/edit"
android:text="@string/screenshot_edit_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/edit"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="end|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
</LinearLayout>
<TextView
android:id="@+id/delete"
android:text="@string/screenshot_delete_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/delete"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
<TextView
android:id="@+id/save"
android:text="@string/screenshot_save_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/save"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
<TextView
android:id="@+id/share"
android:text="@string/screenshot_share_title"
style="@style/SplitToolbarButton"
android:drawableTop="@drawable/share"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="start|bottom"
android:background="?attr/selectableItemBackgroundBorderless"
app:tint="@color/default_icon_color_tint_list" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
......
......@@ -78,7 +78,8 @@ public class ScreenshotCoordinator {
* Opens the screenshot sharesheet.
*/
private void launchSharesheet() {
ScreenshotShareSheetCoordinator shareSheet = new ScreenshotShareSheetCoordinator(mActivity);
ScreenshotShareSheetDialogCoordinator shareSheet =
new ScreenshotShareSheetDialogCoordinator(mActivity, mScreenshot);
shareSheet.showShareSheet();
mScreenshot = null;
}
......
......@@ -4,39 +4,41 @@
package org.chromium.chrome.browser.share.screenshot;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Bitmap;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Coordinator for displaying the screenshot share sheet.
*/
public class ScreenshotShareSheetCoordinator {
private final ScreenshotShareSheetDialog mDialog;
private final FragmentManager mFragmentManager;
private final ScreenshotShareSheetMediator mMediator;
private final PropertyModel mModel;
/**
* Constructs a new ShareSheetCoordinator.
*
* @param context The context to use for user permissions.
* @param screenshot The screenshot to be shared.
* @param deleteRunanble The runnable to be called on cancel or delete.
* @param screenshotShareSheetView the view for the screenshot share sheet.
*/
public ScreenshotShareSheetCoordinator(Activity activity) {
mDialog = new ScreenshotShareSheetDialog();
public ScreenshotShareSheetCoordinator(Context context, Bitmap screenshot,
Runnable deleteRunnable, ScreenshotShareSheetView screenshotShareSheetView) {
ArrayList<PropertyKey> allProperties =
new ArrayList<>(Arrays.asList(ScreenshotShareSheetViewProperties.ALL_KEYS));
mModel = new PropertyModel(allProperties);
mFragmentManager = activity.getFragmentManager();
// TODO(crbug/1024586) Flesh out MVC for the upstream screenshot MVC.
}
mModel.set(ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP, screenshot);
mMediator = new ScreenshotShareSheetMediator(mModel, deleteRunnable);
/**
* Show the main share sheet dialog.
*/
protected void showShareSheet() {
mDialog.show(mFragmentManager, null);
}
/**
* Dismiss the main dialog.
*/
public void dismiss() {
mDialog.dismiss();
PropertyModelChangeProcessor.create(
mModel, screenshotShareSheetView, ScreenshotShareSheetViewBinder::bind);
}
}
......@@ -7,25 +7,37 @@ package org.chromium.chrome.browser.share.screenshot;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AlertDialog;
import org.chromium.chrome.R;
import org.chromium.ui.widget.ChromeImageButton;
/**
* ScreenshotShareSheetDialog is the main view for sharing non edited screenshots.
*/
public class ScreenshotShareSheetDialog extends DialogFragment {
private Context mContext;
private ScreenshotShareSheetView mDialogView;
private Bitmap mScreenshot;
private Runnable mDeleteRunnable;
/**
* The ScreenshotShareSheetDialog constructor.
*/
public ScreenshotShareSheetDialog() {}
/**
* Initialize the dialog outside of the constructor as fragments require default constructor.
* @param screenshot The screenshot image to show.
* @param deleteRunnable The function to call on delete.
*/
public void init(Bitmap screenshot, Runnable deleteRunnable) {
mScreenshot = screenshot;
mDeleteRunnable = deleteRunnable;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
......@@ -36,18 +48,13 @@ public class ScreenshotShareSheetDialog extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder =
new AlertDialog.Builder(getActivity(), R.style.Theme_Chromium_Fullscreen);
builder.setView(getDialogView());
return builder.create();
}
private View getDialogView() {
ScreenshotShareSheetView dialogView =
ScreenshotShareSheetView screenshotShareSheetView =
(ScreenshotShareSheetView) getActivity().getLayoutInflater().inflate(
org.chromium.chrome.browser.share.R.layout.screenshot_share_sheet, null);
ChromeImageButton closeButton =
(ChromeImageButton) dialogView.findViewById(R.id.close_button);
closeButton.setOnClickListener(v -> dismiss());
builder.setView(screenshotShareSheetView);
return dialogView;
ScreenshotShareSheetCoordinator shareCoordinator = new ScreenshotShareSheetCoordinator(
mContext, mScreenshot, mDeleteRunnable, screenshotShareSheetView);
return builder.create();
}
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.screenshot;
import android.app.Activity;
import android.app.FragmentManager;
import android.graphics.Bitmap;
/**
* Coordinator for displaying the screenshot share sheet dialog.
*/
public class ScreenshotShareSheetDialogCoordinator {
private final ScreenshotShareSheetDialog mDialog;
private final FragmentManager mFragmentManager;
private final Bitmap mScreenshot;
/**
* Constructs a new ShareSheetCoordinator.
*
* @param context The context to use for user permissions.
* @param screenshot The screenshot to be shared.
*/
public ScreenshotShareSheetDialogCoordinator(Activity activity, Bitmap screenshot) {
mFragmentManager = activity.getFragmentManager();
mScreenshot = screenshot;
mDialog = new ScreenshotShareSheetDialog();
mDialog.init(mScreenshot, this::dismiss);
}
/**
* Show the main share sheet dialog.
*/
protected void showShareSheet() {
mDialog.show(mFragmentManager, null);
}
/**
* Dismiss the main dialog.
*/
public void dismiss() {
mDialog.dismiss();
}
}
......@@ -4,25 +4,56 @@
package org.chromium.chrome.browser.share.screenshot;
import android.content.Context;
import org.chromium.chrome.browser.share.screenshot.ScreenshotShareSheetViewProperties.NoArgOperation;
import org.chromium.ui.modelutil.PropertyModel;
/**
* ScreenshotShareSheetMediator is in charge of calculating and setting values for
* ScreenshotShareSheetViewProperties.
*/
class ScreenshotShareSheetMediator implements ShareImageFileUtils.OnImageSaveListener {
private final Context mContext;
private final PropertyModel mPropertyModel;
class ScreenshotShareSheetMediator {
private final PropertyModel mModel;
private final Runnable mDeleteRunnable;
/**
* The ScreenshotShareSheetMediator constructor.
* @param context The context to use.
* @param propertyModel The property modelto use to communicate with views.
*/
ScreenshotShareSheetMediator(Context context, PropertyModel propertyModel) {
mContext = context;
mPropertyModel = propertyModel;
ScreenshotShareSheetMediator(PropertyModel propertyModel, Runnable deleteRunnable) {
mDeleteRunnable = deleteRunnable;
mModel = propertyModel;
mModel.set(ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER,
operation -> { performNoArgOperation(operation); });
}
/**
* Performs the operation passed in.
*
* @param operation The operation to perform.
*/
public void performNoArgOperation(
@ScreenshotShareSheetViewProperties.NoArgOperation int operation) {
if (NoArgOperation.SHARE == operation) {
share();
} else if (NoArgOperation.SAVE == operation) {
save();
} else if (NoArgOperation.DELETE == operation) {
mDeleteRunnable.run();
}
}
/**
* Sends the current image to the share target.
*/
private void share() {
// TODO(crbug/1024586): export image
}
/**
* Saves the current image.
*/
private void save() {
// TODO(crbug/1024586):save image
}
}
......@@ -5,9 +5,18 @@
package org.chromium.chrome.browser.share.screenshot;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.share.R;
import org.chromium.chrome.browser.share.screenshot.ScreenshotShareSheetViewProperties.NoArgOperation;
import org.chromium.ui.widget.ChromeImageView;
/**
* Manages the Android View representing the Screenshot share panel.
*/
......@@ -16,4 +25,40 @@ class ScreenshotShareSheetView extends FrameLayout {
public ScreenshotShareSheetView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Sets the listeners for all no arg operations.
*
* @param noArgOperationCallback Callback to perform.
*/
public void setNoArgOperationsListeners(Callback<Integer> noArgOperationCallback) {
setNoArgOperationListener(NoArgOperation.SHARE, R.id.share, noArgOperationCallback);
setNoArgOperationListener(NoArgOperation.SAVE, R.id.save, noArgOperationCallback);
setNoArgOperationListener(NoArgOperation.DELETE, R.id.delete, noArgOperationCallback);
setNoArgOperationListener(NoArgOperation.DELETE, R.id.close_button, noArgOperationCallback);
}
/**
* Sets the listener for an operation with zero arguments.
*
* @param operation The type of operation as defined by BottomBarProperties.NoArgOperation
* @param viewId The id to listen for a tap on
* @param setNoArgOperationCallback The callback to perform on tap
*/
private void setNoArgOperationListener(
Integer operation, int viewId, Callback<Integer> noArgOperationCallback) {
View button = findViewById(viewId);
button.setOnClickListener(v -> { noArgOperationCallback.onResult(operation); });
}
/**
* Updates Screenshot image on panel.
*
* @param bitmap The {@link Bitmap} to display.
*/
public void updateScreenshotBitmap(Bitmap bitmap) {
ChromeImageView screenshotImageView = findViewById(R.id.screenshot);
Drawable drawable = new BitmapDrawable(bitmap);
screenshotImageView.setImageDrawable(drawable);
}
}
......@@ -6,11 +6,17 @@ package org.chromium.chrome.browser.share.screenshot;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor.ViewBinder;
/** The view binder for the Screenshot Share Sheet. */
class ScreenshotShareSheetViewBinder
implements ViewBinder<PropertyModel, ScreenshotShareSheetView, PropertyKey> {
@Override
public void bind(PropertyModel model, ScreenshotShareSheetView view, PropertyKey propertyKey) {}
class ScreenshotShareSheetViewBinder {
public static void bind(
PropertyModel model, ScreenshotShareSheetView view, PropertyKey propertyKey) {
if (ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER == propertyKey) {
view.setNoArgOperationsListeners(
model.get(ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER));
} else if (ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP == propertyKey) {
view.updateScreenshotBitmap(
model.get(ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP));
}
}
}
......@@ -4,8 +4,40 @@
package org.chromium.chrome.browser.share.screenshot;
import android.graphics.Bitmap;
import androidx.annotation.IntDef;
import org.chromium.base.Callback;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableObjectPropertyKey;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
class ScreenshotShareSheetViewProperties {
public static final PropertyKey[] ALL_KEYS = {};
/**
* Callback to perform the specified operation. Argument to callback must be a
* NoArgOperation
*/
public static final WritableObjectPropertyKey<Callback<Integer>> NO_ARG_OPERATION_LISTENER =
new WritableObjectPropertyKey<Callback<Integer>>();
public static final WritableObjectPropertyKey<Bitmap> SCREENSHOT_BITMAP =
new WritableObjectPropertyKey<>();
/**
* Set of operations that don't require additional arguments. If a callback requires an
* argument, it should defined separately.
*/
@IntDef({NoArgOperation.NONE, NoArgOperation.SHARE, NoArgOperation.SAVE, NoArgOperation.DELETE})
@Retention(RetentionPolicy.SOURCE)
public @interface NoArgOperation {
int NONE = 0;
int SHARE = 1;
int SAVE = 2;
int DELETE = 3;
}
public static final PropertyKey[] ALL_KEYS =
new PropertyKey[] {NO_ARG_OPERATION_LISTENER, SCREENSHOT_BITMAP};
}
......@@ -29,6 +29,8 @@ share_java_sources = [
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotCoordinator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetCoordinator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetDialog.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetDialogCoordinator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetMediator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetView.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetViewBinder.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetViewProperties.java",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.screenshot;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.verify;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.chromium.base.Callback;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.ui.modelutil.PropertyModel;
/**
* Tests for {@link ScreenshotShareSheetMediator}.
*/
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
// clang-format off
@Features.EnableFeatures(ChromeFeatureList.CHROME_SHARE_SCREENSHOT)
public class ScreenshotShareSheetMediatorUnitTest {
// clang-format on
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
@Mock
Runnable mDeleteRunnable;
private PropertyModel mModel;
private ScreenshotShareSheetMediator mMediator;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
doNothing().when(mDeleteRunnable).run();
mModel = new PropertyModel(ScreenshotShareSheetViewProperties.ALL_KEYS);
mMediator = new ScreenshotShareSheetMediator(mModel, mDeleteRunnable);
}
@Test
public void onClickDelete() {
Callback<Integer> callback =
mModel.get(ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER);
callback.onResult(ScreenshotShareSheetViewProperties.NoArgOperation.DELETE);
verify(mDeleteRunnable).run();
}
@After
public void tearDown() {}
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.screenshot;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.MediumTest;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.share.R;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.test.util.DummyUiActivityTestCase;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Tests for the {@link ScreenshotShareSheetView}.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@Features.EnableFeatures(ChromeFeatureList.CHROME_SHARE_SCREENSHOT)
public class ScreenshotShareSheetViewTest extends DummyUiActivityTestCase {
private ScreenshotShareSheetView mScreenshotView;
private PropertyModel mScreenshotModel;
private PropertyModelChangeProcessor mScreenshotMCP;
private AtomicBoolean mCloseClicked = new AtomicBoolean();
private AtomicBoolean mShareClicked = new AtomicBoolean();
private AtomicBoolean mSaveClicked = new AtomicBoolean();
private Callback<Integer> mMockNoArgListener = new Callback<Integer>() {
@Override
public void onResult(@ScreenshotShareSheetViewProperties.NoArgOperation Integer operation) {
if (ScreenshotShareSheetViewProperties.NoArgOperation.SHARE == operation) {
mShareClicked.set(true);
} else if (ScreenshotShareSheetViewProperties.NoArgOperation.SAVE == operation) {
mSaveClicked.set(true);
} else if (ScreenshotShareSheetViewProperties.NoArgOperation.DELETE == operation) {
mCloseClicked.set(true);
}
}
};
@Override
public void setUpTest() throws Exception {
super.setUpTest();
ViewGroup view = new LinearLayout(getActivity());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
TestThreadUtils.runOnUiThreadBlocking(() -> {
getActivity().setContentView(view, params);
mScreenshotView = (ScreenshotShareSheetView) getActivity().getLayoutInflater().inflate(
R.layout.screenshot_share_sheet, null);
view.addView(mScreenshotView);
});
SelectionDelegate<Integer> mSelectionDelegate = new SelectionDelegate<>();
mScreenshotModel =
new PropertyModel.Builder(ScreenshotShareSheetViewProperties.ALL_KEYS)
.with(ScreenshotShareSheetViewProperties.NO_ARG_OPERATION_LISTENER,
mMockNoArgListener)
.build();
TestThreadUtils.runOnUiThreadBlocking(() -> {
mScreenshotMCP = PropertyModelChangeProcessor.create(
mScreenshotModel, mScreenshotView, ScreenshotShareSheetViewBinder::bind);
});
}
@Test
@MediumTest
@UiThreadTest
public void testClickToClose() {
ImageView closeButton = mScreenshotView.findViewById(R.id.close_button);
Assert.assertFalse(mCloseClicked.get());
closeButton.performClick();
Assert.assertTrue(mCloseClicked.get());
mCloseClicked.set(false);
}
@Override
public void tearDownTest() throws Exception {
mScreenshotMCP.destroy();
super.tearDownTest();
}
}
......@@ -3,4 +3,10 @@
# found in the LICENSE file.
# TODO(crbug.com/1022172): This should be a separate build target when circular dependencies are removed.
share_test_java_sources = [ "//chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/clipboard/ClipboardImageFileProviderTest.java" ]
share_test_java_sources = [
"//chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/clipboard/ClipboardImageFileProviderTest.java",
"//chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetViewTest.java",
]
share_junit_test_java_sources = [ "//chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/screenshot/ScreenshotShareSheetMediatorUnitTest.java" ]
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