Commit 0b7a581e authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Fix ContactsPickerDialogTest.

Since the dialog code always calls ContactsPicker.onDialogDismssed, but
the test did not launch the dialog through ContactsPicker, the null
assert was hit. Change the test to launch the dialog by way of
ContactsPicker.

Bug: 1125409
Change-Id: I2212aca6e13b960dfe09ae145f9f75e70830e405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2394647
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804813}
parent 4db6ddd6
...@@ -32,6 +32,7 @@ import org.chromium.blink.mojom.ContactIconBlob; ...@@ -32,6 +32,7 @@ import org.chromium.blink.mojom.ContactIconBlob;
import org.chromium.components.browser_ui.widget.RecyclerViewTestUtils; import org.chromium.components.browser_ui.widget.RecyclerViewTestUtils;
import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate; import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate;
import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate.SelectionObserver; import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate.SelectionObserver;
import org.chromium.content_public.browser.ContactsPicker;
import org.chromium.content_public.browser.ContactsPickerListener; import org.chromium.content_public.browser.ContactsPickerListener;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.content_public.browser.test.util.TestTouchUtils; import org.chromium.content_public.browser.test.util.TestTouchUtils;
...@@ -47,7 +48,6 @@ import java.util.ArrayList; ...@@ -47,7 +48,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable;
/** /**
* Tests for the ContactsPickerDialog class. * Tests for the ContactsPickerDialog class.
...@@ -152,46 +152,45 @@ public class ContactsPickerDialogTest extends DummyUiActivityTestCase ...@@ -152,46 +152,45 @@ public class ContactsPickerDialogTest extends DummyUiActivityTestCase
* Creates a ContactPicker dialog with no filtering (default case). For a more fine-grained * Creates a ContactPicker dialog with no filtering (default case). For a more fine-grained
* version, see below. * version, see below.
*/ */
private ContactsPickerDialog createDialog(final boolean multiselect) throws Exception { private void createDialog(final boolean multiselect) throws Exception {
return createDialog(multiselect, /* includeNames = */ true, createDialog(multiselect, /* includeNames = */ true,
/* includeEmails = */ true, /* includeEmails = */ true,
/* includeTel = */ true, /* includeTel = */ true,
/* includeAddresses = */ true, /* includeAddresses = */ true,
/* includeIcons = */ true); /* includeIcons = */ true);
} }
private ContactsPickerDialog createDialog(final boolean multiselect, final boolean includeNames, private void createDialog(final boolean multiselect, final boolean includeNames,
final boolean includeEmails, final boolean includeTel, final boolean includeAddresses, final boolean includeEmails, final boolean includeTel, final boolean includeAddresses,
final boolean includeIcons) throws Exception { final boolean includeIcons) throws Exception {
mClosing = false; mClosing = false;
final ContactsPickerDialog dialog =
TestThreadUtils.runOnUiThreadBlocking(new Callable<ContactsPickerDialog>() { TestThreadUtils.runOnUiThreadBlocking(() -> {
ContactsPickerDialog dialog = null;
ContactsPicker.setContactsPickerDelegate((WindowAndroid windowAndroid,
ContactsPickerListener listener,
boolean multiple, boolean names,
boolean emails, boolean tels,
boolean addresses, boolean icons,
String formattedOrigin) -> {
mDialog = new ContactsPickerDialog(windowAndroid, new PickerAdapter() {
@Override @Override
public ContactsPickerDialog call() { protected String findOwnerEmail() {
final ContactsPickerDialog dialog = new ContactsPickerDialog(mWindowAndroid, return null;
new PickerAdapter() {
@Override
protected String findOwnerEmail() {
return null;
}
@Override
protected void addOwnerInfoToContacts(
ArrayList<ContactDetails> contacts) {}
},
ContactsPickerDialogTest.this, multiselect, includeNames,
includeEmails, includeTel, includeAddresses, includeIcons,
"example.com");
dialog.show();
return dialog;
} }
}); @Override
protected void addOwnerInfoToContacts(ArrayList<ContactDetails> contacts) {}
mSelectionDelegate = dialog.getCategoryViewForTesting().getSelectionDelegateForTesting(); }, listener, multiple, names, emails, tels, addresses, icons, formattedOrigin);
mDialog.show();
return true;
});
ContactsPicker.showContactsPicker(mWindowAndroid, this, multiselect, includeNames,
includeEmails, includeTel, includeAddresses, includeIcons, "example.com");
});
mSelectionDelegate = mDialog.getCategoryViewForTesting().getSelectionDelegateForTesting();
if (!multiselect) mSelectionDelegate.setSingleSelectionMode(); if (!multiselect) mSelectionDelegate.setSingleSelectionMode();
mSelectionDelegate.addObserver(this); mSelectionDelegate.addObserver(this);
mDialog = dialog;
return dialog;
} }
/** /**
......
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