当前位置: 首页>>代码示例>>Java>>正文


Java UiDevice.wait方法代码示例

本文整理汇总了Java中android.support.test.uiautomator.UiDevice.wait方法的典型用法代码示例。如果您正苦于以下问题:Java UiDevice.wait方法的具体用法?Java UiDevice.wait怎么用?Java UiDevice.wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.test.uiautomator.UiDevice的用法示例。


在下文中一共展示了UiDevice.wait方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNotificationAdapter

import android.support.test.uiautomator.UiDevice; //导入方法依赖的package包/类
@Test
public void testNotificationAdapter() {
    final String NOTIFICATION_TEXT = "adapter-text";
    final String NOTIFICATION_TITLE = "adapter-title";
    final long TIMEOUT = 5000;

    Context appContext = InstrumentationRegistry.getTargetContext();

    RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test", R.layout.custom_layout);
    contentView.setTextViewText(R.id.title, NOTIFICATION_TITLE);
    contentView.setTextViewText(R.id.text, NOTIFICATION_TEXT);

    // Fix the Notification-Style problem ---------------
    // Set the default title style color to title view.
    contentView.setTextColor(R.id.title, NotificationAdapter.getTitleColor(appContext));
    // Set the default title style size to title view
    contentView.setTextViewTextSize(R.id.title, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
    // Set the default text style color to text view
    contentView.setTextColor(R.id.text, NotificationAdapter.getTextColor(appContext));
    // Set the default text style size to text view
    contentView.setTextViewTextSize(R.id.text, COMPLEX_UNIT_PX, NotificationAdapter.getTextSize(appContext));
    // End fix the Notification-Style problem ---------------

    Notification notification = new Notification();
    notification.icon = R.drawable.ic_launcher;
    notification.contentView = contentView;

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;

    NotificationManager notifyMgr =
            (NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
    notifyMgr.notify(1, notification);

    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    device.openNotification();
    device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
}
 
开发者ID:Jacksgong,项目名称:notification-adapter,代码行数:40,代码来源:NotificationAdapterTest.java

示例2: launchResume

import android.support.test.uiautomator.UiDevice; //导入方法依赖的package包/类
@Override
protected void launchResume() {
    Log.i(runner.chimpTag("[email protected]"), "Resume");

    String packageName = runner.getAppPackageName();
    int launchTimeout = 5000;


    sleep(500);

    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
    Context context = InstrumentationRegistry.getContext();
    final Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(packageName);
    context.startActivity(intent);

    mDevice.wait(Until.hasObject(By.pkg(packageName).depth(0)), launchTimeout);

}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:20,代码来源:EspressoChimpDriver.java

示例3: waitForCondition

import android.support.test.uiautomator.UiDevice; //导入方法依赖的package包/类
private static boolean waitForCondition(UiDevice uiDevice,
        SearchCondition<Boolean> searchCondition, long timeout) {
    long adjustedTimeout = timeout + Math.max(Constants.MIN_EXTRA_TIMEOUT,
            (long) (timeout * Constants.EXTRA_TIMEOUT_PERCENT));
    return uiDevice.wait(searchCondition, adjustedTimeout);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:7,代码来源:UiDeviceAsserts.java


注:本文中的android.support.test.uiautomator.UiDevice.wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。