Example usage for android.widget ProgressBar requestFocus

List of usage examples for android.widget ProgressBar requestFocus

Introduction

In this page you can find the example usage for android.widget ProgressBar requestFocus.

Prototype

public final boolean requestFocus() 

Source Link

Document

Call this to try to give focus to a specific view or to one of its descendants.

Usage

From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java

/**
 * Make sure that selection-event elimination does not get rid of progress bar VIEW_SELECTED
 * events.//from   ww w  . j a v  a2s  .  c o m
 */
@MediumTest
public void testProgressBarSelectedEvents() {
    final ProgressBar progressBar = (ProgressBar) getViewForId(R.id.progress_bar);
    final AccessibilityNodeInfoCompat progressBarNode = getNodeForView(progressBar);

    mMatchEventType = AccessibilityEvent.TYPE_VIEW_SELECTED;
    mMatchNode = AccessibilityNodeInfoCompat.obtain(progressBarNode);

    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            progressBar.requestFocus();
            progressBar.setProgress(25);
        }
    });
    getInstrumentation().waitForIdleSync();
    waitForAccessibilityIdleSync();

    assertTrue(mMatched);
}