Java Code Examples for

The following are Jave code examples for showing how to use wait() of the class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: notification-adapter   File:   Source Code and License Vote up 5 votes
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(, NOTIFICATION_TITLE);
    contentView.setTextViewText(, NOTIFICATION_TEXT);

    // Fix the Notification-Style problem ---------------
    // Set the default title style color to title view.
    contentView.setTextColor(, NotificationAdapter.getTitleColor(appContext));
    // Set the default title style size to title view
    contentView.setTextViewTextSize(, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
    // Set the default text style color to text view
    contentView.setTextColor(, NotificationAdapter.getTextColor(appContext));
    // Set the default text style size to text view
    contentView.setTextViewTextSize(, 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.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
Example 2
Project: ChimpCheck   File:   Source Code and License Vote up 4 votes
protected void launchResume() {
    Log.i(runner.chimpTag("[email protected]"), "Resume");

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


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

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

Example 3
Project: android_packages_apps_tv   File:   Source Code and License Vote up 4 votes
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);