Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
| index 6632d82dac1d2c4ce789f61492bc43946266fd52..a0f6405fafb41d54ccc073f5a69561d7d9feea44 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
| @@ -61,10 +61,11 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
| SpannableString title = new SpannableString("title"); |
| String searching = new String("searching"); |
| SpannableString noneFound = new SpannableString("noneFound"); |
| - SpannableString status = new SpannableString("status"); |
| + SpannableString statusActive = new SpannableString("statusActive"); |
| + SpannableString statusIdle = new SpannableString("statusIdle"); |
| String positiveButton = new String("positiveButton"); |
| final ItemChooserDialog.ItemChooserLabels labels = new ItemChooserDialog.ItemChooserLabels( |
| - title, searching, noneFound, status, positiveButton); |
| + title, searching, noneFound, statusActive, statusIdle, positiveButton); |
| ItemChooserDialog dialog = ThreadUtils.runOnUiThreadBlockingNoException( |
| new Callable<ItemChooserDialog>() { |
| @Override |
| @@ -129,27 +130,27 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
| List<ItemChooserDialog.ItemChooserRow> devices = |
| new ArrayList<ItemChooserDialog.ItemChooserRow>(); |
| - mChooserDialog.showList(devices); |
| - |
| - // Listview should now be showing empty, with an empty view visible to |
| - // drive home the point and a status message at the bottom. |
| - assertEquals(View.VISIBLE, items.getVisibility()); |
| - assertEquals(View.VISIBLE, items.getEmptyView().getVisibility()); |
| - assertEquals("status", statusView.getText().toString()); |
| - assertFalse(button.isEnabled()); |
|
Finnur
2016/02/01 12:16:43
You CL description makes it sound like you are onl
ortuno
2016/02/01 17:00:31
In this part of the test we sent an empty list to
|
| - |
| - devices = new ArrayList<ItemChooserDialog.ItemChooserRow>(); |
| devices.add(new ItemChooserDialog.ItemChooserRow("key", "key")); |
| devices.add(new ItemChooserDialog.ItemChooserRow("key2", "key2")); |
| - mChooserDialog.showList(devices); |
| + mChooserDialog.addItemsToList(devices); |
| - // Two items showing, the emty view should be no more and the button |
| + // Two items showing, the empty view should be no more and the button |
| // should now be enabled. |
| assertEquals(View.VISIBLE, items.getVisibility()); |
| assertEquals(View.GONE, items.getEmptyView().getVisibility()); |
| - assertEquals("status", statusView.getText().toString()); |
| + assertEquals("statusActive", statusView.getText().toString()); |
| assertFalse(button.isEnabled()); |
| + mChooserDialog.discoveryIdle(); |
| + // After discovery stops the list should still be visible, |
| + // it should not show the empty view and the button should not be enabled. |
| + // The chooser should show the status idle text. |
| + assertEquals(View.VISIBLE, items.getVisibility()); |
| + assertEquals(View.GONE, items.getEmptyView().getVisibility()); |
| + assertEquals("statusIdle", statusView.getText().toString()); |
| + assertFalse(button.isEnabled()); |
| + |
| + |
|
Finnur
2016/02/01 12:16:43
nit: Extra line.
ortuno
2016/02/01 17:00:31
Done.
|
| // Select the first item and verify it got selected. |
| selectItem(dialog, 1, "key", true); |
| @@ -157,6 +158,34 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
| } |
| @SmallTest |
| + public void testNoItemsAddedDiscoveryIdle() throws InterruptedException { |
| + Dialog dialog = mChooserDialog.getDialogForTesting(); |
| + assertTrue(dialog.isShowing()); |
| + |
| + TextViewWithClickableSpans statusView = (TextViewWithClickableSpans) |
| + dialog.findViewById(R.id.status); |
| + final ListView items = (ListView) dialog.findViewById(R.id.items); |
| + final Button button = (Button) dialog.findViewById(R.id.positive); |
| + |
| + // Before we add items to the dialog, the 'searching' message should be |
| + // showing, the Commit button should be disabled and the list view hidden. |
| + assertEquals("searching", statusView.getText().toString()); |
| + assertFalse(button.isEnabled()); |
| + assertEquals(View.GONE, items.getVisibility()); |
| + |
| + mChooserDialog.discoveryIdle(); |
| + |
| + // Listview should now be showing empty, with an empty view visible to |
| + // drive home the point and a status message at the bottom. |
| + assertEquals(View.GONE, items.getVisibility()); |
|
ortuno
2016/02/01 17:00:31
quick question: Why do you need to make the list v
Finnur
2016/02/02 17:02:52
Not sure (long since forgotten).
|
| + assertEquals(View.VISIBLE, items.getEmptyView().getVisibility()); |
| + assertEquals("statusIdle", statusView.getText().toString()); |
| + assertFalse(button.isEnabled()); |
| + |
| + mChooserDialog.dismiss(); |
| + } |
| + |
| + @SmallTest |
| public void testDisabledSelection() throws InterruptedException { |
| Dialog dialog = mChooserDialog.getDialogForTesting(); |
| assertTrue(dialog.isShowing()); |
| @@ -165,7 +194,7 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
| new ArrayList<ItemChooserDialog.ItemChooserRow>(); |
| devices.add(new ItemChooserDialog.ItemChooserRow("key", "key")); |
| devices.add(new ItemChooserDialog.ItemChooserRow("key2", "key2")); |
| - mChooserDialog.showList(devices); |
| + mChooserDialog.addItemsToList(devices); |
| // Disable one item and try to select it. |
| mChooserDialog.setEnabled("key", false); |