Skip to content

Commit bdd6da2

Browse files
committed
Fix issues after rebase
1 parent 53ff790 commit bdd6da2

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import com.duckduckgo.autoconsent.api.Autoconsent
6868
import com.duckduckgo.autofill.api.BrowserAutofill
6969
import com.duckduckgo.autofill.api.InternalTestUserChecker
7070
import com.duckduckgo.browser.api.JsInjectorPlugin
71+
import com.duckduckgo.browser.api.WebMessagingBrowserPlugin
7172
import com.duckduckgo.browser.api.WebViewVersionProvider
7273
import com.duckduckgo.common.test.CoroutineTestRule
7374
import com.duckduckgo.common.utils.CurrentTimeProvider
@@ -86,7 +87,7 @@ import com.duckduckgo.feature.toggles.api.Toggle
8687
import com.duckduckgo.history.api.NavigationHistory
8788
import com.duckduckgo.js.messaging.api.PostMessageWrapperPlugin
8889
import com.duckduckgo.js.messaging.api.SubscriptionEventData
89-
import com.duckduckgo.js.messaging.api.WebMessagingPlugin
90+
import com.duckduckgo.js.messaging.api.WebMessaging
9091
import com.duckduckgo.js.messaging.api.WebViewCompatMessageCallback
9192
import com.duckduckgo.privacy.config.api.AmpLinks
9293
import com.duckduckgo.subscriptions.api.Subscriptions
@@ -380,10 +381,10 @@ class BrowserWebViewClientTest {
380381
@Test
381382
fun whenConfigureWebViewThenAddWebMessageListener() =
382383
runTest {
383-
assertFalse(fakeMessagingPlugins.plugin.registered)
384+
assertFalse(fakeMessagingPlugins.plugin.webMessaging().registered)
384385
val mockCallback = mock<WebViewCompatMessageCallback>()
385386
testee.configureWebView(DuckDuckGoWebView(context), mockCallback)
386-
assertTrue(fakeMessagingPlugins.plugin.registered)
387+
assertTrue(fakeMessagingPlugins.plugin.webMessaging().registered)
387388
}
388389

389390
@Test
@@ -1342,7 +1343,7 @@ class BrowserWebViewClientTest {
13421343
const val EXAMPLE_URL = "https://example.com"
13431344
}
13441345

1345-
class FakeWebMessagingPlugin : WebMessagingPlugin.WebMessaging {
1346+
class FakeWebMessaging : WebMessaging {
13461347
var registered = false
13471348
private set
13481349

@@ -1367,10 +1368,16 @@ class BrowserWebViewClientTest {
13671368
get() = "test"
13681369
}
13691370

1370-
class FakeWebMessagingPluginPoint : PluginPoint<WebMessaging> {
1371-
val plugin = FakeWebMessagingPlugin()
1371+
class FakeWebMessagingBrowserPlugin : WebMessagingBrowserPlugin {
1372+
private val webMessaging = FakeWebMessaging()
13721373

1373-
override fun getPlugins(): Collection<WebMessaging> {
1374+
override fun webMessaging(): FakeWebMessaging = webMessaging
1375+
}
1376+
1377+
class FakeWebMessagingPluginPoint : PluginPoint<WebMessagingBrowserPlugin> {
1378+
val plugin = FakeWebMessagingBrowserPlugin()
1379+
1380+
override fun getPlugins(): Collection<WebMessagingBrowserPlugin> {
13741381
return listOf(plugin)
13751382
}
13761383
}

content-scope-scripts/content-scope-scripts-impl/src/test/java/com/duckduckgo/contentscopescripts/impl/messaging/ContentScopeScriptsPostMessageWrapperPluginTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class ContentScopeScriptsPostMessageWrapperPluginTest {
6565

6666
testee.postMessage(subscriptionEventData, mockWebView)
6767

68-
verify(mockWebMessaging).postMessage(mockWebView, subscriptionEventData)
69-
}
68+
verify(mockWebMessaging).postMessage(mockWebView, subscriptionEventData)
69+
}
7070

7171
@Test
7272
fun whenWebViewCompatContentScopeScriptsIsNotEnabledThenPostMessageToContentScopeScriptsJsMessaging() =

js-messaging/js-messaging-impl/src/main/java/com/duckduckgo/js/messaging/impl/RealWebMessagingDelegate.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ import com.duckduckgo.js.messaging.api.WebMessagingStrategy
3838
import com.duckduckgo.js.messaging.api.WebViewCompatMessageCallback
3939
import com.squareup.anvil.annotations.ContributesBinding
4040
import com.squareup.moshi.Moshi
41-
import javax.inject.Inject
4241
import kotlinx.coroutines.CoroutineScope
4342
import kotlinx.coroutines.launch
4443
import logcat.LogPriority.ERROR
4544
import logcat.asLog
4645
import logcat.logcat
4746
import org.json.JSONObject
47+
import javax.inject.Inject
4848

4949
@ContributesBinding(AppScope::class)
5050
class RealWebMessagingDelegate @Inject constructor(
@@ -162,8 +162,8 @@ class RealWebMessagingDelegate @Inject constructor(
162162
webView: WebView,
163163
) {
164164
if (!strategy.canHandleMessaging()) {
165-
return
166-
}
165+
return
166+
}
167167

168168
runCatching {
169169
return@runCatching webViewCompatWrapper.addWebMessageListener(
@@ -181,7 +181,6 @@ class RealWebMessagingDelegate @Inject constructor(
181181
}.getOrElse { exception ->
182182
logcat(ERROR) { "Error adding WebMessageListener for ${strategy.objectName}: ${exception.asLog()}" }
183183
}
184-
185184
}
186185

187186
override suspend fun unregister(

js-messaging/js-messaging-impl/src/test/java/com/duckduckgo/js/messaging/impl/RealWebMessagingDelegateTest.kt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,28 @@ class RealWebMessagingDelegateTest {
240240
override suspend fun canHandleMessaging(): Boolean = canHandleMessaging
241241

242242
override fun getMessageHandlers(): List<WebViewCompatMessageHandler> {
243-
return listOf(object : WebViewCompatMessageHandler {
244-
override fun process(jsMessage: JsMessage): ProcessResult {
245-
return SendToConsumer
246-
}
247-
248-
override val featureName: String = "testFeature"
249-
override val methods: List<String> = listOf("testMethod")
250-
},)
243+
return listOf(
244+
object : WebViewCompatMessageHandler {
245+
override fun process(jsMessage: JsMessage): ProcessResult {
246+
return SendToConsumer
247+
}
248+
249+
override val featureName: String = "testFeature"
250+
override val methods: List<String> = listOf("testMethod")
251+
},
252+
)
251253
}
252254

253255
override fun getGlobalMessageHandler(): List<GlobalJsMessageHandler> {
254-
return listOf(object : GlobalJsMessageHandler {
255-
override fun process(jsMessage: JsMessage): ProcessResult {
256-
return SendToConsumer
257-
}
258-
259-
override val method: String = "globalMethod"
260-
},)
256+
return listOf(
257+
object : GlobalJsMessageHandler {
258+
override fun process(jsMessage: JsMessage): ProcessResult {
259+
return SendToConsumer
260+
}
261+
262+
override val method: String = "globalMethod"
263+
},
264+
)
261265
}
262266
}
263267
}

0 commit comments

Comments
 (0)