2016-10-26 7 views
0

私のビューを上下にスワイプするカスタムメソッドを作成したいとします。 私はこのような方法で上書きしようとした:私のビューを上下にスワイプするカスタムメソッドを作成する方法、Espresso - ViewActions

public static ViewAction swipeDown(){ 
    return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER, 
      GeneralLocation.TOP_CENTER, Press.FINGER); 
} 

をしかし、それは上から中央にだけだと私は短いものを必要としています。私は新しいCoordinatesProvider()を使用したい:

public static ViewAction swipeDown(){ 
    return new GeneralSwipeAction(Swipe.FAST, new CoordinatesProvider() { 
     @Override 
     public float[] calculateCoordinates(View view) { 
      return new float[0]; 
     } 
    }, 
      GeneralLocation.TOP_CENTER, Press.FINGER); 
} 

を...、それが答えかもしれませんが、私は本当に座標を計算する方法がわかりません。

答えて

0

Robotiumはすでにswipe[Direction]の機能とよく似ていますが、すでに定義されている座標を使用していますが、すでにdrag()の機能があります。

* @param fromX X coordinate of the initial touch, in screen coordinates * @param toX X coordinate of the drag destination, in screen coordinates * @param fromY Y 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. Less steps results in a faster drag

チェックhttps://github.com/RobotiumTech/robotium/blob/b69dcf740baabec48c91999e523377faef79682e/robotium-solo/src/main/java/com/robotium/solo/Solo.java

あなたが一緒に両方のフレームワークを使用するか、独自の方法でRobotiumdrag機能を書き換えることを試みることができます。

関連する問題