Skip to content

Commit e6cd50a

Browse files
committed
Merge branch 'release/5.11.0'
2 parents da2ea6e + d359013 commit e6cd50a

File tree

177 files changed

+2204
-3794
lines changed

Some content is hidden

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

177 files changed

+2204
-3794
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ captures/
4141

4242
# Keystore files
4343
*.jks
44+
45+
# Fastlane
46+
fastlane/report.xml

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source "https://rubygems.org"
2+
3+
gem "fastlane"
4+
5+
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
6+
eval_gemfile(plugins_path) if File.exist?(plugins_path)

Gemfile.lock

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.0)
5+
addressable (2.5.2)
6+
public_suffix (>= 2.0.2, < 4.0)
7+
atomos (0.1.3)
8+
babosa (1.0.2)
9+
claide (1.0.2)
10+
colored (1.2)
11+
colored2 (3.1.2)
12+
commander-fastlane (4.4.6)
13+
highline (~> 1.7.2)
14+
declarative (0.0.10)
15+
declarative-option (0.1.0)
16+
domain_name (0.5.20180417)
17+
unf (>= 0.0.5, < 1.0.0)
18+
dotenv (2.5.0)
19+
emoji_regex (0.1.1)
20+
excon (0.62.0)
21+
faraday (0.15.3)
22+
multipart-post (>= 1.2, < 3)
23+
faraday-cookie_jar (0.0.6)
24+
faraday (>= 0.7.4)
25+
http-cookie (~> 1.0.0)
26+
faraday_middleware (0.12.2)
27+
faraday (>= 0.7.4, < 1.0)
28+
fastimage (2.1.4)
29+
fastlane (2.104.0)
30+
CFPropertyList (>= 2.3, < 4.0.0)
31+
addressable (>= 2.3, < 3.0.0)
32+
babosa (>= 1.0.2, < 2.0.0)
33+
bundler (>= 1.12.0, < 2.0.0)
34+
colored
35+
commander-fastlane (>= 4.4.6, < 5.0.0)
36+
dotenv (>= 2.1.1, < 3.0.0)
37+
emoji_regex (~> 0.1)
38+
excon (>= 0.45.0, < 1.0.0)
39+
faraday (~> 0.9)
40+
faraday-cookie_jar (~> 0.0.6)
41+
faraday_middleware (~> 0.9)
42+
fastimage (>= 2.1.0, < 3.0.0)
43+
gh_inspector (>= 1.1.2, < 2.0.0)
44+
google-api-client (>= 0.21.2, < 0.24.0)
45+
highline (>= 1.7.2, < 2.0.0)
46+
json (< 3.0.0)
47+
mini_magick (~> 4.5.1)
48+
multi_json
49+
multi_xml (~> 0.5)
50+
multipart-post (~> 2.0.0)
51+
plist (>= 3.1.0, < 4.0.0)
52+
public_suffix (~> 2.0.0)
53+
rubyzip (>= 1.2.2, < 2.0.0)
54+
security (= 0.1.3)
55+
simctl (~> 1.6.3)
56+
slack-notifier (>= 2.0.0, < 3.0.0)
57+
terminal-notifier (>= 1.6.2, < 2.0.0)
58+
terminal-table (>= 1.4.5, < 2.0.0)
59+
tty-screen (>= 0.6.3, < 1.0.0)
60+
tty-spinner (>= 0.8.0, < 1.0.0)
61+
word_wrap (~> 1.0.0)
62+
xcodeproj (>= 1.6.0, < 2.0.0)
63+
xcpretty (~> 0.3.0)
64+
xcpretty-travis-formatter (>= 0.0.3)
65+
fastlane-plugin-property_file_read (1.0.1)
66+
gh_inspector (1.1.3)
67+
google-api-client (0.23.9)
68+
addressable (~> 2.5, >= 2.5.1)
69+
googleauth (>= 0.5, < 0.7.0)
70+
httpclient (>= 2.8.1, < 3.0)
71+
mime-types (~> 3.0)
72+
representable (~> 3.0)
73+
retriable (>= 2.0, < 4.0)
74+
signet (~> 0.9)
75+
googleauth (0.6.6)
76+
faraday (~> 0.12)
77+
jwt (>= 1.4, < 3.0)
78+
memoist (~> 0.12)
79+
multi_json (~> 1.11)
80+
os (>= 0.9, < 2.0)
81+
signet (~> 0.7)
82+
highline (1.7.10)
83+
http-cookie (1.0.3)
84+
domain_name (~> 0.5)
85+
httpclient (2.8.3)
86+
json (2.1.0)
87+
jwt (2.1.0)
88+
memoist (0.16.0)
89+
mime-types (3.2.2)
90+
mime-types-data (~> 3.2015)
91+
mime-types-data (3.2018.0812)
92+
mini_magick (4.5.1)
93+
multi_json (1.13.1)
94+
multi_xml (0.6.0)
95+
multipart-post (2.0.0)
96+
nanaimo (0.2.6)
97+
naturally (2.2.0)
98+
os (1.0.0)
99+
plist (3.4.0)
100+
public_suffix (2.0.5)
101+
representable (3.0.4)
102+
declarative (< 0.1.0)
103+
declarative-option (< 0.2.0)
104+
uber (< 0.2.0)
105+
retriable (3.1.2)
106+
rouge (2.0.7)
107+
rubyzip (1.2.2)
108+
security (0.1.3)
109+
signet (0.9.2)
110+
addressable (~> 2.3)
111+
faraday (~> 0.9)
112+
jwt (>= 1.5, < 3.0)
113+
multi_json (~> 1.10)
114+
simctl (1.6.5)
115+
CFPropertyList
116+
naturally
117+
slack-notifier (2.3.2)
118+
terminal-notifier (1.8.0)
119+
terminal-table (1.8.0)
120+
unicode-display_width (~> 1.1, >= 1.1.1)
121+
tty-cursor (0.6.0)
122+
tty-screen (0.6.5)
123+
tty-spinner (0.8.0)
124+
tty-cursor (>= 0.5.0)
125+
uber (0.1.0)
126+
unf (0.1.4)
127+
unf_ext
128+
unf_ext (0.0.7.5)
129+
unicode-display_width (1.4.0)
130+
word_wrap (1.0.0)
131+
xcodeproj (1.6.0)
132+
CFPropertyList (>= 2.3.3, < 4.0)
133+
atomos (~> 0.1.3)
134+
claide (>= 1.0.2, < 2.0)
135+
colored2 (~> 3.1)
136+
nanaimo (~> 0.2.6)
137+
xcpretty (0.3.0)
138+
rouge (~> 2.0.7)
139+
xcpretty-travis-formatter (1.0.0)
140+
xcpretty (~> 0.2, >= 0.0.7)
141+
142+
PLATFORMS
143+
ruby
144+
145+
DEPENDENCIES
146+
fastlane
147+
fastlane-plugin-property_file_read
148+
149+
BUNDLED WITH
150+
1.16.4

app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ apply plugin: 'kotlin-kapt'
66
apply from: '../versioning.gradle'
77

88
ext {
9-
VERSION_NAME = "5.10.6"
109
USE_ORCHESTRATOR = project.hasProperty('orchestrator') ? project.property('orchestrator') : false
1110
}
1211

@@ -17,7 +16,7 @@ android {
1716
minSdkVersion 21
1817
targetSdkVersion 28
1918
versionCode buildVersionCode()
20-
versionName VERSION_NAME
19+
versionName buildVersionName()
2120
testInstrumentationRunner "com.duckduckgo.app.TestRunner"
2221
archivesBaseName = "duckduckgo-$versionName"
2322

@@ -87,6 +86,7 @@ ext {
8786
glide = "4.6.1"
8887
androidTestRunner = "1.0.2"
8988
lottieVersion = "2.6.0-beta19"
89+
okHttp = "3.10.0"
9090
}
9191

9292

@@ -100,7 +100,7 @@ dependencies {
100100
implementation "com.android.support:appcompat-v7:$supportLibrary"
101101
implementation "com.android.support:design:$supportLibrary"
102102
implementation "com.android.support.constraint:constraint-layout:1.1.0"
103-
implementation "com.squareup.okhttp3:okhttp:3.10.0"
103+
implementation "com.squareup.okhttp3:okhttp:$okHttp"
104104
implementation "com.squareup.retrofit2:retrofit:$retrofit"
105105
implementation "com.squareup.retrofit2:converter-moshi:$retrofit"
106106
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit"
@@ -157,6 +157,7 @@ dependencies {
157157
androidTestUtil "com.android.support.test:orchestrator:1.0.2"
158158
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
159159
androidTestImplementation "org.mockito:mockito-android:2.15.0"
160+
androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okHttp"
160161
androidTestImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
161162

162163
}

app/src/androidTest/java/com/duckduckgo/app/FileUtilities.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
package com.duckduckgo.app
1818

19+
import java.io.BufferedReader
20+
1921
object FileUtilities {
2022

21-
fun loadText(resourceName: String): String =
22-
javaClass.classLoader.getResource(resourceName).openStream().bufferedReader().use { it.readText() }
23+
fun loadText(resourceName: String): String = readResource(resourceName).use { it.readText() }
2324

25+
fun loadLines(resourceName: String): List<String> = readResource(resourceName).use { it.readLines() }
2426

25-
fun loadLines(resourceName: String): List<String> =
26-
javaClass.classLoader.getResource(resourceName).openStream().bufferedReader().use { it.readLines() }
27+
private fun readResource(resourceName: String): BufferedReader {
28+
return javaClass.classLoader!!.getResource(resourceName).openStream().bufferedReader()
29+
}
2730

2831
}

app/src/androidTest/java/com/duckduckgo/app/TestApplication.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class TestApplication : DuckDuckGoApplication() {
2929
*/
3030

3131
override fun configureDependencyInjection() {
32-
DaggerTestAppComponent.builder()
32+
daggerAppComponent = DaggerTestAppComponent.builder()
3333
.application(this)
34-
.create(this)
35-
.inject(this)
34+
.build()
35+
daggerAppComponent.inject(this)
3636
}
3737

3838
// We don't need to actually use leak canary for tests

app/src/androidTest/java/com/duckduckgo/app/TestExtensions.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package com.duckduckgo.app
1818

1919
import android.arch.lifecycle.LiveData
2020
import android.arch.lifecycle.Observer
21+
import android.support.test.InstrumentationRegistry
22+
import com.duckduckgo.app.di.TestAppComponent
2123
import java.util.concurrent.CountDownLatch
2224
import java.util.concurrent.TimeUnit
2325

@@ -32,4 +34,12 @@ fun <T> LiveData<T>.blockingObserve(): T? {
3234
observeForever(innerObserver)
3335
latch.await(2, TimeUnit.SECONDS)
3436
return value
37+
}
38+
39+
fun getApp(): TestApplication {
40+
return InstrumentationRegistry.getTargetContext().applicationContext as TestApplication
41+
}
42+
43+
fun getDaggerComponent(): TestAppComponent {
44+
return getApp().daggerAppComponent as TestAppComponent
3545
}

app/src/androidTest/java/com/duckduckgo/app/browser/WebDataManagerTest.kt renamed to app/src/androidTest/java/com/duckduckgo/app/browser/WebViewDataManagerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ import org.junit.Assert.assertTrue
2929
import org.junit.Test
3030
import org.mockito.ArgumentCaptor
3131

32-
class WebDataManagerTest {
32+
class WebViewDataManagerTest {
3333

3434
private inline fun <reified T : Any> argumentCaptor() = ArgumentCaptor.forClass(T::class.java)
3535

3636
private val mockCookieManager: CookieManager = mock()
3737

3838
private val mockStorage: WebStorage = mock()
3939

40-
private val testee = WebDataManager(host, WebViewSessionInMemoryStorage())
40+
private val testee = WebViewDataManager(host, WebViewSessionInMemoryStorage())
4141

4242
@UiThreadTest
4343
@Test

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

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616

1717
package com.duckduckgo.app.browser
1818

19+
import android.support.test.InstrumentationRegistry
1920
import android.view.ContextMenu
2021
import android.view.MenuItem
2122
import android.webkit.WebView.HitTestResult
2223
import com.duckduckgo.app.statistics.pixels.Pixel
23-
import com.nhaarman.mockito_kotlin.*
24+
import com.nhaarman.mockito_kotlin.eq
25+
import com.nhaarman.mockito_kotlin.never
26+
import com.nhaarman.mockito_kotlin.verify
27+
import com.nhaarman.mockito_kotlin.whenever
2428
import org.junit.Assert.assertEquals
2529
import org.junit.Assert.assertTrue
2630
import org.junit.Before
@@ -46,10 +50,12 @@ class WebViewLongPressHandlerTest {
4650
@Mock
4751
private lateinit var mockPixel: Pixel
4852

53+
private var context = InstrumentationRegistry.getTargetContext()
54+
4955
@Before
5056
fun setup() {
5157
MockitoAnnotations.initMocks(this)
52-
testee = WebViewLongPressHandler(mockPixel)
58+
testee = WebViewLongPressHandler(context, mockPixel)
5359
}
5460

5561
@Test
@@ -71,27 +77,39 @@ class WebViewLongPressHandlerTest {
7177
}
7278

7379
@Test
74-
fun whenLongPressedWithImageTypeThenImageOptionsHeaderAddedToMenu() {
80+
fun whenLongPressedWithImageTypeThenUrlHeaderAddedToMenu() {
7581
testee.handleLongPress(HitTestResult.IMAGE_TYPE, HTTPS_IMAGE_URL, mockMenu)
76-
verify(mockMenu).setHeaderTitle(R.string.imageOptions)
82+
verify(mockMenu).setHeaderTitle(HTTPS_IMAGE_URL)
83+
}
84+
85+
@Test
86+
fun whenLongPressedWithAnchorImageTypeThenUrlHeaderAddedToMenu() {
87+
testee.handleLongPress(HitTestResult.SRC_IMAGE_ANCHOR_TYPE, HTTPS_IMAGE_URL, mockMenu)
88+
verify(mockMenu).setHeaderTitle(HTTPS_IMAGE_URL)
7789
}
7890

7991
@Test
80-
fun whenLongPressedWithAnchorImageTypeThenImageOptionsHeaderAddedToMenu() {
92+
fun whenLongPressedWithAnchorImageTypeThenTabOptionsHeaderAddedToMenu() {
8193
testee.handleLongPress(HitTestResult.SRC_IMAGE_ANCHOR_TYPE, HTTPS_IMAGE_URL, mockMenu)
82-
verify(mockMenu).setHeaderTitle(R.string.imageOptions)
94+
verifyNewForegroundTabItemAdded()
95+
}
96+
97+
@Test
98+
fun whenLongPressedWithAnchorImageTypeThenBgTabOptionsHeaderAddedToMenu() {
99+
testee.handleLongPress(HitTestResult.SRC_IMAGE_ANCHOR_TYPE, HTTPS_IMAGE_URL, mockMenu)
100+
verifyNewBackgroundTabItemAdded()
83101
}
84102

85103
@Test
86104
fun whenLongPressedWithImageTypeThenDownloadImageMenuAdded() {
87105
testee.handleLongPress(HitTestResult.IMAGE_TYPE, HTTPS_IMAGE_URL, mockMenu)
88-
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_DOWNLOAD_IMAGE), anyInt(), eq(R.string.downloadImage))
106+
verifyDownloadImageItemAdded()
89107
}
90108

91109
@Test
92110
fun whenLongPressedWithAnchorImageTypeThenDownloadImageMenuAdded() {
93111
testee.handleLongPress(HitTestResult.SRC_IMAGE_ANCHOR_TYPE, HTTPS_IMAGE_URL, mockMenu)
94-
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_DOWNLOAD_IMAGE), anyInt(), eq(R.string.downloadImage))
112+
verifyDownloadImageItemAdded()
95113
}
96114

97115
@Test
@@ -103,7 +121,7 @@ class WebViewLongPressHandlerTest {
103121
@Test
104122
fun whenLongPressedWithImageTypeWhichIsADataUriThenDownloadImageMenuAdded() {
105123
testee.handleLongPress(HitTestResult.IMAGE_TYPE, DATA_URI_IMAGE_URL, mockMenu)
106-
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_DOWNLOAD_IMAGE), anyInt(), eq(R.string.downloadImage))
124+
verifyDownloadImageItemAdded()
107125
}
108126

109127
@Test
@@ -128,9 +146,19 @@ class WebViewLongPressHandlerTest {
128146
assertTrue(action == LongPressHandler.RequiredAction.None)
129147
}
130148

149+
private fun verifyDownloadImageItemAdded() {
150+
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_DOWNLOAD_IMAGE), anyInt(), eq(R.string.downloadImage))
151+
}
152+
153+
private fun verifyNewForegroundTabItemAdded() {
154+
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_OPEN_IN_NEW_TAB), anyInt(), eq(R.string.openInNewTab))
155+
}
156+
157+
private fun verifyNewBackgroundTabItemAdded() {
158+
verify(mockMenu).add(anyInt(), eq(WebViewLongPressHandler.CONTEXT_MENU_ID_OPEN_IN_NEW_BACKGROUND_TAB), anyInt(), eq(R.string.openInNewBackgroundTab))
159+
}
160+
131161
private fun verifyMenuNotAltered() {
132-
verify(mockMenu, never()).setHeaderTitle(anyString())
133-
verify(mockMenu, never()).setHeaderTitle(anyInt())
134162
verify(mockMenu, never()).add(anyInt())
135163
verify(mockMenu, never()).add(anyString())
136164
verify(mockMenu, never()).add(anyInt(), anyInt(), anyInt(), anyInt())

0 commit comments

Comments
 (0)