### Question:
PlaybackTransportControlGlue extends PlaybackBaseControlGlue<T> { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_ESCAPE: return false; } final ObjectAdapter primaryActionsAdapter = mControlsRow.getPrimaryActionsAdapter(); Action action = mControlsRow.getActionForKeyCode(primaryActionsAdapter, keyCode); if (action == null) { action = mControlsRow.getActionForKeyCode(mControlsRow.getSecondaryActionsAdapter(), keyCode); } if (action != null) { if (event.getAction() == KeyEvent.ACTION_DOWN) { dispatchAction(action, event); } return true; } return false; } PlaybackTransportControlGlue(Context context, T impl); @Override void setControlsRow(PlaybackControlsRow controlsRow); @Override void onActionClicked(Action action); @Override boolean onKey(View v, int keyCode, KeyEvent event); final void setSeekProvider(PlaybackSeekDataProvider seekProvider); final PlaybackSeekDataProvider getSeekProvider(); final void setSeekEnabled(boolean seekEnabled); final boolean isSeekEnabled();  }### Answer:
@Test public void playStateReceivePlayPause() { setupWithMockAdapterAndViewHolder(); playMockAdapter(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)); Mockito.verify(mAdapter, times(1)).pause(); }
@Test public void playStateReceivePause() { setupWithMockAdapterAndViewHolder(); playMockAdapter(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PAUSE, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE)); Mockito.verify(mAdapter, times(1)).pause(); }
@Test public void playStateReceivePlay() { setupWithMockAdapterAndViewHolder(); playMockAdapter(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PLAY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY)); Mockito.verify(mAdapter, never()).pause(); }
@Test public void pauseStateReceivePlayPause() { setupWithMockAdapterAndViewHolder(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)); Mockito.verify(mAdapter, times(1)).play(); }
@Test public void pauseStateReceivePause() { setupWithMockAdapterAndViewHolder(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PAUSE, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE)); Mockito.verify(mAdapter, never()).play(); }
@Test public void pauseStateReceivePlay() { setupWithMockAdapterAndViewHolder(); mGlue.onKey(null, KeyEvent.KEYCODE_MEDIA_PLAY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY)); Mockito.verify(mAdapter, times(1)).play(); }