当前位置: 首页>>代码示例>>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;未经允许,请勿转载。