FileDocCategorySizeDatePackage
ViewAttachTest.javaAPI DocAndroid 5.1 API2020Thu Mar 12 22:22:12 GMT 2015android.view

ViewAttachTest

public class ViewAttachTest extends android.test.ActivityInstrumentationTestCase2

Fields Summary
Constructors Summary
public ViewAttachTest()

        super(ViewAttachTestActivity.class);
    
Methods Summary
public voidtestAttached()
Make sure that onAttachedToWindow and onDetachedToWindow is called in the correct order. The ViewAttachTestActivity contains a view that will throw a RuntimeException if onDetachedToWindow and onAttachedToWindow are called in the wrong order. 1. Initiate the activity 2. Perform a series of orientation changes to the activity (this will force the View hierarchy to be rebuilt, generating onAttachedToWindow and onDetachedToWindow) Expected result: No RuntimeException is thrown from the TestView in ViewFlipperTestActivity.

throws
Throwable

        final ViewAttachTestActivity activity = getActivity();
        for (int i = 0; i < 20; i++) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            SystemClock.sleep(250);
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            SystemClock.sleep(250);
        }