LoyaltyCardViewActivity extends AppCompatActivity { @Override public void onBackPressed() { if (barcodeIsFullscreen) { setFullscreen(false); return; } super.onBackPressed(); return; }  @Override void onNewIntent(Intent intent); @Override void onResume(); @Override void onBackPressed(); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item);  }
@Test public void checkBarcodeFullscreenWorkflow() { ActivityController activityController = createActivityWithLoyaltyCard(false); Activity activity = (Activity)activityController.get(); DBHelper db = new DBHelper(activity); db.insertLoyaltyCard("store", "note", BARCODE_DATA, BARCODE_TYPE, Color.BLACK, Color.WHITE); activityController.start(); activityController.visible(); activityController.resume(); assertEquals(false, activity.isFinishing()); ImageView barcodeImage = activity.findViewById(R.id.barcode); View collapsingToolbarLayout = activity.findViewById(R.id.collapsingToolbarLayout); int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions); assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility()); barcodeImage.performClick(); uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); assertEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions); assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions); assertEquals(View.GONE, collapsingToolbarLayout.getVisibility()); barcodeImage.performClick(); uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions); assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility()); barcodeImage.performClick(); uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); assertEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions); assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions); assertEquals(View.GONE, collapsingToolbarLayout.getVisibility()); activity.onBackPressed(); uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility(); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions); assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions); assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility()); activity.onBackPressed(); assertEquals(true, activity.isFinishing()); }