本文整理汇总了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);
}
示例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);
}
示例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);
}