Skip to content

Commit df51f9c

Browse files
committed
Merge branch 'release/5.34.0'
2 parents 52d86bc + 2329e23 commit df51f9c

File tree

53 files changed

+2076
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2076
-146
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#These people are listed as being the code owners for this project. As such, they will be automatically added as a reviewer when a PR is created.
22
#For more details on how this is configured, see https://help.github.com/articles/about-code-owners/
33

4-
* @CDRussell @subsymbolic
4+
* @CDRussell @subsymbolic @marcosholgado

TRANSLATIONS.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,13 @@ If you know any of the following languages and would like to help us improve the
2828

2929
## How to help
3030

31-
There is a branch containing the current translations, called [`feature/app_translations`](https://github.com/duckduckgo/Android/tree/feature/app_translations/app/src/main/res).
32-
1. Each language has a `values` directory containing the language code, and the `strings.xml` file contains the translations. Examples:
33-
- Italian translation files are located within `values-it/strings.xml`
34-
- Spanish translation files are located within `values-es/strings.xml`
35-
1. If you notice anything which could be improved, you should create a PR containing the improved language suggestions and those changes will be merged into that branch if accepted.
36-
1. Fork the project, and clone your forked project to your machine. [Instructions](https://help.github.com/en/articles/fork-a-repo)
37-
1. Checkout the translations branch `git checkout --track origin/feature/app_translations`
38-
1. Make the changes to the relevant `strings.xml` file, and commit
31+
1. Each language has a [`values`](https://github.com/duckduckgo/Android/tree/develop/app/src/main/res) directory containing the language code, and the `strings.xml` file contains the translations. Examples:
32+
- Italian translation files are located within `app/src/main/res/values-it/strings.xml`
33+
- Spanish translation files are located within `app/src/main/res/values-es/strings.xml`
34+
1. If you notice anything which could be improved, you should create a PR containing the improved language suggestions.
35+
1. Make the changes to the relevant `strings.xml` file
3936
1. Test the app in the language you've improved, and ensure the changed strings look good
40-
1. Push the changes to your fork `git push origin`
41-
1. Create a Pull Request for your changes. [Instructions](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork)
42-
- Ensure the base branch in your PR is `feature/app_translations`
43-
37+
1. Create a PR. As well as the changes themselves, explaining _why_ the changes are an improvement helps a lot.
38+
4439

4540
ℹ️ Please note we are not looking for help with other languages at this time; only the languages listed above. We may open up requests in future for additional languages.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class BrowserTabViewModelTest {
218218
testee.command.observeForever(mockCommandObserver)
219219

220220
whenever(mockOmnibarConverter.convertQueryToUrl(any())).thenReturn("duckduckgo.com")
221-
whenever(mockVariantManager.getVariant()).thenReturn(VariantManager.DEFAULT_VARIANT)
221+
whenever(mockVariantManager.getVariant()).thenReturn(DEFAULT_VARIANT)
222222
}
223223

224224
@After
@@ -481,7 +481,9 @@ class BrowserTabViewModelTest {
481481

482482
@Test
483483
fun whenProgressChangesToFinishedAndImprovedTabUxVariantActiveThenWebViewPreviewGenerated() {
484-
whenever(mockVariantManager.getVariant()).thenReturn(Variant("mx", 1.0, listOf(VariantManager.VariantFeature.TabSwitcherGrid)))
484+
whenever(mockVariantManager.getVariant()).thenReturn(
485+
Variant("mx", 1.0, listOf(VariantManager.VariantFeature.TabSwitcherGrid), filterBy = { true })
486+
)
485487
updateUrl("https://example.com", "https://example.com", true)
486488
testee.progressChanged(100)
487489
val command = captureCommands().lastValue as Command.GenerateWebViewPreviewImage
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2019 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.browser.defaultbrowsing
18+
19+
import com.duckduckgo.app.global.install.AppInstallStore
20+
import com.duckduckgo.app.statistics.pixels.Pixel
21+
import com.nhaarman.mockitokotlin2.any
22+
import com.nhaarman.mockitokotlin2.eq
23+
import com.nhaarman.mockitokotlin2.never
24+
import com.nhaarman.mockitokotlin2.verify
25+
import com.nhaarman.mockitokotlin2.whenever
26+
import org.junit.Test
27+
import org.junit.Before
28+
import org.mockito.Mock
29+
import org.mockito.MockitoAnnotations
30+
31+
class DefaultBrowserObserverTest {
32+
33+
private lateinit var testee: DefaultBrowserObserver
34+
35+
@Mock
36+
private lateinit var mockDefaultBrowserDetector: DefaultBrowserDetector
37+
38+
@Mock
39+
private lateinit var mockAppInstallStore: AppInstallStore
40+
41+
@Mock
42+
private lateinit var mockPixel: Pixel
43+
44+
@Before
45+
fun setup() {
46+
MockitoAnnotations.initMocks(this)
47+
testee = DefaultBrowserObserver(mockDefaultBrowserDetector, mockAppInstallStore, mockPixel)
48+
}
49+
50+
@Test
51+
fun whenDDGIsDefaultBrowserIfItWasNotBeforeThenFireSetPixel() {
52+
whenever(mockDefaultBrowserDetector.isDefaultBrowser()).thenReturn(true)
53+
whenever(mockAppInstallStore.defaultBrowser).thenReturn(false)
54+
val params = mapOf(
55+
Pixel.PixelParameter.DEFAULT_BROWSER_SET_FROM_ONBOARDING to false.toString()
56+
)
57+
58+
testee.onApplicationResumed()
59+
60+
verify(mockPixel).fire(Pixel.PixelName.DEFAULT_BROWSER_SET, params)
61+
}
62+
63+
@Test
64+
fun whenDDGIsNotDefaultBrowserIfItWasNotBeforeThenDoNotFireSetPixel() {
65+
whenever(mockDefaultBrowserDetector.isDefaultBrowser()).thenReturn(false)
66+
whenever(mockAppInstallStore.defaultBrowser).thenReturn(false)
67+
68+
testee.onApplicationResumed()
69+
70+
verify(mockPixel, never()).fire(eq(Pixel.PixelName.DEFAULT_BROWSER_SET), any())
71+
}
72+
73+
@Test
74+
fun whenDDGIsDefaultBrowserIfItWasBeforeThenDoNotFireSetPixel() {
75+
whenever(mockDefaultBrowserDetector.isDefaultBrowser()).thenReturn(true)
76+
whenever(mockAppInstallStore.defaultBrowser).thenReturn(true)
77+
78+
testee.onApplicationResumed()
79+
80+
verify(mockPixel, never()).fire(eq(Pixel.PixelName.DEFAULT_BROWSER_SET), any())
81+
}
82+
83+
@Test
84+
fun whenDDGIsNotDefaultBrowserIfItWasBeforeThenFireUnsetPixel() {
85+
whenever(mockDefaultBrowserDetector.isDefaultBrowser()).thenReturn(false)
86+
whenever(mockAppInstallStore.defaultBrowser).thenReturn(true)
87+
88+
testee.onApplicationResumed()
89+
90+
verify(mockPixel).fire(Pixel.PixelName.DEFAULT_BROWSER_UNSET)
91+
}
92+
}

app/src/androidTest/java/com/duckduckgo/app/global/ChecksumTest.kt renamed to app/src/androidTest/java/com/duckduckgo/app/global/HashUtilitiesTest.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,34 @@ package com.duckduckgo.app.global
1919
import org.junit.Assert.*
2020
import org.junit.Test
2121

22-
class ChecksumTest {
22+
class HashUtilitiesTest {
2323

2424
@Test
25-
fun whenSha256ChecksumCalledThenChecksumIsCorrect() {
25+
fun whenSha1HashCalledOnStringThenResultIsCorrect() {
26+
val result = helloWorldText.sha1
27+
assertEquals(helloWorldSha1, result)
28+
}
29+
30+
@Test
31+
fun whenSha256HashCalledOnBytesThenResultIsCorrect() {
2632
val result = helloWorldText.toByteArray().sha256
2733
assertEquals(helloWorldSha256, result)
2834
}
2935

3036
@Test
31-
fun whenSha256CheckumCorrectThenVerifyIsTrue() {
37+
fun whenCorrectSha256HashUsedThenVerifyIsTrue() {
3238
assertTrue(helloWorldText.toByteArray().verifySha256(helloWorldSha256))
3339
}
3440

3541
@Test
36-
fun whenSha256CheckumIncorrectThenVerifyIsFalse() {
42+
fun whenIncorrectByteSha256HashUsedThenVerifyIsFalse() {
3743
assertFalse(helloWorldText.toByteArray().verifySha256(otherSha256))
3844
}
3945

4046
companion object {
4147
const val helloWorldText = "Hello World!"
4248
const val helloWorldSha256 = "7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"
49+
const val helloWorldSha1 = "2ef7bde608ce5404e97d5f042f95f89f1c232871"
4350
const val otherSha256 = "f97e9da0e3b879f0a9df979ae260a5f7e1371edb127c1862d4f861981166cdc1"
4451
}
4552
}

app/src/androidTest/java/com/duckduckgo/app/httpsupgrade/HttpsUpgraderTest.kt

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,105 @@ package com.duckduckgo.app.httpsupgrade
1818

1919
import android.net.Uri
2020
import com.duckduckgo.app.httpsupgrade.api.HttpsBloomFilterFactory
21+
import com.duckduckgo.app.httpsupgrade.api.HttpsUpgradeService
2122
import com.duckduckgo.app.httpsupgrade.db.HttpsWhitelistDao
23+
import com.duckduckgo.app.statistics.pixels.Pixel
24+
import com.nhaarman.mockitokotlin2.any
2225
import com.nhaarman.mockitokotlin2.mock
2326
import com.nhaarman.mockitokotlin2.whenever
27+
import okhttp3.ResponseBody
2428
import org.junit.Assert.assertFalse
2529
import org.junit.Assert.assertTrue
2630
import org.junit.Before
2731
import org.junit.Test
32+
import retrofit2.Call
33+
import retrofit2.Response
2834

2935
class HttpsUpgraderTest {
3036

3137
lateinit var testee: HttpsUpgrader
3238

3339
private var mockHttpsBloomFilterFactory: HttpsBloomFilterFactory = mock()
3440
private var mockWhitelistDao: HttpsWhitelistDao = mock()
41+
private var mockUpgradeService: HttpsUpgradeService = mock()
42+
private var mockServiceCall: Call<List<String>> = mock()
43+
44+
private var mockPixel: Pixel = mock()
3545
private var bloomFilter = BloomFilter(100, 0.01)
3646

3747
@Before
3848
fun before() {
3949
whenever(mockHttpsBloomFilterFactory.create()).thenReturn(bloomFilter)
40-
testee = HttpsUpgraderImpl(mockWhitelistDao, mockHttpsBloomFilterFactory)
50+
testee = HttpsUpgraderImpl(mockWhitelistDao, mockHttpsBloomFilterFactory, mockUpgradeService, mockPixel)
4151
testee.reloadData()
4252
}
4353

4454
@Test
45-
fun whenUriIsHttpsThenShouldNotUpgrade() {
46-
assertFalse(testee.shouldUpgrade(Uri.parse("https://www.example.com")))
55+
fun whenHttpUriIsInLocalListThenShouldUpgrade() {
56+
bloomFilter.add("www.local.url")
57+
assertTrue(testee.shouldUpgrade(Uri.parse("http://www.local.url")))
58+
}
59+
60+
@Test
61+
fun whenHttpsUriThenShouldNotUpgrade() {
62+
assertFalse(testee.shouldUpgrade(Uri.parse("https://www.local.url")))
63+
}
64+
65+
@Test
66+
fun whenHttpUriHasOnlyPartDomainInLocalListThenShouldNotUpgrade() {
67+
bloomFilter.add("local.url")
68+
assertFalse(testee.shouldUpgrade(Uri.parse("http://www.local.url")))
4769
}
4870

4971
@Test
50-
fun whenHttpUriIsNotInBloomFilterThenShouldNotUpgrade() {
51-
assertFalse(testee.shouldUpgrade(Uri.parse("http://www.example.com")))
72+
fun whenHttpUriIsInLocalListAndInWhitelistThenShouldNotUpgrade() {
73+
bloomFilter.add("www.local.url")
74+
whenever(mockWhitelistDao.contains("www.local.url")).thenReturn(true)
75+
assertFalse(testee.shouldUpgrade(Uri.parse("http://www.local.url")))
5276
}
5377

5478
@Test
55-
fun whenHttpUriIsInBloomFilterThenShouldUpgrade() {
56-
bloomFilter.add("www.example.com")
57-
assertTrue(testee.shouldUpgrade(Uri.parse("http://www.example.com")))
79+
fun whenHttpUriIsNotInLocalListButCanBeUpgradedByServiceThenShouldUpgrade() {
80+
whenever(mockServiceCall.execute()).thenReturn(Response.success(serviceResponse()))
81+
whenever(mockUpgradeService.upgradeListForPartialHost(any())).thenReturn(mockServiceCall)
82+
assertTrue(testee.shouldUpgrade(Uri.parse("http://service.url")))
5883
}
5984

6085
@Test
61-
fun whenHttpUriHasOnlyPartDomainInBloomFilterThenShouldNotUpgrade() {
62-
bloomFilter.add("example.com")
63-
assertFalse(testee.shouldUpgrade(Uri.parse("http://www.example.com")))
86+
fun whenHttpUriIsNotInLocalListAndCannotBeUpgradedByServiceThenShouldNotUpgrade() {
87+
whenever(mockServiceCall.execute()).thenReturn(Response.success(serviceResponse()))
88+
whenever(mockUpgradeService.upgradeListForPartialHost(any())).thenReturn(mockServiceCall)
89+
assertFalse(testee.shouldUpgrade(Uri.parse("http://unknown.com")))
6490
}
6591

6692
@Test
67-
fun whenHttpUriIsInBloomFilterAndInWhitelistThenShouldNotUpgrade() {
68-
bloomFilter.add("www.example.com")
69-
whenever(mockWhitelistDao.contains("www.example.com")).thenReturn(true)
70-
assertFalse(testee.shouldUpgrade(Uri.parse("http://www.example.com")))
93+
fun whenHttpUriIsNotInLocalListAndServiceRequestFailsThenShouldNotUpgrade() {
94+
whenever(mockServiceCall.execute()).thenReturn(Response.error(500, ResponseBody.create(null, "")))
95+
whenever(mockUpgradeService.upgradeListForPartialHost(any())).thenReturn(mockServiceCall)
96+
assertFalse(testee.shouldUpgrade(Uri.parse("http://service.url")))
7197
}
7298

99+
@Test
100+
fun whenBloomFilterIsNotLoadedAndUrlIsInServiceListThenShouldUpgrade() {
101+
whenever(mockHttpsBloomFilterFactory.create()).thenReturn(null)
102+
whenever(mockServiceCall.execute()).thenReturn(Response.success(serviceResponse()))
103+
whenever(mockUpgradeService.upgradeListForPartialHost(any())).thenReturn(mockServiceCall)
104+
assertTrue(testee.shouldUpgrade(Uri.parse("http://service.url")))
105+
}
106+
107+
@Test
108+
fun testWhenBloomFilterIsNotLoadedAndUrlNotInServiceListThenShouldNotUpgrade() {
109+
whenever(mockHttpsBloomFilterFactory.create()).thenReturn(null)
110+
whenever(mockServiceCall.execute()).thenReturn(Response.success(serviceResponse()))
111+
whenever(mockUpgradeService.upgradeListForPartialHost(any())).thenReturn(mockServiceCall)
112+
assertFalse(testee.shouldUpgrade(Uri.parse("http://unknown.com")))
113+
}
114+
115+
private fun serviceResponse(): List<String> {
116+
return arrayListOf(
117+
"cfb1a171724ad0b8f108526d6a201667f74691e4",
118+
"cfb10e3da9ae3bc2ba7e4641c911987da63aa0a7",
119+
"cfb18efe21acd63556dd75bcae7003a2fff90752"
120+
)
121+
}
73122
}

app/src/androidTest/java/com/duckduckgo/app/httpsupgrade/db/HttpsWhitelistDaoTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class HttpsWhitelistDaoTest {
8686
}
8787

8888
@Test
89-
fun whenhAllDeletedThenContainsDomainIsFalse() {
89+
fun whenAllDeletedThenContainsDomainIsFalse() {
9090
dao.insertAll(listOf(HttpsWhitelistedDomain(domain)))
9191
dao.deleteAll()
9292
assertFalse(dao.contains(domain))

app/src/androidTest/java/com/duckduckgo/app/integration/AtbIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AtbIntegrationTest {
5757
statisticsStore = StatisticsSharedPreferences(InstrumentationRegistry.getInstrumentation().targetContext)
5858
statisticsStore.clearAtb()
5959

60-
whenever(mockVariantManager.getVariant()).thenReturn(Variant("ma", 100.0))
60+
whenever(mockVariantManager.getVariant()).thenReturn(Variant("ma", 100.0, filterBy = { true }))
6161
service = getDaggerComponent().retrofit().create(StatisticsService::class.java)
6262
testee = StatisticsRequester(statisticsStore, service, mockVariantManager)
6363
}

app/src/androidTest/java/com/duckduckgo/app/onboarding/ui/OnboardingPageManagerPageCountTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.duckduckgo.app.onboarding.ui
1818

1919
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
20+
import com.duckduckgo.app.statistics.VariantManager
2021
import com.nhaarman.mockitokotlin2.mock
2122
import com.nhaarman.mockitokotlin2.whenever
2223
import org.junit.Assert.assertEquals
@@ -31,10 +32,11 @@ class OnboardingPageManagerPageCountTest(private val testCase: TestCase) {
3132
private lateinit var testee: OnboardingPageManager
3233
private val onboardingPageBuilder: OnboardingPageBuilder = mock()
3334
private val mockDefaultBrowserDetector: DefaultBrowserDetector = mock()
35+
private val mockVariantManager: VariantManager = mock()
3436

3537
@Before
3638
fun setup() {
37-
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector)
39+
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector, mockVariantManager)
3840
}
3941

4042
@Test

app/src/androidTest/java/com/duckduckgo/app/onboarding/ui/OnboardingPageManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class OnboardingPageManagerTest {
3434

3535
@Before
3636
fun setup() {
37-
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector)
37+
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector, variantManager)
3838
}
3939

4040
@Test

0 commit comments

Comments
 (0)