Java 类com.facebook.react.testing.SingleTouchGestureGenerator 实例源码

项目:RNLearn_Project1    文件:JSResponderTestCase.java   
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
项目:RNLearn_Project1    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * 1) Start touch at view A, then drag and release on view {B} (but outside of A), expect {B}'s
 * touch handler to fire
 * 2) Do the same with view C and {D}
 */
public void testDownOnInnerUpOnTouchableParent() {
  View innerButton = getViewByTestId("A");
  View touchableParent = getViewByTestId("B");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("inner", mRecordingModule.getCalls().get(0));

  // Do same with second inner view
  mRecordingModule.reset();

  touchableParent = getViewByTestId("D");
  innerButton = getViewByTestId("C");

  gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("outer", mRecordingModule.getCalls().get(0));
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * Start gesture at view A, then drag and release on view {E}. Expect no touch handlers to fire
 */
public void testDragOutOfTouchable() {
  View outsideView = getViewByTestId("E");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(outsideView, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * In this scenario we start gesture at view A (has two touchable parents {B} and {D}) then we
 * drag and release gesture on view {D}, but outside of {B}. We expect no touch handler to fire
 */
public void testNoEventWhenDragOutOfFirstTouchableParentToItsTouchableParent() {
  View topLevelTouchable = getViewByTestId("C");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(topLevelTouchable, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:RNLearn_Project1    文件:JSResponderTestCase.java   
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
项目:RNLearn_Project1    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * 1) Start touch at view A, then drag and release on view {B} (but outside of A), expect {B}'s
 * touch handler to fire
 * 2) Do the same with view C and {D}
 */
public void testDownOnInnerUpOnTouchableParent() {
  View innerButton = getViewByTestId("A");
  View touchableParent = getViewByTestId("B");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("inner", mRecordingModule.getCalls().get(0));

  // Do same with second inner view
  mRecordingModule.reset();

  touchableParent = getViewByTestId("D");
  innerButton = getViewByTestId("C");

  gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("outer", mRecordingModule.getCalls().get(0));
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * Start gesture at view A, then drag and release on view {E}. Expect no touch handlers to fire
 */
public void testDragOutOfTouchable() {
  View outsideView = getViewByTestId("E");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(outsideView, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:RNLearn_Project1    文件:CatalystTouchBubblingTestCase.java   
/**
 * In this scenario we start gesture at view A (has two touchable parents {B} and {D}) then we
 * drag and release gesture on view {D}, but outside of {B}. We expect no touch handler to fire
 */
public void testNoEventWhenDragOutOfFirstTouchableParentToItsTouchableParent() {
  View topLevelTouchable = getViewByTestId("C");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(topLevelTouchable, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:ReactNativeSignatureExample    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:ReactNativeSignatureExample    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:react-native-ibeacon-android    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:react-native-ibeacon-android    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:react-native-box-loaders    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:react-native-box-loaders    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:Ironman    文件:JSResponderTestCase.java   
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
项目:Ironman    文件:ReactScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragUp(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[1] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
项目:Ironman    文件:CatalystTouchBubblingTestCase.java   
/**
 * 1) Start touch at view A, then drag and release on view {B} (but outside of A), expect {B}'s
 * touch handler to fire
 * 2) Do the same with view C and {D}
 */
public void testDownOnInnerUpOnTouchableParent() {
  View innerButton = getViewByTestId("A");
  View touchableParent = getViewByTestId("B");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("inner", mRecordingModule.getCalls().get(0));

  // Do same with second inner view
  mRecordingModule.reset();

  touchableParent = getViewByTestId("D");
  innerButton = getViewByTestId("C");

  gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(touchableParent, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertEquals(1, mRecordingModule.getCalls().size());
  assertEquals("outer", mRecordingModule.getCalls().get(0));
}
项目:Ironman    文件:CatalystTouchBubblingTestCase.java   
/**
 * Start gesture at view A, then drag and release on view {E}. Expect no touch handlers to fire
 */
public void testDragOutOfTouchable() {
  View outsideView = getViewByTestId("E");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(outsideView, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:Ironman    文件:CatalystTouchBubblingTestCase.java   
/**
 * In this scenario we start gesture at view A (has two touchable parents {B} and {D}) then we
 * drag and release gesture on view {D}, but outside of {B}. We expect no touch handler to fire
 */
public void testNoEventWhenDragOutOfFirstTouchableParentToItsTouchableParent() {
  View topLevelTouchable = getViewByTestId("C");
  View innerButton = getViewByTestId("A");

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();
  gestureGenerator.startGesture(innerButton);
  // wait for tapped view measurements
  waitForBridgeAndUIIdle();

  gestureGenerator.dragTo(topLevelTouchable, 15).endGesture();
  waitForBridgeAndUIIdle();
  assertTrue(mRecordingModule.getCalls().isEmpty());
}
项目:Ironman    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollAndClick() throws Exception {
  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  // Slowly drag the ScrollView to prevent fling
  dragLeft(15000);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Find visible item to be clicked
  View visibleItem = null;
  int visibleItemNumber = 0;
  for (; visibleItemNumber < 100; visibleItemNumber++) {
    visibleItem = getViewAtPath(0, 0, visibleItemNumber);
    int pos[] = new int[2];
    visibleItem.getLocationInWindow(pos);
    if (pos[0] >= 0) {
      break;
    }
  }

  // Click first visible item
  gestureGenerator.startGesture(visibleItem).endGesture();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  ArrayList<Integer> itemIds = mScrollListenerModule.getItemsPressed();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertEquals("Expected to receive exactly one item click event", 1, itemIds.size());
  assertEquals(visibleItemNumber, (int) itemIds.get(0));
}