| Index: chrome/android/javatests/src/org/chromium/chrome/browser/history/HistoryAdapterTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/history/HistoryAdapterTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/history/HistoryAdapterTest.java
|
| index 0040d6b5f864695009ff27caf0164f974f4569fc..5810e5c005d3c5566e806362ab5642ee73ffcc42 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/history/HistoryAdapterTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/history/HistoryAdapterTest.java
|
| @@ -9,12 +9,17 @@ import static org.chromium.chrome.browser.widget.DateDividedAdapter.TYPE_HEADER;
|
| import static org.chromium.chrome.browser.widget.DateDividedAdapter.TYPE_NORMAL;
|
|
|
| import android.support.test.filters.SmallTest;
|
| -import android.test.InstrumentationTestCase;
|
| +
|
| +import org.junit.Assert;
|
| +import org.junit.Before;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
|
|
| import org.chromium.base.ContextUtils;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
|
|
| import java.util.Date;
|
| import java.util.concurrent.TimeUnit;
|
| @@ -22,13 +27,13 @@ import java.util.concurrent.TimeUnit;
|
| /**
|
| * Tests for the {@link HistoryAdapter}.
|
| */
|
| -public class HistoryAdapterTest extends InstrumentationTestCase {
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| +public class HistoryAdapterTest {
|
| private StubbedHistoryProvider mHistoryProvider;
|
| private HistoryAdapter mAdapter;
|
|
|
| - @Override
|
| + @Before
|
| public void setUp() throws Exception {
|
| - super.setUp();
|
| mHistoryProvider = new StubbedHistoryProvider();
|
| mAdapter = new HistoryAdapter(new SelectionDelegate<HistoryItem>(), null, mHistoryProvider);
|
| }
|
| @@ -42,12 +47,14 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
| });
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testInitialize_Empty() {
|
| initializeAdapter();
|
| checkAdapterContents(false);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testInitialize_SingleItem() {
|
| Date today = new Date();
|
| @@ -61,6 +68,7 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
| checkAdapterContents(true, null, null, item1);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testRemove_TwoItemsOneDate() {
|
| Date today = new Date();
|
| @@ -80,20 +88,21 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
|
|
| // Check that one item was removed.
|
| checkAdapterContents(true, null, null, item2);
|
| - assertEquals(1, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| - assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(1, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| + Assert.assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
|
|
| mAdapter.markItemForRemoval(item2);
|
|
|
| // There should no longer be any items in the adapter.
|
| checkAdapterContents(false);
|
| - assertEquals(2, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| - assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(2, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| + Assert.assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
|
|
| mAdapter.removeItems();
|
| - assertEquals(1, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(1, mHistoryProvider.removeItemsCallback.getCallCount());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testRemove_TwoItemsTwoDates() {
|
| Date today = new Date();
|
| @@ -115,20 +124,21 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
|
|
| // Check that the first item and date header were removed.
|
| checkAdapterContents(true, null, null, item2);
|
| - assertEquals(1, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| - assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(1, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| + Assert.assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
|
|
| mAdapter.markItemForRemoval(item2);
|
|
|
| // There should no longer be any items in the adapter.
|
| checkAdapterContents(false);
|
| - assertEquals(2, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| - assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(2, mHistoryProvider.markItemForRemovalCallback.getCallCount());
|
| + Assert.assertEquals(0, mHistoryProvider.removeItemsCallback.getCallCount());
|
|
|
| mAdapter.removeItems();
|
| - assertEquals(1, mHistoryProvider.removeItemsCallback.getCallCount());
|
| + Assert.assertEquals(1, mHistoryProvider.removeItemsCallback.getCallCount());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testSearch() {
|
| Date today = new Date();
|
| @@ -154,6 +164,7 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
| checkAdapterContents(true, null, null, item1, null, item2);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testLoadMoreItems() {
|
| Date today = new Date();
|
| @@ -185,16 +196,17 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
|
|
| // Only the first five of the seven items should be loaded.
|
| checkAdapterContents(true, null, null, item1, item2, item3, item4, null, item5);
|
| - assertTrue(mAdapter.canLoadMoreItems());
|
| + Assert.assertTrue(mAdapter.canLoadMoreItems());
|
|
|
| mAdapter.loadMoreItems();
|
|
|
| // All items should now be loaded.
|
| checkAdapterContents(true, null, null, item1, item2, item3, item4, null, item5, item6,
|
| null, item7);
|
| - assertFalse(mAdapter.canLoadMoreItems());
|
| + Assert.assertFalse(mAdapter.canLoadMoreItems());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testOnHistoryDeleted() throws Exception {
|
| Date today = new Date();
|
| @@ -218,6 +230,7 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
| checkAdapterContents(false);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| public void testBlockedSite() {
|
| Date today = new Date();
|
| @@ -231,27 +244,28 @@ public class HistoryAdapterTest extends InstrumentationTestCase {
|
| initializeAdapter();
|
|
|
| checkAdapterContents(true, null, null, item1, item2);
|
| - assertEquals(ContextUtils.getApplicationContext().getString(
|
| - R.string.android_history_blocked_site), item2.getTitle());
|
| - assertTrue(item2.wasBlockedVisit());
|
| + Assert.assertEquals(ContextUtils.getApplicationContext().getString(
|
| + R.string.android_history_blocked_site),
|
| + item2.getTitle());
|
| + Assert.assertTrue(item2.wasBlockedVisit());
|
| }
|
|
|
| private void checkAdapterContents(boolean hasHeader, Object... expectedItems) {
|
| - assertEquals(expectedItems.length, mAdapter.getItemCount());
|
| - assertEquals(hasHeader, mAdapter.hasListHeader());
|
| + Assert.assertEquals(expectedItems.length, mAdapter.getItemCount());
|
| + Assert.assertEquals(hasHeader, mAdapter.hasListHeader());
|
|
|
| for (int i = 0; i < expectedItems.length; i++) {
|
| if (i == 0 && hasHeader) {
|
| - assertEquals(TYPE_HEADER, mAdapter.getItemViewType(i));
|
| + Assert.assertEquals(TYPE_HEADER, mAdapter.getItemViewType(i));
|
| continue;
|
| }
|
|
|
| if (expectedItems[i] == null) {
|
| // TODO(twellington): Check what date header is showing.
|
| - assertEquals(TYPE_DATE, mAdapter.getItemViewType(i));
|
| + Assert.assertEquals(TYPE_DATE, mAdapter.getItemViewType(i));
|
| } else {
|
| - assertEquals(TYPE_NORMAL, mAdapter.getItemViewType(i));
|
| - assertEquals(expectedItems[i], mAdapter.getItemAt(i).second);
|
| + Assert.assertEquals(TYPE_NORMAL, mAdapter.getItemViewType(i));
|
| + Assert.assertEquals(expectedItems[i], mAdapter.getItemAt(i).second);
|
| }
|
| }
|
| }
|
|
|