import android.support.test.uiautomator.Direction; //导入依赖的package包/类

/**

* Navigates through the focus items in a container returning the container child that has a

* descendant matching the {@code selector}.

*

* The navigation starts in the {@code direction} specified and

* {@link Direction#reverse(Direction) reverses} once if needed. Fails if there is not a

* focused

* descendant, or if after completing both directions no focused child has a descendant

* matching

* {@code selector}.

*

* Fails if the menu item can not be navigated to.

*

* @param uiDevice the device under test.

* @param container contains children to navigate over.

* @param selector the selector for the object to navigate to.

* @param direction the direction to start navigating.

* @return the object navigated to.

*/

public static UiObject2 assertNavigateTo(UiDevice uiDevice, UiObject2 container,

BySelector selector, Direction direction) {

int count = 0;

while (count < 2) {

BySelector hasFocusedDescendant = By.hasDescendant(FOCUSED_VIEW);

UiObject2 focusedChild = null;

SearchCondition untilHasFocusedDescendant = Until

.hasObject(hasFocusedDescendant);

boolean result = container.wait(untilHasFocusedDescendant,

UiObject2Asserts.getAdjustedTimeout(Constants.MAX_SHOW_DELAY_MILLIS));

if (!result) {

// HACK: Try direction anyways because play control does not always have a

// focused item.

UiDeviceUtils.pressDpad(uiDevice, direction);

UiObject2Asserts.assertWaitForCondition(container, untilHasFocusedDescendant);

}

for (UiObject2 c : container.getChildren()) {

if (c.isFocused() || c.hasObject(hasFocusedDescendant)) {

focusedChild = c;

break;

}

}

if (focusedChild == null) {

Assert.fail("No focused item found in container " + container);

}

if (focusedChild.hasObject(selector)) {

return focusedChild;

}

if (!UiObject2Utils.hasSiblingInDirection(focusedChild, direction)) {

direction = Direction.reverse(direction);

count++;

}

UiDeviceUtils.pressDpad(uiDevice, direction);

}

Assert.fail("Could not find item with " + selector);

return null;

}

java direction_Java Direction类代码示例相关推荐

  1. java dataconvert_Java DateConverter类代码示例

    import org.apache.commons.beanutils.converters.DateConverter; //导入依赖的package包/类 /** * Register array ...

  2. java parseexception_Java ParseException类代码示例

    import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException; //导入依赖的package包/类 @Overri ...

  3. java link_Java Link类代码示例

    import org.nodes.Link; //导入依赖的package包/类 public static double sizeBetaCopying(DGraph graph, DGraph s ...

  4. java bar_Java Bar类代码示例

    import com.db.chart.model.Bar; //导入依赖的package包/类 @Override protected void onCreate(Bundle savedInsta ...

  5. java backoff_Java BackOff类代码示例

    import org.apache.beam.sdk.util.BackOff; //导入依赖的package包/类 /** * Writes a batch of mutations to Clou ...

  6. java widget_Java FavoritesWidget类代码示例

    import com.google.gwt.sample.dynatablerf.client.widgets.FavoritesWidget; //导入依赖的package包/类 /** * Thi ...

  7. java plugin_Java Plugin类代码示例

    import org.apache.logging.log4j.core.config.plugins.Plugin; //导入依赖的package包/类 /** * @since 2.1 */ pu ...

  8. java jsonresult_Java JsonResult类代码示例

    import eu.socialsensor.framework.client.search.visual.JsonResultSet.JsonResult; //导入依赖的package包/类 @O ...

  9. postgresql java demo_Java PostgreSQL9Dialect类代码示例

    import org.hibernate.dialect.PostgreSQL9Dialect; //导入依赖的package包/类 private void addDialects(Strategy ...

最新文章

  1. java 网络编程简单聊天_网络编程之 TCP 实现简单聊天
  2. AWS SDK for Java 2.0 使用的基础入门
  3. [转]史上最全的CSS hack方式一览
  4. python -- join()
  5. 已经没有再谈话再培养的飞秋必要了
  6. 前端:JS/19/特殊运算符,运算符优先级,if条件判断语句,switch分支语句,while循环语句,for循环语句,break和continue循环控制语句,实例:九九乘法表
  7. 【C#】读取Excel中嵌套的Json对象,Json带斜杠的问题(其三)
  8. PHP开发入行真功夫(含DVD光盘1张)
  9. MyEclipse取消验证Js的两种方法
  10. hdu 1698 Just a Hook
  11. 算法交流:分享我的一个算法,实现项目需求
  12. 软件各项会议评审意见模版
  13. 客服坐席聊天页面html,WebSocket实现简单客服聊天系统
  14. 如何使用百度统计监测网站流量
  15. 捋一捋Kafka中的消费者API
  16. 字节题--雀魂启动!
  17. 最新车载以太网解决方案,你知多少?
  18. 线性回归中的L1与L2正则化
  19. JAVA-动态代理和AOP
  20. information about btcoin

热门文章

  1. 【乐鑫ESP32】腾讯云平台项目创建以及MQTT协议连接
  2. 计算机毕设(附源码)JAVA-SSM金牛社区疫情防控系统
  3. HoloLens增强现实: Vuforia + Unity3D + SolidWorks + 3ds Max 的一个例子 (网络摄像头也可以)
  4. 基于Matlab实现微波带低通高通带通滤波器设计
  5. 比程序员更好的职业_立即成为更好的程序员的20条技巧
  6. python内置模块re_13.python内置模块之re模块
  7. 校园广播系统应用案例-柴达木职业技术学院
  8. smba简单设置共享
  9. 影响PCB电路板焊接质量的原因有哪些?
  10. JetBrains系列pycharm等设置主题皮肤