This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #10867 - Dismisses user prompt when GV calls
onPromptDismiss
- Loading branch information
1 parent
a992c20
commit fd2ce39
Showing
8 changed files
with
132 additions
and
6 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
21 changes: 21 additions & 0 deletions
21
...main/java/mozilla/components/browser/engine/gecko/prompt/PromptInstanceDismissDelegate.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,21 @@ | ||
/* 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.browser.engine.gecko.prompt | ||
|
||
import mozilla.components.browser.engine.gecko.GeckoEngineSession | ||
import mozilla.components.concept.engine.prompt.PromptRequest | ||
import org.mozilla.geckoview.GeckoSession | ||
|
||
internal class PromptInstanceDismissDelegate( | ||
private val geckoSession: GeckoEngineSession, | ||
private val promptRequest: PromptRequest | ||
) : GeckoSession.PromptDelegate.PromptInstanceDelegate { | ||
|
||
override fun onPromptDismiss(prompt: GeckoSession.PromptDelegate.BasePrompt) { | ||
geckoSession.notifyObservers { | ||
onPromptDismissed(promptRequest) | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
.../java/mozilla/components/browser/engine/gecko/prompt/PromptInstanceDismissDelegateTest.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,38 @@ | ||
/* 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.browser.engine.gecko.prompt | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import mozilla.components.browser.engine.gecko.GeckoEngineSession | ||
import mozilla.components.concept.engine.EngineSession | ||
import mozilla.components.concept.engine.prompt.PromptRequest | ||
import mozilla.components.support.test.mock | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mozilla.geckoview.Autocomplete | ||
import org.mozilla.geckoview.GeckoSession | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class PromptInstanceDismissDelegateTest { | ||
|
||
@Test | ||
fun `GIVEN delegate with promptRequest WHEN onPromptDismiss called from geckoview THEN notifyObservers the prompt is dismissed`() { | ||
val mockSession = GeckoEngineSession(mock()) | ||
var onDismissWasCalled = false | ||
mockSession.register(object : EngineSession.Observer { | ||
override fun onPromptDismissed(promptRequest: PromptRequest) { | ||
super.onPromptDismissed(promptRequest) | ||
onDismissWasCalled = true | ||
} | ||
}) | ||
val basePrompt: GeckoSession.PromptDelegate.AutocompleteRequest<Autocomplete.LoginSaveOption> = mock() | ||
val prompt: PromptRequest = mock() | ||
val delegate = PromptInstanceDismissDelegate(mockSession, prompt) | ||
|
||
delegate.onPromptDismiss(basePrompt) | ||
|
||
assertTrue(onDismissWasCalled) | ||
} | ||
} |
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
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
fd2ce39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh! Looks like an error! Details
Failed to fetch task artifact
public/github/customCheckRunText.md
for GitHub integration.Make sure the artifact exists on the worker or other location.