From b1d830e3235da4592d5ad60837be05eb8712a829 Mon Sep 17 00:00:00 2001 From: Codrut Topliceanu <60002907+codrut-topliceanu@users.noreply.github.com> Date: Wed, 30 Jun 2021 18:37:16 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/20195 - Adds tabsTray allowScreenshotsInPrivateMode check (https://github.com/mozilla-mobile/fenix/pull/20203) * For https://github.com/mozilla-mobile/fenix/issues/20195 - Adds tabsTray allowScreenshotsInPrivateMode check --- .../fenix/tabstray/SecureTabsTrayBinding.kt | 3 ++- .../fenix/tabstray/SecureTabsTrayBindingTest.kt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/SecureTabsTrayBinding.kt b/app/src/main/java/org/mozilla/fenix/tabstray/SecureTabsTrayBinding.kt index 0023d0bc94..047132bb8c 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/SecureTabsTrayBinding.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/SecureTabsTrayBinding.kt @@ -33,7 +33,8 @@ class SecureTabsTrayBinding( ) } .collect { state -> - if (state.selectedPage == Page.PrivateTabs) { + if (state.selectedPage == Page.PrivateTabs && + !settings.allowScreenshotsInPrivateMode) { fragment.secure() } else if (!settings.lastKnownMode.isPrivate) { fragment.removeSecure() diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt index 9177074761..4a3b670798 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt @@ -56,6 +56,23 @@ class SecureTabsTrayBindingTest { verify { fragment.secure() } } + @Test + fun `WHEN tab selected page switches to private and allowScreenshotsInPrivateMode true THEN set fragment to un-secure`() { + val tabsTrayStore = TabsTrayStore(TabsTrayState()) + val secureTabsTrayBinding = SecureTabsTrayBinding( + store = tabsTrayStore, + settings = settings, + fragment = fragment + ) + every { settings.allowScreenshotsInPrivateMode } returns true + + secureTabsTrayBinding.start() + tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.positionToPage(Page.PrivateTabs.ordinal))) + tabsTrayStore.waitUntilIdle() + + verify { fragment.removeSecure() } + } + @Test fun `GIVEN not in private mode WHEN tab selected page switches to normal tabs from private THEN set fragment to un-secure`() { every { settings.lastKnownMode.isPrivate } returns false