Skip to content

Commit 1a73d54

Browse files
committed
Merge branch 'release/5.45.0'
2 parents bd44b61 + 0f16407 commit 1a73d54

File tree

14 files changed

+83
-16
lines changed

14 files changed

+83
-16
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class BrowserChromeClientTest {
4848
webView = TestWebView(getInstrumentation().targetContext)
4949
}
5050

51+
@Test
52+
fun whenWindowClosedThenCloseCurrentTab() {
53+
testee.onCloseWindow(window = null)
54+
verify(mockWebViewClientListener).closeCurrentTab()
55+
}
56+
5157
@Test
5258
fun whenCustomViewShownForFirstTimeListenerInstructedToGoFullScreen() {
5359
testee.onShowCustomView(fakeView, null)

app/src/androidTest/java/com/duckduckgo/app/statistics/VariantManagerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class VariantManagerTest {
3333
@Test
3434
fun serpControlVariantIsInactiveAndHasNoFeatures() {
3535
val variant = variants.first { it.key == "sc" }
36-
assertEqualsDouble(0.0, variant.weight)
36+
assertEqualsDouble(1.0, variant.weight)
3737
assertEquals(0, variant.features.size)
3838
}
3939

4040
@Test
4141
fun serpExperimentalVariantIsInactiveAndHasNoFeatures() {
4242
val variant = variants.first { it.key == "se" }
43-
assertEqualsDouble(0.0, variant.weight)
43+
assertEqualsDouble(1.0, variant.weight)
4444
assertEquals(0, variant.features.size)
4545
}
4646

app/src/androidTest/java/com/duckduckgo/app/systemsearch/SystemSearchViewModelTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ class SystemSearchViewModelTest {
8585
assertEquals(autocompleteQueryResult, newViewState?.autocompleteResults)
8686
}
8787

88+
@Test
89+
fun whenUserAddsSpaceToQueryThenViewStateMatchesAndSpaceTrimmedFromAutocomplete() = ruleRunBlockingTest {
90+
testee.userUpdatedQuery(QUERY)
91+
testee.userUpdatedQuery("$QUERY ")
92+
93+
val newViewState = testee.viewState.value
94+
assertNotNull(newViewState)
95+
assertEquals("$QUERY ", newViewState?.queryText)
96+
assertEquals(appQueryResult, newViewState?.appResults)
97+
assertEquals(autocompleteQueryResult, newViewState?.autocompleteResults)
98+
}
99+
88100
@Test
89101
fun whenUserClearsQueryThenViewStateReset() = ruleRunBlockingTest {
90102
testee.userUpdatedQuery(QUERY)

app/src/main/java/com/duckduckgo/app/browser/BrowserChromeClient.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,8 @@ class BrowserChromeClient @Inject constructor(private val uncaughtExceptionRepos
116116
}
117117
return false
118118
}
119+
120+
override fun onCloseWindow(window: WebView?) {
121+
webViewClientListener?.closeCurrentTab()
122+
}
119123
}

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,17 @@ class BrowserTabViewModel(
379379
return !currentBrowserViewState().browserShowing && navigation.hasNavigationHistory
380380
}
381381

382-
suspend fun closeCurrentTab() {
382+
private suspend fun removeCurrentTabFromRepository() {
383383
val currentTab = tabRepository.liveSelectedTab.value
384384
currentTab?.let {
385385
tabRepository.delete(currentTab)
386386
}
387387
}
388388

389+
override fun closeCurrentTab() {
390+
viewModelScope.launch { removeCurrentTabFromRepository() }
391+
}
392+
389393
fun onUserPressedForward() {
390394
if (!currentBrowserViewState().browserShowing) {
391395
browserViewState.value = currentBrowserViewState().copy(browserShowing = true)
@@ -1058,7 +1062,7 @@ class BrowserTabViewModel(
10581062
}
10591063

10601064
private fun recoverTabWithQuery(query: String) {
1061-
viewModelScope.launch { closeCurrentTab() }
1065+
closeCurrentTab()
10621066
command.value = OpenInNewTab(query)
10631067
}
10641068

app/src/main/java/com/duckduckgo/app/browser/WebViewClientListener.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ interface WebViewClientListener {
4545
fun openMessageInNewTab(message: Message)
4646
fun recoverFromRenderProcessGone()
4747
fun requiresAuthentication(request: BasicAuthenticationRequest)
48+
fun closeCurrentTab()
4849
}

app/src/main/java/com/duckduckgo/app/statistics/VariantManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ interface VariantManager {
4747
val ACTIVE_VARIANTS = listOf(
4848
// SERP variants. "sc" may also be used as a shared control for mobile experiments in
4949
// the future if we can filter by app version
50-
Variant(key = "sc", weight = 0.0, features = emptyList(), filterBy = { noFilter() }),
51-
Variant(key = "se", weight = 0.0, features = emptyList(), filterBy = { noFilter() }),
50+
Variant(key = "sc", weight = 1.0, features = emptyList(), filterBy = { noFilter() }),
51+
Variant(key = "se", weight = 1.0, features = emptyList(), filterBy = { noFilter() }),
5252

5353
// Concept test experiment
5454
Variant(key = "mc", weight = 0.0, features = emptyList(), filterBy = { isEnglishLocale() }),

app/src/main/java/com/duckduckgo/app/systemsearch/SystemSearchViewModel.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,21 @@ class SystemSearchViewModel(
9191

9292
appsJob?.cancel()
9393

94-
val trimmedQuery = query.trim()
95-
96-
if (trimmedQuery == currentViewState().queryText) {
94+
if (query == currentViewState().queryText) {
9795
return
9896
}
9997

100-
if (trimmedQuery.isBlank()) {
98+
if (query.isBlank()) {
10199
userClearedQuery()
102100
return
103101
}
104102

105-
viewState.value = currentViewState().copy(queryText = trimmedQuery)
106-
autoCompletePublishSubject.accept(trimmedQuery)
103+
viewState.value = currentViewState().copy(queryText = query)
107104

105+
val trimmedQuery = query.trim()
106+
autoCompletePublishSubject.accept(trimmedQuery)
108107
appsJob = viewModelScope.launch(dispatchers.io()) {
109-
updateAppResults(deviceAppLookup.query(query))
108+
updateAppResults(deviceAppLookup.query(trimmedQuery))
110109
}
111110
}
112111

app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherAdapter.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,15 @@ class TabSwitcherAdapter(private val itemClickListener: TabSwitcherListener, pri
119119
}
120120

121121
private fun loadTabPreviewImage(tab: TabEntity, glide: GlideRequests, holder: TabViewHolder) {
122-
val previewFile = tab.tabPreviewFile ?: return
122+
val previewFile = tab.tabPreviewFile
123+
if (previewFile == null) {
124+
glide.clear(holder.tabPreview)
125+
return
126+
}
123127

124128
val cachedWebViewPreview = File(webViewPreviewPersister.fullPathForFile(tab.tabId, previewFile))
125129
if (!cachedWebViewPreview.exists()) {
130+
glide.clear(holder.tabPreview)
126131
return
127132
}
128133

app/src/main/res/layout/popup_window_browser_menu.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
android:background="@color/white"
2828
android:gravity="center"
2929
android:orientation="horizontal"
30+
app:layout_constraintTop_toTopOf="parent"
3031
app:layout_constraintEnd_toEndOf="parent"
3132
app:layout_constraintStart_toStartOf="parent">
3233

@@ -68,6 +69,7 @@
6869
<ScrollView
6970
android:layout_width="match_parent"
7071
android:layout_height="wrap_content"
72+
app:layout_constrainedHeight="true"
7173
app:layout_constraintBottom_toBottomOf="parent"
7274
app:layout_constraintTop_toBottomOf="@id/header">
7375

0 commit comments

Comments
 (0)