use of android.app.Instrumentation in project android_frameworks_base by ParanoidAndroid.
the class ListManagedCursorTest method testKeyScrolling.
/**
* Scroll the list using arrows, launch new activity, hit back, make sure we're still scrolled.
*/
@LargeTest
public void testKeyScrolling() {
Instrumentation inst = getInstrumentation();
int firstVisiblePosition = arrowScroll(inst);
inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
inst.waitForIdleSync();
assertTrue("List changed to touch mode", !mListView.isInTouchMode());
assertTrue("List did not preserve scroll position", firstVisiblePosition == mListView.getFirstVisiblePosition());
}
use of android.app.Instrumentation in project android_frameworks_base by ParanoidAndroid.
the class ListScrollListenerTest method testKeyScrolling.
@LargeTest
public void testKeyScrolling() {
Instrumentation inst = getInstrumentation();
int firstVisibleItem = mFirstVisibleItem;
for (int i = 0; i < mVisibleItemCount * 2; i++) {
inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
}
inst.waitForIdleSync();
assertTrue("Arrow scroll did not happen", mFirstVisibleItem > firstVisibleItem);
firstVisibleItem = mFirstVisibleItem;
inst.sendCharacterSync(KeyEvent.KEYCODE_SPACE);
inst.waitForIdleSync();
assertTrue("Page scroll did not happen", mFirstVisibleItem > firstVisibleItem);
firstVisibleItem = mFirstVisibleItem;
KeyEvent down = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
KeyEvent up = new KeyEvent(0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_DOWN, 0, KeyEvent.META_ALT_ON);
inst.sendKeySync(down);
inst.sendKeySync(up);
inst.waitForIdleSync();
assertTrue("Full scroll did not happen", mFirstVisibleItem > firstVisibleItem);
assertEquals("Full scroll did not happen", mTotalItemCount, mFirstVisibleItem + mVisibleItemCount);
}
use of android.app.Instrumentation in project android_frameworks_base by ParanoidAndroid.
the class ListViewHeightTest method testButtons.
@MediumTest
public void testButtons() {
Instrumentation inst = getInstrumentation();
final Button button1 = (Button) mActivity.findViewById(R.id.button1);
final Button button2 = (Button) mActivity.findViewById(R.id.button2);
final Button button3 = (Button) mActivity.findViewById(R.id.button3);
ListView list = (ListView) mActivity.findViewById(R.id.inner_list);
assertEquals("Unexpected items in adapter", 0, list.getCount());
assertEquals("Unexpected children in list view", 0, list.getChildCount());
mActivity.runOnUiThread(new Runnable() {
public void run() {
button1.performClick();
}
});
inst.waitForIdleSync();
assertTrue("List not be visible after clicking button1", list.isShown());
assertTrue("List incorrect height", list.getHeight() == 200);
mActivity.runOnUiThread(new Runnable() {
public void run() {
button2.performClick();
}
});
inst.waitForIdleSync();
assertTrue("List not be visible after clicking button2", list.isShown());
mActivity.runOnUiThread(new Runnable() {
public void run() {
button3.performClick();
}
});
inst.waitForIdleSync();
assertFalse("List should not be visible clicking button3", list.isShown());
}
use of android.app.Instrumentation in project android_frameworks_base by ParanoidAndroid.
the class EffectsVideoCapture method testBackEffectsVideoCapture.
@LargeTest
public void testBackEffectsVideoCapture() throws Exception {
Instrumentation inst = getInstrumentation();
Intent intent = new Intent();
intent.setClass(getInstrumentation().getTargetContext(), CameraEffectsRecordingSample.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("OUTPUT_FILENAME", Environment.getExternalStorageDirectory().toString() + "/CameraEffectsRecordingTest.mp4");
Activity act = inst.startActivitySync(intent);
captureVideos("Back Camera Video Capture\n", inst);
act.finish();
// Verification
File file = new File(Environment.getExternalStorageDirectory(), "CameraEffectsRecordingTest.mp4");
Uri uri = Uri.fromFile(file);
verify(getActivity(), uri);
}
use of android.app.Instrumentation in project android_frameworks_base by ParanoidAndroid.
the class TouchUtils method drag.
/**
* Simulate touching a specific location and dragging to a new location.
*
* @param test The test case that is being run
* @param fromX X coordinate of the initial touch, in screen coordinates
* @param toX Xcoordinate of the drag destination, in screen coordinates
* @param fromY X coordinate of the initial touch, in screen coordinates
* @param toY Y coordinate of the drag destination, in screen coordinates
* @param stepCount How many move steps to include in the drag
*/
public static void drag(InstrumentationTestCase test, float fromX, float toX, float fromY, float toY, int stepCount) {
Instrumentation inst = test.getInstrumentation();
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
float y = fromY;
float x = fromX;
float yStep = (toY - fromY) / stepCount;
float xStep = (toX - fromX) / stepCount;
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
for (int i = 0; i < stepCount; ++i) {
y += yStep;
x += xStep;
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x, y, 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
}
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
}
Aggregations