Skip to content

Commit 03ada31

Browse files
committed
Merge branch 'release/5.41.0'
2 parents c6d746a + 0cc60ee commit 03ada31

30 files changed

+557
-266
lines changed

Gemfile.lock

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.1)
4+
CFPropertyList (3.0.2)
55
addressable (2.7.0)
66
public_suffix (>= 2.0.2, < 5.0)
77
atomos (0.1.3)
@@ -18,16 +18,16 @@ GEM
1818
unf (>= 0.0.5, < 1.0.0)
1919
dotenv (2.7.5)
2020
emoji_regex (1.0.1)
21-
excon (0.67.0)
22-
faraday (0.17.0)
21+
excon (0.71.1)
22+
faraday (0.17.3)
2323
multipart-post (>= 1.2, < 3)
2424
faraday-cookie_jar (0.0.6)
2525
faraday (>= 0.7.4)
2626
http-cookie (~> 1.0.0)
2727
faraday_middleware (0.13.1)
2828
faraday (>= 0.7.4, < 1.0)
2929
fastimage (2.1.7)
30-
fastlane (2.134.0)
30+
fastlane (2.139.0)
3131
CFPropertyList (>= 2.3, < 4.0.0)
3232
addressable (>= 2.3, < 3.0.0)
3333
babosa (>= 1.0.2, < 2.0.0)
@@ -36,13 +36,13 @@ GEM
3636
commander-fastlane (>= 4.4.6, < 5.0.0)
3737
dotenv (>= 2.1.1, < 3.0.0)
3838
emoji_regex (>= 0.1, < 2.0)
39-
excon (>= 0.45.0, < 1.0.0)
39+
excon (>= 0.71.0, < 1.0.0)
4040
faraday (~> 0.17)
4141
faraday-cookie_jar (~> 0.0.6)
4242
faraday_middleware (~> 0.13.1)
4343
fastimage (>= 2.1.0, < 3.0.0)
4444
gh_inspector (>= 1.1.2, < 2.0.0)
45-
google-api-client (>= 0.21.2, < 0.24.0)
45+
google-api-client (>= 0.29.2, < 0.37.0)
4646
google-cloud-storage (>= 1.15.0, < 2.0.0)
4747
highline (>= 1.7.2, < 2.0.0)
4848
json (< 3.0.0)
@@ -61,46 +61,46 @@ GEM
6161
tty-screen (>= 0.6.3, < 1.0.0)
6262
tty-spinner (>= 0.8.0, < 1.0.0)
6363
word_wrap (~> 1.0.0)
64-
xcodeproj (>= 1.8.1, < 2.0.0)
64+
xcodeproj (>= 1.13.0, < 2.0.0)
6565
xcpretty (~> 0.3.0)
6666
xcpretty-travis-formatter (>= 0.0.3)
6767
fastlane-plugin-property_file_read (1.0.1)
6868
gh_inspector (1.1.3)
69-
google-api-client (0.23.9)
69+
google-api-client (0.36.4)
7070
addressable (~> 2.5, >= 2.5.1)
71-
googleauth (>= 0.5, < 0.7.0)
71+
googleauth (~> 0.9)
7272
httpclient (>= 2.8.1, < 3.0)
73-
mime-types (~> 3.0)
73+
mini_mime (~> 1.0)
7474
representable (~> 3.0)
7575
retriable (>= 2.0, < 4.0)
76-
signet (~> 0.9)
77-
google-cloud-core (1.3.2)
76+
signet (~> 0.12)
77+
google-cloud-core (1.4.1)
7878
google-cloud-env (~> 1.0)
79-
google-cloud-env (1.2.1)
79+
google-cloud-env (1.3.0)
8080
faraday (~> 0.11)
81-
google-cloud-storage (1.16.0)
81+
google-cloud-storage (1.25.0)
82+
addressable (~> 2.5)
8283
digest-crc (~> 0.4)
83-
google-api-client (~> 0.23)
84+
google-api-client (~> 0.33)
8485
google-cloud-core (~> 1.2)
85-
googleauth (>= 0.6.2, < 0.10.0)
86-
googleauth (0.6.7)
86+
googleauth (~> 0.9)
87+
mini_mime (~> 1.0)
88+
googleauth (0.10.0)
8789
faraday (~> 0.12)
8890
jwt (>= 1.4, < 3.0)
8991
memoist (~> 0.16)
9092
multi_json (~> 1.11)
9193
os (>= 0.9, < 2.0)
92-
signet (~> 0.7)
94+
signet (~> 0.12)
9395
highline (1.7.10)
9496
http-cookie (1.0.3)
9597
domain_name (~> 0.5)
9698
httpclient (2.8.3)
97-
json (2.2.0)
99+
json (2.3.0)
98100
jwt (2.1.0)
99-
memoist (0.16.0)
100-
mime-types (3.3)
101-
mime-types-data (~> 3.2015)
102-
mime-types-data (3.2019.1009)
103-
mini_magick (4.9.5)
101+
memoist (0.16.2)
102+
mini_magick (4.10.1)
103+
mini_mime (1.0.2)
104104
multi_json (1.14.1)
105105
multi_xml (0.6.0)
106106
multipart-post (2.0.0)
@@ -122,7 +122,7 @@ GEM
122122
faraday (~> 0.9)
123123
jwt (>= 1.5, < 3.0)
124124
multi_json (~> 1.10)
125-
simctl (1.6.6)
125+
simctl (1.6.7)
126126
CFPropertyList
127127
naturally
128128
slack-notifier (2.3.2)
@@ -131,15 +131,15 @@ GEM
131131
unicode-display_width (~> 1.1, >= 1.1.1)
132132
tty-cursor (0.7.0)
133133
tty-screen (0.7.0)
134-
tty-spinner (0.9.1)
134+
tty-spinner (0.9.2)
135135
tty-cursor (~> 0.7)
136136
uber (0.1.0)
137137
unf (0.1.4)
138138
unf_ext
139139
unf_ext (0.0.7.6)
140140
unicode-display_width (1.6.0)
141141
word_wrap (1.0.0)
142-
xcodeproj (1.13.0)
142+
xcodeproj (1.14.0)
143143
CFPropertyList (>= 2.3.3, < 4.0)
144144
atomos (~> 0.1.3)
145145
claide (>= 1.0.2, < 2.0)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2020 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
18+
19+
import androidx.lifecycle.Observer
20+
21+
/**
22+
* Concrete class of Observer<T> to validate if any value has been received when observing a LiveData
23+
*
24+
* @param skipFirst: skip first value emitted by LiveData stream.
25+
* SkipFirst is usually:
26+
* Set to False to observe a SingleLiveEvent or any LiveData that starts emitting after subscription.
27+
* Set to True when observing any LiveData that emits its lastValue on subscription.
28+
*/
29+
class ValueCaptorObserver<T>(private var skipFirst: Boolean = true) : Observer<T> {
30+
var hasReceivedValue = false
31+
private set
32+
33+
var lastValueReceived: T? = null
34+
private set
35+
36+
override fun onChanged(t: T) {
37+
if (skipFirst) {
38+
skipFirst = false
39+
return
40+
}
41+
lastValueReceived = t
42+
hasReceivedValue = true
43+
}
44+
}

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919
package com.duckduckgo.app.browser
2020

2121
import android.content.Context
22+
import android.os.Message
2223
import android.view.View
2324
import android.webkit.WebChromeClient
2425
import android.webkit.WebView
2526
import androidx.test.annotation.UiThreadTest
2627
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
2728
import com.duckduckgo.app.global.exception.UncaughtExceptionRepository
28-
import com.nhaarman.mockitokotlin2.any
29-
import com.nhaarman.mockitokotlin2.mock
30-
import com.nhaarman.mockitokotlin2.times
31-
import com.nhaarman.mockitokotlin2.verify
29+
import com.nhaarman.mockitokotlin2.*
3230
import org.junit.Before
3331
import org.junit.Test
3432

@@ -93,5 +91,25 @@ class BrowserChromeClientTest {
9391
verify(mockWebViewClientListener).navigationStateChanged(any())
9492
}
9593

94+
@UiThreadTest
95+
@Test
96+
fun whenOnCreateWindowWithUserGestureThenMessageOpenedInNewTab() {
97+
testee.onCreateWindow(webView, isDialog = false, isUserGesture = true, resultMsg = mockMsg)
98+
verify(mockWebViewClientListener).openMessageInNewTab(eq(mockMsg))
99+
verifyNoMoreInteractions(mockWebViewClientListener)
100+
}
101+
102+
@UiThreadTest
103+
@Test
104+
fun whenOnCreateWindowWithoutUserGestureThenNewTabNotOpened() {
105+
testee.onCreateWindow(webView, isDialog = false, isUserGesture = false, resultMsg = mockMsg)
106+
verifyZeroInteractions(mockWebViewClientListener)
107+
}
108+
109+
private val mockMsg = Message().apply {
110+
target = mock()
111+
obj = mock<WebView.WebViewTransport>()
112+
}
113+
96114
private class TestWebView(context: Context) : WebView(context)
97115
}

0 commit comments

Comments
 (0)