1 package org.robolectric.shadows;
2 
3 import static org.junit.Assert.assertEquals;
4 
5 import android.widget.ScrollView;
6 import androidx.test.core.app.ApplicationProvider;
7 import androidx.test.ext.junit.runners.AndroidJUnit4;
8 import org.junit.Test;
9 import org.junit.runner.RunWith;
10 
11 @RunWith(AndroidJUnit4.class)
12 public class ShadowScrollViewTest {
13   @Test
shouldSmoothScrollTo()14   public void shouldSmoothScrollTo() throws Exception {
15     ScrollView scrollView = new ScrollView(ApplicationProvider.getApplicationContext());
16     scrollView.smoothScrollTo(7, 6);
17 
18     assertEquals(7, scrollView.getScrollX());
19     assertEquals(6, scrollView.getScrollY());
20   }
21 
22   @Test
shouldSmoothScrollBy()23   public void shouldSmoothScrollBy() throws Exception {
24     ScrollView scrollView = new ScrollView(ApplicationProvider.getApplicationContext());
25     scrollView.smoothScrollTo(7, 6);
26     scrollView.smoothScrollBy(10, 20);
27 
28     assertEquals(17, scrollView.getScrollX());
29     assertEquals(26, scrollView.getScrollY());
30   }
31 }
32