media/version-compat-tests/previous/service/src/androidTest/java/android/support/mediacompat/service/MediaSessionCompatCallbackTest.java
@Test
    @SmallTest
    public void testFromSession() throws Exception {
        if (android.os.Build.VERSION.SDK_INT < 21) {
            // MediaSession was introduced from API level 21.
            return;
        }
        mCallback.reset(1);
        mSession.setCallback(mCallback, new Handler(Looper.getMainLooper()));
        MediaSessionCompat session = MediaSessionCompat.fromMediaSession(
                getContext(), mSession.getMediaSession());
        assertEquals(session.getSessionToken(), mSession.getSessionToken());

        session.getController().getTransportControls().play();
        mCallback.await(TIME_OUT_MS);
        assertEquals(1, mCallback.mOnPlayCalledCount);
    }
/**
     * Tests that a session can be created from the framework session object and the callback
     * set on the framework session object before fromSession() is called works properly.
     */
Tests that a session can be created from the framework session object and the callback
set on the framework session object before fromSession() is called works properly.
Tests that a session can be created from the framework session object and the callback set on the framework session object before fromSession () is called works properly .
@Test
    @SmallTest
    public void testFromSession() throws Exception {
        if (android.os.Build.VERSION.SDK_INT < 21) {
            return;
        }
        mCallback.reset(1);
        mSession.setCallback(mCallback, new Handler(Looper.getMainLooper()));
        MediaSessionCompat session = MediaSessionCompat.fromMediaSession(
                getContext(), mSession.getMediaSession());
        assertEquals(session.getSessionToken(), mSession.getSessionToken());
        session.getController().getTransportControls().play();
        mCallback.await(TIME_OUT_MS);
        assertEquals(1, mCallback.mOnPlayCalledCount);
    }
@ Test @ SmallTest public void testFromSession ( ) throws Exception { if ( android . os . Build . VERSION . SDK_INT < 21 ) { return ; } mCallback . reset ( 1 ) ; mSession . setCallback ( mCallback , new Handler ( Looper . getMainLooper ( ) ) ) ; MediaSessionCompat session = MediaSessionCompat . fromMediaSession ( getContext ( ) , mSession . getMediaSession ( ) ) ; assertEquals ( session . getSessionToken ( ) , mSession . getSessionToken ( ) ) ; session . getController ( ) . getTransportControls ( ) . play ( ) ; mCallback . await ( TIME_OUT_MS ) ; assertEquals ( 1 , mCallback . mOnPlayCalledCount ) ; }
Tests that a session can be created from the framework session object and the callback
 set on the framework session object before fromSession() is called works properly.
Tests that a session can be created from the framework session object and the callback set on the framework session object before fromSession () is called works properly .
// MediaSession was introduced from API level 21.