package com.github.kubode.wiggle;

import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.github.kubode.wiggle.test.R;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.scrollTo;
import static android.support.test.espresso.action.ViewActions.swipeDown;
import static android.support.test.espresso.action.ViewActions.swipeUp;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.github.kubode.wiggle.MyMatchers.withLastNon0TranslationY;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.not;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class WiggleHelperTest {

    @Rule
    public ActivityTestRule<MockActivity> rule = new ActivityTestRule<>(MockActivity.class);

    @Before
    public void setUp() {
        onView(withId(R.id.view)).perform(scrollTo());
    }

    @Test
    public void lastNon0TranslationYGreaterThan0WhenSwipeUp() {
        onView(withId(R.id.scrollView))
                .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
                .perform(swipeUp());
        onView(withId(R.id.view)).check(matches(withLastNon0TranslationY(greaterThan(0f))));
    }

    @Test
    public void lastNon0TranslationYLessThan0WhenSwipeDown() {
        onView(withId(R.id.scrollView))
                .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
                .perform(swipeDown());
        onView(withId(R.id.view)).check(matches(withLastNon0TranslationY(lessThan(0f))));
    }
}

@@ -32,55 +32,8 @@
 e;%0A%0A
-import android.support.test.filters.LargeTest;%0A
 impo
@@ -128,16 +128,51 @@
 dJUnit4;
+%0Aimport android.view.WindowManager;
 %0A%0Aimport
@@ -673,88 +673,8 @@
 es;%0A
-import static android.support.test.espresso.matcher.RootMatchers.withDecorView;%0A
 impo
@@ -871,48 +871,8 @@
 an;%0A
-import static org.hamcrest.Matchers.is;%0A
 impo
@@ -916,49 +916,8 @@
 han;
-%0Aimport static org.hamcrest.Matchers.not;
 %0A%0A@R
@@ -948,19 +948,8 @@
 ss)%0A
-@LargeTest%0A
 publ
@@ -1115,24 +1115,434 @@
 d setUp() %7B%0A
+        rule.getActivity().runOnUiThread(new Runnable() %7B%0A            public void run() %7B%0A                rule.getActivity().getWindow().addFlags(%0A                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON%0A                                %7C WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED%0A                                %7C WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);%0A            %7D%0A        %7D);%0A
         onVi
@@ -1708,120 +1708,8 @@
 ew))
-%0A                .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))%0A                
 .per
@@ -1941,120 +1941,8 @@
 ew))
-%0A                .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))%0A                
 .per

Fix build. http://circleci.com/docs/1.0/android/