diff options
author | Xin Li <delphij@google.com> | 2019-07-01 20:59:51 +0000 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2019-07-01 20:59:51 +0000 |
commit | aa06a98b9387bf7cda7948de3f3949e82c151856 (patch) | |
tree | d4d0f1ccfa3d6b82ef0a0be0a353328a3001714d /library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java | |
parent | f26a9e8e2e422b20c721e199961f11bc82dd250a (diff) | |
parent | 93dacd74efc365bc889773a7cca03adad1ded25d (diff) | |
download | setupwizard-aa06a98b9387bf7cda7948de3f3949e82c151856.tar.gz |
DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-mastertemp_140451723
Bug: 134405016
Change-Id: I5e74b54945db4e896b45312ec51d2a4facc01c55
Diffstat (limited to 'library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java')
-rw-r--r-- | library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java b/library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java index 429445c..b07e2a3 100644 --- a/library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java +++ b/library/test/robotest/src/com/android/setupwizardlib/template/ScrollViewScrollHandlingDelegateTest.java @@ -16,72 +16,65 @@ package com.android.setupwizardlib.template; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.spy; +import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.verify; import static org.robolectric.RuntimeEnvironment.application; -import com.android.setupwizardlib.robolectric.SuwLibRobolectricTestRunner; +import android.view.View; import com.android.setupwizardlib.view.BottomScrollView; -import com.android.setupwizardlib.view.BottomScrollView.BottomScrollListener; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -@Config(sdk = { Config.OLDEST_SDK, Config.NEWEST_SDK }) -@RunWith(SuwLibRobolectricTestRunner.class) +@Config(sdk = {Config.OLDEST_SDK, Config.NEWEST_SDK}) +@RunWith(RobolectricTestRunner.class) public class ScrollViewScrollHandlingDelegateTest { - @Mock - private RequireScrollMixin mRequireScrollMixin; - - private BottomScrollView mScrollView; - private ScrollViewScrollHandlingDelegate mDelegate; - private ArgumentCaptor<BottomScrollListener> mListenerCaptor; + @Mock private RequireScrollMixin requireScrollMixin; - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); + private BottomScrollView scrollView; + private ScrollViewScrollHandlingDelegate delegate; - mScrollView = spy(new BottomScrollView(application)); - mDelegate = new ScrollViewScrollHandlingDelegate(mRequireScrollMixin, mScrollView); + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); - mListenerCaptor = ArgumentCaptor.forClass(BottomScrollListener.class); - doNothing().when(mScrollView).setBottomScrollListener(mListenerCaptor.capture()); + scrollView = new BottomScrollView(application); + View childView = new View(application); + scrollView.addView(childView); + delegate = new ScrollViewScrollHandlingDelegate(requireScrollMixin, scrollView); - mScrollView.layout(0, 0, 50, 50); - } + scrollView.layout(0, 0, 500, 500); + childView.layout(0, 0, 1000, 1000); + } - @Test - public void testRequireScroll() throws Throwable { - mDelegate.startListening(); + @Test + public void testRequireScroll() throws Throwable { + delegate.startListening(); - mListenerCaptor.getValue().onRequiresScroll(); - verify(mRequireScrollMixin).notifyScrollabilityChange(true); - } + scrollView.getBottomScrollListener().onRequiresScroll(); + verify(requireScrollMixin).notifyScrollabilityChange(true); + } - @Test - public void testScrolledToBottom() throws Throwable { - mDelegate.startListening(); + @Test + public void testScrolledToBottom() throws Throwable { + delegate.startListening(); - mListenerCaptor.getValue().onRequiresScroll(); - verify(mRequireScrollMixin).notifyScrollabilityChange(true); + scrollView.getBottomScrollListener().onRequiresScroll(); + verify(requireScrollMixin).notifyScrollabilityChange(true); - mListenerCaptor.getValue().onScrolledToBottom(); + scrollView.getBottomScrollListener().onScrolledToBottom(); - verify(mRequireScrollMixin).notifyScrollabilityChange(false); - } + verify(requireScrollMixin).notifyScrollabilityChange(false); + } - @Test - public void testPageScrollDown() throws Throwable { - mDelegate.pageScrollDown(); - verify(mScrollView).smoothScrollBy(anyInt(), eq(50)); - } + @Test + public void testPageScrollDown() throws Throwable { + delegate.pageScrollDown(); + assertThat(scrollView.getScrollY()).isEqualTo(500); + } } |