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 e469114c245c1dd6e11c062cb591dcf0ccebba09..cd1b07fddb98a4849c6a53fe899b5b71666f14b8 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java |
@@ -32,6 +32,13 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
String mLastSelectedId = "None"; |
+ private static final ItemChooserDialog.ItemChooserRowIcon TEST_ICON1 = |
+ new ItemChooserDialog.ItemChooserRowIcon(R.drawable.ic_signal_cellular_0_bar_black_48dp, |
+ R.drawable.ic_signal_cellular_0_bar_white_48dp, "test icon1"); |
+ private static final ItemChooserDialog.ItemChooserRowIcon TEST_ICON2 = |
+ new ItemChooserDialog.ItemChooserRowIcon(R.drawable.ic_signal_cellular_1_bar_black_48dp, |
+ R.drawable.ic_signal_cellular_1_bar_white_48dp, "test icon2"); |
+ |
public ItemChooserDialogTest() { |
super(ChromeActivity.class); |
} |
@@ -202,6 +209,91 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
} |
@SmallTest |
+ public void testUpdateItemWithIconToNoIcon() throws InterruptedException { |
+ Dialog dialog = mChooserDialog.getDialogForTesting(); |
+ assertTrue(dialog.isShowing()); |
+ |
+ ItemChooserDialog.ItemAdapter itemAdapter = mChooserDialog.getItemAdapterForTesting(); |
+ |
+ // Initially the itemAdapter is empty. |
+ assertTrue(itemAdapter.isEmpty()); |
+ |
+ // Add item 1. |
+ ItemChooserDialog.ItemChooserRow item1 = |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1", TEST_ICON1); |
+ mChooserDialog.addOrUpdateItem(item1); |
+ assertEquals(1, itemAdapter.getCount()); |
+ assertEquals(itemAdapter.getItem(0), item1); |
+ |
+ // Add item 1 with no icon. |
+ ItemChooserDialog.ItemChooserRow item1_with_no_icon = |
juncai
2016/08/26 19:37:48
Use lowerCamelCase.
Same for the other variable n
ortuno
2016/09/12 05:11:28
Done.
|
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1"); |
+ mChooserDialog.addOrUpdateItem(item1_with_no_icon); |
+ assertEquals(1, itemAdapter.getCount()); |
+ // We should still see the original item with the icon. |
+ assertEquals(itemAdapter.getItem(0), item1); |
+ |
+ mChooserDialog.setIdleState(); |
+ mChooserDialog.dismiss(); |
+ } |
+ |
+ @SmallTest |
+ public void testUpdateItemWithNoIconToIcon() throws InterruptedException { |
+ Dialog dialog = mChooserDialog.getDialogForTesting(); |
+ assertTrue(dialog.isShowing()); |
+ |
+ ItemChooserDialog.ItemAdapter itemAdapter = mChooserDialog.getItemAdapterForTesting(); |
+ |
+ // Initially the itemAdapter is empty. |
+ assertTrue(itemAdapter.isEmpty()); |
+ |
+ // Add item 1 with no icon. |
+ ItemChooserDialog.ItemChooserRow item1_with_no_icon = |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1"); |
+ mChooserDialog.addOrUpdateItem(item1_with_no_icon); |
+ assertEquals(1, itemAdapter.getCount()); |
+ assertEquals(itemAdapter.getItem(0), item1_with_no_icon); |
+ |
+ // Add item 1 with icon. |
+ ItemChooserDialog.ItemChooserRow item1 = |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1", TEST_ICON1); |
+ mChooserDialog.addOrUpdateItem(item1); |
+ assertEquals(1, itemAdapter.getCount()); |
+ assertEquals(itemAdapter.getItem(0), item1); |
+ |
+ mChooserDialog.setIdleState(); |
+ mChooserDialog.dismiss(); |
+ } |
+ |
+ @SmallTest |
+ public void testUpdateItemWithNoIconToNoIcon() throws InterruptedException { |
+ Dialog dialog = mChooserDialog.getDialogForTesting(); |
+ assertTrue(dialog.isShowing()); |
+ |
+ ItemChooserDialog.ItemAdapter itemAdapter = mChooserDialog.getItemAdapterForTesting(); |
+ |
+ // Initially the itemAdapter is empty. |
+ assertTrue(itemAdapter.isEmpty()); |
+ |
+ // Add item 1 with no icon. |
+ ItemChooserDialog.ItemChooserRow item1_with_no_icon = |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1"); |
+ mChooserDialog.addOrUpdateItem(item1_with_no_icon); |
+ assertEquals(1, itemAdapter.getCount()); |
+ // We should still see the original item with the icon. |
+ assertEquals(itemAdapter.getItem(0), item1_with_no_icon); |
+ |
+ // Add item 1 with no icon again. |
+ mChooserDialog.addOrUpdateItem(item1_with_no_icon); |
+ assertEquals(1, itemAdapter.getCount()); |
+ // We should still see the original item with the icon. |
+ assertEquals(itemAdapter.getItem(0), item1_with_no_icon); |
+ |
+ mChooserDialog.setIdleState(); |
+ mChooserDialog.dismiss(); |
+ } |
+ |
+ @SmallTest |
public void testAddOrUpdateItemAndRemoveItemFromList() throws InterruptedException { |
Dialog dialog = mChooserDialog.getDialogForTesting(); |
assertTrue(dialog.isShowing()); |
@@ -224,14 +316,14 @@ public class ItemChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActi |
// Add item 1. |
ItemChooserDialog.ItemChooserRow item1 = |
- new ItemChooserDialog.ItemChooserRow("key1", "desc1"); |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1", TEST_ICON1); |
mChooserDialog.addOrUpdateItem(item1); |
assertEquals(1, itemAdapter.getCount()); |
assertEquals(itemAdapter.getItem(0), item1); |
- // Add item 1 with different description. |
+ // Add item 1 with different description and icon. |
ItemChooserDialog.ItemChooserRow item1_again = |
- new ItemChooserDialog.ItemChooserRow("key1", "desc1_again"); |
+ new ItemChooserDialog.ItemChooserRow("key1", "desc1_again", TEST_ICON2); |
mChooserDialog.addOrUpdateItem(item1_again); |
assertEquals(1, itemAdapter.getCount()); |
assertEquals(itemAdapter.getItem(0), item1_again); |