MraidNativeCommandHandler { @TargetApi(11) boolean isInlineVideoAvailable(@NonNull Activity activity, @NonNull View view) { if (VersionCode.currentApiLevel().isBelow(VersionCode.HONEYCOMB_MR1)) { return false; } View tempView = view; while (true) { if (!tempView.isHardwareAccelerated() || Utils.bitMaskContainsFlag(tempView.getLayerType(), View.LAYER_TYPE_SOFTWARE)) { return false; } if (!(tempView.getParent() instanceof View)) { break; } tempView = (View)tempView.getParent(); } Window window = activity.getWindow(); if (window != null) { if (Utils.bitMaskContainsFlag(window.getAttributes().flags, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)) { return true; } } return false; }  boolean isStorePictureSupported(Context context); static final String ANDROID_CALENDAR_CONTENT_TYPE; }
@TargetApi(11) @Test public void isInlineVideoAvailable_whenViewsAreHardwareAccelerated_whenWindowIsHardwareAccelerated_whenApiLevelIsAtLeastHoneycombMR1_shouldReturnTrue() throws Exception { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); View mockView = mock(View.class); when(mockView.isHardwareAccelerated()).thenReturn(true); when(mockView.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); assertThat(subject.isInlineVideoAvailable(activity, mockView)).isTrue(); }
@TargetApi(11) @Test public void isInlineVideoAvailable_whenViewsAreHardwareAccelerated_whenWindowIsNotHardwareAccelerated_whenApiLevelIsAtLeastHoneycombMR1_shouldReturnFalse() throws Exception { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); View mockView = mock(View.class); when(mockView.isHardwareAccelerated()).thenReturn(true); when(mockView.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); assertThat(subject.isInlineVideoAvailable(activity, mockView)).isFalse(); }
@Config(reportSdk = Build.VERSION_CODES.HONEYCOMB) @TargetApi(11) @Test public void isInlineVideoAvailable_whenViewsAreHardwareAccelerated_whenWindowIsHardwareAccelerated_whenApiLevelIsLessThanHoneycombMR1_shouldReturnFalse() throws Exception { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); View mockView = mock(View.class); when(mockView.isHardwareAccelerated()).thenReturn(true); when(mockView.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); assertThat(subject.isInlineVideoAvailable(activity, mockView)).isFalse(); }
@TargetApi(11) @Test public void isInlineVideoAvailable_whenViewsAreNotHardwareAccelerated_whenWindowIsHardwareAccelerated_whenApiLevelIsAtLeastHoneycombMR1_shouldReturnFalse() throws Exception { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); View mockView = mock(View.class); when(mockView.isHardwareAccelerated()).thenReturn(false); when(mockView.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); assertThat(subject.isInlineVideoAvailable(activity, mockView)).isFalse(); }
@TargetApi(11) @Test public void isInlineVideoAvailable_whenViewParentIsNotHardwareAccelerated_whenWindowIsHardwareAccelerated_whenApiLevelIsAtLeastHoneycombMR1_shouldReturnFalse() throws Exception { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); LinearLayout mockLinearLayout = mock(LinearLayout.class); when(mockLinearLayout.isHardwareAccelerated()).thenReturn(false); when(mockLinearLayout.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); View mockView = mock(View.class); when(mockView.isHardwareAccelerated()).thenReturn(true); when(mockView.getLayerType()).thenReturn(View.LAYER_TYPE_HARDWARE); when(mockView.getParent()).thenReturn(mockLinearLayout); assertThat(subject.isInlineVideoAvailable(activity, mockView)).isFalse(); }