Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java |
| index d484e312df5448108e92dab240bd1092f2a01d21..9e7dc0405481f46320e03797fef603eeab6c05e7 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java |
| @@ -389,6 +389,76 @@ public class DownloadHistoryAdapterTest extends NativeLibraryTestBase { |
| assertEquals(itemCompleted.getId(), toDelete.iterator().next().getId()); |
| } |
| + @SmallTest |
| + public void testSearch_NoFilter() throws Exception { |
| + DownloadItem item0 = StubbedProvider.createDownloadItem(0, "19840116 12:00"); |
| + DownloadItem item1 = StubbedProvider.createDownloadItem(1, "19840116 12:01"); |
| + DownloadItem item2 = StubbedProvider.createDownloadItem(2, "19840117 12:00"); |
| + DownloadItem item3 = StubbedProvider.createDownloadItem(3, "19840117 12:01"); |
| + DownloadItem item4 = StubbedProvider.createDownloadItem(4, "19840118 12:00"); |
| + DownloadItem item5 = StubbedProvider.createDownloadItem(5, "19840118 12:01"); |
| + OfflinePageDownloadItem item6 = StubbedProvider.createOfflineItem(0, "19840118 6:00"); |
| + mDownloadDelegate.regularItems.add(item0); |
| + mDownloadDelegate.offTheRecordItems.add(item1); |
| + mDownloadDelegate.regularItems.add(item2); |
| + mDownloadDelegate.regularItems.add(item3); |
| + mDownloadDelegate.offTheRecordItems.add(item4); |
| + mDownloadDelegate.regularItems.add(item5); |
| + mOfflineDelegate.items.add(item6); |
| + initializeAdapter(true); |
| + checkAdapterContents(null, item5, item4, item6, null, item3, item2, null, item1, item0); |
| + |
| + // Perform a search that matches the file name for a few downloads. |
| + mAdapter.search("FiLe"); |
| + |
| + // Only items matching the query should be shown. |
| + checkAdapterContents(null, item2, null, item1, item0); |
| + |
| + mAdapter.onEndSearch(); |
|
gone
2017/01/20 20:13:00
onEndSearch and other things like that should be f
Theresa
2017/01/20 21:16:18
Done.
|
| + |
| + // All items should be shown again after the search is ended. |
| + checkAdapterContents(null, item5, item4, item6, null, item3, item2, null, item1, item0); |
| + |
| + // Perform a search that matches the hostname for a couple downloads. |
| + mAdapter.search("oNE"); |
| + |
| + checkAdapterContents(null, item4, null, item1); |
| + } |
| + |
| + @SmallTest |
| + public void testSearch_WithFilter() throws Exception { |
| + DownloadItem item0 = StubbedProvider.createDownloadItem(0, "19840116 12:00"); |
| + DownloadItem item1 = StubbedProvider.createDownloadItem(1, "19840116 12:01"); |
| + DownloadItem item2 = StubbedProvider.createDownloadItem(2, "19840117 12:00"); |
| + DownloadItem item3 = StubbedProvider.createDownloadItem(3, "19840117 12:01"); |
| + DownloadItem item4 = StubbedProvider.createDownloadItem(4, "19840118 12:00"); |
| + DownloadItem item5 = StubbedProvider.createDownloadItem(5, "19840118 12:01"); |
| + OfflinePageDownloadItem item6 = StubbedProvider.createOfflineItem(0, "19840118 6:00"); |
| + mDownloadDelegate.regularItems.add(item0); |
| + mDownloadDelegate.offTheRecordItems.add(item1); |
| + mDownloadDelegate.regularItems.add(item2); |
| + mDownloadDelegate.regularItems.add(item3); |
| + mDownloadDelegate.offTheRecordItems.add(item4); |
| + mDownloadDelegate.regularItems.add(item5); |
| + mOfflineDelegate.items.add(item6); |
| + initializeAdapter(true); |
| + checkAdapterContents(null, item5, item4, item6, null, item3, item2, null, item1, item0); |
| + |
| + // Change the filter |
| + mAdapter.onFilterChanged(DownloadFilter.FILTER_IMAGE); |
| + checkAdapterContents(null, item1, item0); |
| + |
| + mAdapter.search("FiRSt"); |
| + |
| + // Only items matching both the filter and the search query should be shown. |
| + checkAdapterContents(null, item0); |
| + |
| + mAdapter.onEndSearch(); |
| + |
| + // All items matching the filter should be shown after the search is ended. |
| + checkAdapterContents(null, item1, item0); |
| + } |
| + |
| /** Checks that the adapter has the correct items in the right places. */ |
| private void checkAdapterContents(Object... expectedItems) { |
| assertEquals(expectedItems.length, mAdapter.getItemCount()); |