54 lines
1.5 KiB
Java
54 lines
1.5 KiB
Java
package org.sufficientlysecure.keychain.actions;
|
|
|
|
|
|
import android.support.test.espresso.UiController;
|
|
import android.support.test.espresso.ViewAction;
|
|
import android.support.test.espresso.matcher.ViewMatchers;
|
|
import android.support.v4.view.GravityCompat;
|
|
import android.support.v4.widget.DrawerLayout;
|
|
import android.view.View;
|
|
|
|
import org.hamcrest.Matcher;
|
|
|
|
|
|
public abstract class CustomActions {
|
|
|
|
public static ViewAction actionOpenDrawer() {
|
|
return new ViewAction() {
|
|
@Override
|
|
public Matcher<View> getConstraints() {
|
|
return ViewMatchers.isAssignableFrom(DrawerLayout.class);
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return "open drawer";
|
|
}
|
|
|
|
@Override
|
|
public void perform(UiController uiController, View view) {
|
|
((DrawerLayout) view).openDrawer(GravityCompat.START);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static ViewAction actionCloseDrawer() {
|
|
return new ViewAction() {
|
|
@Override
|
|
public Matcher<View> getConstraints() {
|
|
return ViewMatchers.isAssignableFrom(DrawerLayout.class);
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return "close drawer";
|
|
}
|
|
|
|
@Override
|
|
public void perform(UiController uiController, View view) {
|
|
((DrawerLayout) view).closeDrawer(GravityCompat.START);
|
|
}
|
|
};
|
|
}
|
|
|
|
} |