mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterTest.java
@Test
   @SmallTest
   public void testSessionCallbackAfterSetMediaSessionCompat() throws Exception {
       getInstrumentation().runOnMainSync(new Runnable() {
           @Override
           public void run() {
               mSession.setCallback(mSessionCallback);
               mRouter.setMediaSessionCompat(mSession);
           }
       });

       MediaControllerCompat controller = mSession.getController();
       MediaControllerCompat.TransportControls controls = controller.getTransportControls();
       synchronized (mWaitLock) {
           mSessionCallback.reset();
           controls.play();
           mWaitLock.wait(TIME_OUT_MS);
           assertTrue(mSessionCallback.mOnPlayCalled);

           mSessionCallback.reset();
           controls.pause();
           mWaitLock.wait(TIME_OUT_MS);
           assertTrue(mSessionCallback.mOnPauseCalled);
       }
   }
/**
    * This test checks whether the session callback work properly after setMediaSessionCompat() is
    * called.
    */
This test checks whether the session callback work properly after setMediaSessionCompat() is
called.
This test checks whether the session callback work properly after setMediaSessionCompat () is called .
@Test
   @SmallTest
   public void testSessionCallbackAfterSetMediaSessionCompat() throws Exception {
       getInstrumentation().runOnMainSync(new Runnable() {
           @Override
           public void run() {
               mSession.setCallback(mSessionCallback);
               mRouter.setMediaSessionCompat(mSession);
           }
       });
       MediaControllerCompat controller = mSession.getController();
       MediaControllerCompat.TransportControls controls = controller.getTransportControls();
       synchronized (mWaitLock) {
           mSessionCallback.reset();
           controls.play();
           mWaitLock.wait(TIME_OUT_MS);
           assertTrue(mSessionCallback.mOnPlayCalled);
           mSessionCallback.reset();
           controls.pause();
           mWaitLock.wait(TIME_OUT_MS);
           assertTrue(mSessionCallback.mOnPauseCalled);
       }
   }
@ Test @ SmallTest public void testSessionCallbackAfterSetMediaSessionCompat ( ) throws Exception { getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { mSession . setCallback ( mSessionCallback ) ; mRouter . setMediaSessionCompat ( mSession ) ; } } ) ; MediaControllerCompat controller = mSession . getController ( ) ; MediaControllerCompat . TransportControls controls = controller . getTransportControls ( ) ; synchronized ( mWaitLock ) { mSessionCallback . reset ( ) ; controls . play ( ) ; mWaitLock . wait ( TIME_OUT_MS ) ; assertTrue ( mSessionCallback . mOnPlayCalled ) ; mSessionCallback . reset ( ) ; controls . pause ( ) ; mWaitLock . wait ( TIME_OUT_MS ) ; assertTrue ( mSessionCallback . mOnPauseCalled ) ; } }
This test checks whether the session callback work properly after setMediaSessionCompat() is
 called.
This test checks whether the session callback work properly after setMediaSessionCompat () is called .