| 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..d1f1df81f8433b96a5a059704ed7484f766993f8 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,25 +130,24 @@ 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());
|
| -
|
| - 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.setIdleState();
|
| + // 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());
|
|
|
| // Select the first item and verify it got selected.
|
| @@ -157,6 +157,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.setIdleState();
|
| +
|
| + // 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());
|
| + 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 +193,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);
|
|
|