This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3918: Closes #3791 - Derive app icon for likely app-link app r=jonalmeida a=jhugman This PR exposes the icon and name of the app used to open a given link. This is to allow Fenix to display the app icon in the Quick Action Bar `Open in App` action. ### Pull Request checklist <!-- Before submitting the PR, please address each item --> - [X] **Quality**: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended) - [X] **Tests**: This PR includes thorough tests or an explanation of why it does not - [ ] **Changelog**: This PR includes [a changelog entry](https://github.com/mozilla-mobile/android-components/blob/master/docs/changelog.md) or does not need one - ~[ ] **Accessibility**: The code in this PR follows [accessibility best practices](https://github.com/mozilla-mobile/shared-docs/blob/master/android/accessibility_guide.md) or does not include any user facing features~ ### After merge - [ ] **Milestone**: Make sure issues closed by this pull request are added to the [milestone](https://github.com/mozilla-mobile/android-components/milestones) of the version currently in development. 4572: Closes #2203, #3511: Inline Socorro upload functionality and add supp… r=pocmo a=rocketsroger …ort for "uncaught exception" crash reports Co-authored-by: James Hugman <[email protected]> Co-authored-by: Jonathan Almeida <[email protected]> Co-authored-by: Roger Yang <[email protected]>
- Loading branch information
Showing
8 changed files
with
511 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...ature/app-links/src/test/java/mozilla/components/feature/app/links/AppLinkRedirectTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package mozilla.components.feature.app.links | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import mozilla.components.support.test.mock | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import org.mockito.Mockito.`when` | ||
|
||
class AppLinkRedirectTest { | ||
|
||
@Test | ||
fun hasExternalApp() { | ||
var appLink = AppLinkRedirect(appIntent = mock(), webUrl = null, isFallback = true) | ||
assertTrue(appLink.hasExternalApp()) | ||
|
||
appLink = AppLinkRedirect(appIntent = null, webUrl = null, isFallback = true) | ||
assertFalse(appLink.hasExternalApp()) | ||
} | ||
|
||
@Test | ||
fun hasFallback() { | ||
var appLink = AppLinkRedirect(appIntent = mock(), webUrl = null, isFallback = true) | ||
assertFalse(appLink.hasFallback()) | ||
|
||
appLink = AppLinkRedirect(appIntent = mock(), webUrl = "https://example.com", isFallback = false) | ||
assertFalse(appLink.hasFallback()) | ||
|
||
appLink = AppLinkRedirect(appIntent = mock(), webUrl = "https://example.com", isFallback = true) | ||
assertTrue(appLink.hasFallback()) | ||
} | ||
|
||
@Test | ||
fun isRedirect() { | ||
var appLink = AppLinkRedirect(appIntent = null, webUrl = null, isFallback = true) | ||
assertFalse(appLink.isRedirect()) | ||
|
||
appLink = AppLinkRedirect(appIntent = mock(), webUrl = null, isFallback = true) | ||
assertTrue(appLink.isRedirect()) | ||
|
||
appLink = AppLinkRedirect(appIntent = null, webUrl = "https://example.com", isFallback = true) | ||
assertTrue(appLink.isRedirect()) | ||
|
||
appLink = AppLinkRedirect(appIntent = mock(), webUrl = "https://example.com", isFallback = true) | ||
assertTrue(appLink.isRedirect()) | ||
} | ||
|
||
@Test | ||
fun isInstallable() { | ||
val intent: Intent = mock() | ||
val uri: Uri = mock() | ||
`when`(intent.data).thenReturn(uri) | ||
`when`(uri.scheme).thenReturn("market") | ||
|
||
var appLink = AppLinkRedirect(appIntent = null, webUrl = "https://example.com", isFallback = true) | ||
assertFalse(appLink.isInstallable()) | ||
|
||
appLink = AppLinkRedirect(appIntent = intent, webUrl = "https://example.com", isFallback = true) | ||
assertTrue(appLink.isInstallable()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.