當前位置: 首頁>>代碼示例>>Java>>正文


Java LongSparseArray.valueAt方法代碼示例

本文整理匯總了Java中android.util.LongSparseArray.valueAt方法的典型用法代碼示例。如果您正苦於以下問題:Java LongSparseArray.valueAt方法的具體用法?Java LongSparseArray.valueAt怎麽用?Java LongSparseArray.valueAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.util.LongSparseArray的用法示例。


在下文中一共展示了LongSparseArray.valueAt方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyValidInputEventsChainIsCompiledForSingleKeysGesture

import android.util.LongSparseArray; //導入方法依賴的package包/類
@Test
public void verifyValidInputEventsChainIsCompiledForSingleKeysGesture() throws JSONException {
    final JSONArray actionJson = new JSONArray("[ {" +
            "\"type\": \"key\"," +
            "\"id\": \"keyboard\"," +
            "\"actions\": [" +
            "{\"type\": \"keyDown\", \"value\": \"\u2000\"}," +
            "{\"type\": \"keyDown\", \"value\": \"A\"}," +
            "{\"type\": \"keyUp\", \"value\": \"A\"}," +
            "{\"type\": \"keyUp\", \"value\": \"\u2000\"}]" +
            "} ]");
    final LongSparseArray<List<InputEventParams>> eventsChain = actionsToInputEventsMapping(
            preprocessActions(actionJson)
    );
    assertThat(eventsChain.size(), equalTo(1));
    final List<InputEventParams> generatedParams = eventsChain.valueAt(0);
    assertThat(generatedParams.size(), equalTo(4));

    for (final InputEventParams params : generatedParams) {
        assertThat(params.startDelta, equalTo(0L));
        assertThat(params, is(instanceOf(KeyInputEventParams.class)));
    }

    assertThat(((KeyInputEventParams) generatedParams.get(0)).keyAction,
            equalTo(KeyEvent.ACTION_DOWN));
    assertThat(((KeyInputEventParams) generatedParams.get(0)).keyCode, equalTo(0x2000));

    assertThat(((KeyInputEventParams) generatedParams.get(1)).keyAction,
            equalTo(KeyEvent.ACTION_DOWN));
    assertThat(((KeyInputEventParams) generatedParams.get(1)).keyCode, equalTo(65));

    assertThat(((KeyInputEventParams) generatedParams.get(2)).keyAction,
            equalTo(KeyEvent.ACTION_UP));
    assertThat(((KeyInputEventParams) generatedParams.get(2)).keyCode, equalTo(65));

    assertThat(((KeyInputEventParams) generatedParams.get(3)).keyAction,
            equalTo(KeyEvent.ACTION_UP));
    assertThat(((KeyInputEventParams) generatedParams.get(3)).keyCode, equalTo(0x2000));
}
 
開發者ID:appium,項目名稱:appium-uiautomator2-server,代碼行數:40,代碼來源:W3CActionsTransformationTests.java

示例2: verifyValidInputEventsChainIsCompiledForSingleKeysGestureWithPause

import android.util.LongSparseArray; //導入方法依賴的package包/類
@Test
public void verifyValidInputEventsChainIsCompiledForSingleKeysGestureWithPause() throws JSONException {
    final JSONArray actionJson = new JSONArray("[ {" +
            "\"type\": \"key\"," +
            "\"id\": \"keyboard\"," +
            "\"actions\": [" +
            "{\"type\": \"keyDown\", \"value\": \"A\"}," +
            "{\"type\": \"pause\", \"duration\": 500}," +
            "{\"type\": \"keyUp\", \"value\": \"A\"}]" +
            "} ]");
    final LongSparseArray<List<InputEventParams>> eventsChain = actionsToInputEventsMapping(
            preprocessActions(actionJson)
    );
    assertThat(eventsChain.size(), equalTo(2));

    final List<InputEventParams> paramSet1 = eventsChain.valueAt(0);
    assertThat(paramSet1.size(), equalTo(1));
    final KeyInputEventParams downParams = (KeyInputEventParams) paramSet1.get(0);
    assertThat(downParams.startDelta, equalTo(0L));
    assertThat(downParams.keyAction, equalTo(KeyEvent.ACTION_DOWN));
    assertThat(downParams.keyCode, equalTo(65));


    assertThat(eventsChain.keyAt(1), equalTo(500L));
    final List<InputEventParams> paramSet2 = eventsChain.valueAt(1);
    assertThat(paramSet2.size(), equalTo(1));
    final KeyInputEventParams upParams = (KeyInputEventParams) paramSet2.get(0);
    assertThat(upParams.startDelta, equalTo(0L));
    assertThat(upParams.keyAction, equalTo(KeyEvent.ACTION_UP));
    assertThat(upParams.keyCode, equalTo(65));
}
 
開發者ID:appium,項目名稱:appium-uiautomator2-server,代碼行數:32,代碼來源:W3CActionsTransformationTests.java

示例3: iterate

import android.util.LongSparseArray; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
public static <T> Iterable<T> iterate(final LongSparseArray<T> array) {
	return new Iterable<T>() { @Override public Iterator<T> iterator() {
		return new Iterator<T>() {
			@Override public boolean hasNext() { return i < array.size(); }
			@Override public T next() { return array.valueAt(i ++); }
			int i = 0;
		};
	}};
}
 
開發者ID:oasisfeng,項目名稱:deagle,代碼行數:11,代碼來源:SparseArrays.java

示例4: verifyValidInputEventsChainIsCompiledForSingleFingerGesture

import android.util.LongSparseArray; //導入方法依賴的package包/類
@Test
public void verifyValidInputEventsChainIsCompiledForSingleFingerGesture() throws JSONException {
    final JSONArray actionJson = new JSONArray("[ {" +
            "\"type\": \"pointer\"," +
            "\"id\": \"finger1\"," +
            "\"parameters\": {\"pointerType\": \"touch\"}," +
            "\"actions\": [" +
            "{\"type\": \"pointerMove\", \"duration\": 0, \"x\": 100, \"y\": 100}," +
            "{\"type\": \"pointerDown\"}," +
            "{\"type\": \"pause\", \"duration\": 10}," +
            "{\"type\": \"pointerMove\", \"duration\": 10, \"origin\": \"pointer\", \"x\": -50, \"y\": 0}," +
            "{\"type\": \"pointerUp\"}]" +
            "} ]");
    final LongSparseArray<List<InputEventParams>> eventsChain = actionsToInputEventsMapping(
            preprocessActions(actionJson)
    );
    assertThat(eventsChain.size(), equalTo(4));

    final List<InputEventParams> paramSet1 = eventsChain.valueAt(0);
    assertThat(eventsChain.keyAt(0), equalTo(0L));
    assertThat(paramSet1.size(), equalTo(1));

    final MotionInputEventParams downParams = (MotionInputEventParams) paramSet1.get(0);
    assertThat(downParams.startDelta, equalTo(0L));
    assertThat(downParams.actionCode, equalTo(MotionEvent.ACTION_DOWN));
    assertThat(downParams.button, equalTo(0));
    assertEquals(downParams.coordinates.x, 100.0, Math.ulp(1.0));
    assertEquals(downParams.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(downParams.properties.id, is(equalTo(0)));
    assertThat(downParams.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_FINGER));

    final List<InputEventParams> paramSet2 = eventsChain.valueAt(1);
    assertThat(eventsChain.keyAt(1), equalTo(10L));
    assertThat(paramSet2.size(), equalTo(1));

    final MotionInputEventParams move1Params = (MotionInputEventParams) paramSet2.get(0);
    assertThat(move1Params.startDelta, equalTo(0L));
    assertThat(move1Params.actionCode, equalTo(MotionEvent.ACTION_MOVE));
    assertThat(move1Params.button, equalTo(0));
    assertEquals(move1Params.coordinates.x, 100.0, Math.ulp(1.0));
    assertEquals(move1Params.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(move1Params.properties.id, is(equalTo(0)));
    assertThat(move1Params.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_FINGER));

    final List<InputEventParams> paramSet3 = eventsChain.valueAt(2);
    assertThat(eventsChain.keyAt(2), equalTo(15L));
    assertThat(paramSet3.size(), equalTo(1));

    final MotionInputEventParams move2Params = (MotionInputEventParams) paramSet3.get(0);
    assertThat(move2Params.startDelta, equalTo(0L));
    assertThat(move2Params.actionCode, equalTo(MotionEvent.ACTION_MOVE));
    assertThat(move2Params.button, equalTo(0));
    assertEquals(move2Params.coordinates.x, 75.0, Math.ulp(1.0));
    assertEquals(move2Params.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(move2Params.properties.id, is(equalTo(0)));
    assertThat(move2Params.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_FINGER));

    final List<InputEventParams> paramSet4 = eventsChain.valueAt(3);
    assertThat(eventsChain.keyAt(3), equalTo(20L));
    assertThat(paramSet4.size(), equalTo(1));

    final MotionInputEventParams upParams = (MotionInputEventParams) paramSet4.get(0);
    assertThat(upParams.startDelta, equalTo(0L));
    assertThat(upParams.actionCode, equalTo(MotionEvent.ACTION_UP));
    assertThat(upParams.button, equalTo(0));
    assertEquals(upParams.coordinates.x, 50.0, Math.ulp(1.0));
    assertEquals(upParams.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(upParams.properties.id, is(equalTo(0)));
    assertThat(upParams.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_FINGER));
}
 
開發者ID:appium,項目名稱:appium-uiautomator2-server,代碼行數:71,代碼來源:W3CActionsTransformationTests.java

示例5: verifyValidInputEventsChainIsCompiledForMouseGestureWithHoverGesture

import android.util.LongSparseArray; //導入方法依賴的package包/類
@Test
public void verifyValidInputEventsChainIsCompiledForMouseGestureWithHoverGesture()
        throws JSONException {
    final JSONArray actionJson = new JSONArray("[ {" +
            "\"type\": \"pointer\"," +
            "\"id\": \"mouse1\"," +
            "\"actions\": [" +
            "{\"type\": \"pointerMove\", \"duration\": 0, \"x\": 100, \"y\": 100}," +
            "{\"type\": \"pointerMove\", \"duration\": 10, \"x\": 0, \"y\": 0}]" +
            "} ]");
    final LongSparseArray<List<InputEventParams>> eventsChain = actionsToInputEventsMapping(
            preprocessActions(actionJson)
    );
    assertThat(eventsChain.size(), equalTo(3));

    final List<InputEventParams> paramSet1 = eventsChain.valueAt(0);
    assertThat(eventsChain.keyAt(0), equalTo(0L));
    assertThat(paramSet1.size(), equalTo(2));

    final MotionInputEventParams enterParams = (MotionInputEventParams) paramSet1.get(0);
    assertThat(enterParams.startDelta, equalTo(0L));
    assertThat(enterParams.actionCode, equalTo(MotionEvent.ACTION_HOVER_ENTER));
    assertThat(enterParams.button, equalTo(0));
    assertEquals(enterParams.coordinates.x, 100.0, Math.ulp(1.0));
    assertEquals(enterParams.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(enterParams.properties.id, is(equalTo(0)));
    assertThat(enterParams.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_MOUSE));

    final MotionInputEventParams move1Params = (MotionInputEventParams) paramSet1.get(1);
    assertThat(move1Params.startDelta, equalTo(0L));
    assertThat(move1Params.actionCode, equalTo(MotionEvent.ACTION_HOVER_MOVE));
    assertThat(move1Params.button, equalTo(0));
    assertEquals(move1Params.coordinates.x, 100.0, Math.ulp(1.0));
    assertEquals(move1Params.coordinates.y, 100.0, Math.ulp(1.0));
    assertThat(move1Params.properties.id, is(equalTo(0)));
    assertThat(move1Params.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_MOUSE));

    final List<InputEventParams> paramSet2 = eventsChain.valueAt(1);
    assertThat(eventsChain.keyAt(1), equalTo(5L));
    assertThat(paramSet2.size(), equalTo(1));

    final MotionInputEventParams move2Params = (MotionInputEventParams) paramSet2.get(0);
    assertThat(move2Params.startDelta, equalTo(0L));
    assertThat(move2Params.actionCode, equalTo(MotionEvent.ACTION_HOVER_MOVE));
    assertThat(move2Params.button, equalTo(0));
    assertEquals(move2Params.coordinates.x, 50.0, Math.ulp(1.0));
    assertEquals(move2Params.coordinates.y, 50.0, Math.ulp(1.0));
    assertThat(move2Params.properties.id, is(equalTo(0)));
    assertThat(move2Params.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_MOUSE));

    final List<InputEventParams> paramSet3 = eventsChain.valueAt(2);
    assertThat(eventsChain.keyAt(2), equalTo(10L));
    assertThat(paramSet3.size(), equalTo(1));

    final MotionInputEventParams exitParams = (MotionInputEventParams) paramSet3.get(0);
    assertThat(exitParams.startDelta, equalTo(0L));
    assertThat(exitParams.actionCode, equalTo(MotionEvent.ACTION_HOVER_EXIT));
    assertThat(exitParams.button, equalTo(0));
    assertEquals(exitParams.coordinates.x, 0.0, Math.ulp(1.0));
    assertEquals(exitParams.coordinates.y, 0.0, Math.ulp(1.0));
    assertThat(exitParams.properties.id, is(equalTo(0)));
    assertThat(exitParams.properties.toolType, equalTo(MotionEvent.TOOL_TYPE_MOUSE));
}
 
開發者ID:appium,項目名稱:appium-uiautomator2-server,代碼行數:64,代碼來源:W3CActionsTransformationTests.java


注:本文中的android.util.LongSparseArray.valueAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。