Commit c5c717c3 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

[Android] Contacts Picker: Implement a render test.

The test selects three contacts, then selects all contacts
via the Select All checkbox and verifies that selection
looks right.

Bug: 860467
Change-Id: I366036c929f70e956017515093bade9f1f5f7ca6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106055
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752295}
parent 4fe6a9c9
......@@ -18,12 +18,14 @@ import androidx.recyclerview.widget.RecyclerView;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.blink.mojom.ContactIconBlob;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
......@@ -31,6 +33,7 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate;
......@@ -39,6 +42,7 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.content_public.browser.test.util.TestTouchUtils;
import org.chromium.payments.mojom.PaymentAddress;
import org.chromium.ui.ContactsPickerListener;
import org.chromium.ui.test.util.DisableAnimationsTestRule;
import java.nio.ByteBuffer;
import java.util.ArrayList;
......@@ -54,10 +58,17 @@ import java.util.concurrent.Callable;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ContactsPickerDialogTest
implements ContactsPickerListener, SelectionObserver<ContactDetails> {
@ClassRule
public static DisableAnimationsTestRule mDisableAnimationsTestRule =
new DisableAnimationsTestRule();
@Rule
public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule<>(ChromeActivity.class);
@Rule
public ChromeRenderTestRule mRenderTestRule = new ChromeRenderTestRule();
// The dialog we are testing.
private ContactsPickerDialog mDialog;
......@@ -793,4 +804,33 @@ public class ContactsPickerDialogTest
dismissDialog();
}
@Test
@LargeTest
@Feature("RenderTest")
public void testRenderContactSelection() throws Throwable {
setTestContacts(/* ownerEmail= */ "owner@example.com");
createDialog(/* multiselect= */ true);
Assert.assertTrue(mDialog.isShowing());
mRenderTestRule.render(mDialog.getCategoryViewForTesting(), "selection_none");
int expectedSelectionCount = 0;
clickView(1, ++expectedSelectionCount, /* expectSelection= */ true);
clickView(2, ++expectedSelectionCount, /* expectSelection= */ true);
clickView(3, ++expectedSelectionCount, /* expectSelection= */ true);
mRenderTestRule.render(mDialog.getCategoryViewForTesting(), "selection_some");
toggleSelectAll(/* expectedSelectionCount= */ 8, ContactsPickerAction.SELECT_ALL);
// The test disables animations, which can cause the tickmark not to show after the checkbox
// is checked, unless this is called directly thereafter.
TestThreadUtils.runOnUiThreadBlocking(
() -> { mDialog.getCategoryViewForTesting().jumpDrawablesToCurrentState(); });
mRenderTestRule.render(mDialog.getCategoryViewForTesting(), "selection_all");
dismissDialog();
}
}
163d9ba4eb2cd861b3e50cce8462357fa8cb5669
\ No newline at end of file
89ca67644ead85e147fd61942d10e2bfb1ff34f6
\ No newline at end of file
74553f4a666233d702df38c3a9aaccd0aabb3211
\ No newline at end of file
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