@Test public void testFullscreenBackPressed() { Intent intent = new Intent(); WebItem webItem = new TestWebItem() { @Override public String getUrl() { return "http: } @Override public String getId() { return "1"; } }; intent.putExtra(ItemActivity.EXTRA_ITEM, webItem); controller = Robolectric.buildActivity(ItemActivity.class, intent); controller.create().start().resume().visible(); activity = controller.get(); LocalBroadcastManager.getInstance(activity) .sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN) .putExtra(WebFragment.EXTRA_FULLSCREEN, true)); activity.onBackPressed(); assertThat(activity).isNotFinishing(); activity.onBackPressed(); assertThat(activity).isFinishing(); }
@Override public void onBackPressed() { if (!mFullscreen) { super.onBackPressed(); } else { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent( WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false)); } }
ItemActivity extends InjectableActivity implements ItemFragment.ItemChangedListener { @Override public void onBackPressed() { if (!mFullscreen) { super.onBackPressed(); } else { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent( WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false)); } } }
ItemActivity extends InjectableActivity implements ItemFragment.ItemChangedListener { @Override public void onBackPressed() { if (!mFullscreen) { super.onBackPressed(); } else { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent( WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false)); } }  }
ItemActivity extends InjectableActivity implements ItemFragment.ItemChangedListener { @Override public void onBackPressed() { if (!mFullscreen) { super.onBackPressed(); } else { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent( WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false)); } }  @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onBackPressed(); @Override boolean onKeyDown(int keyCode, KeyEvent event); @Override boolean onKeyUp(int keyCode, KeyEvent event); @Override boolean onKeyLongPress(int keyCode, KeyEvent event); @Override void onWindowFocusChanged(boolean hasFocus); @Override void onItemChanged(@NonNull Item item); }
ItemActivity extends InjectableActivity implements ItemFragment.ItemChangedListener { @Override public void onBackPressed() { if (!mFullscreen) { super.onBackPressed(); } else { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent( WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false)); } }  @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onBackPressed(); @Override boolean onKeyDown(int keyCode, KeyEvent event); @Override boolean onKeyUp(int keyCode, KeyEvent event); @Override boolean onKeyLongPress(int keyCode, KeyEvent event); @Override void onWindowFocusChanged(boolean hasFocus); @Override void onItemChanged(@NonNull Item item); static final String EXTRA_ITEM; static final String EXTRA_CACHE_MODE; static final String EXTRA_OPEN_COMMENTS; }