Skip to content

Commit

Permalink
Bug 1506658 - Add @nullable or @nonnull to all APIs. r=snorp,rbarker,…
Browse files Browse the repository at this point in the history
…geckoview-reviewers

Upgrading apilint to the 0.1.6 release will also ensure that new APIs have
nullability annotations via the GV4 and GV5 lints, see [0].

[0]: mozilla-mobile/gradle-apilint@b994c7c#diff-2c7de691a2642510f69b9ddf59276d85R569

Differential Revision: https://phabricator.services.mozilla.com/D14896

--HG--
extra : moz-landing-system : lando
  • Loading branch information
agi committed Dec 20, 2018
1 parent ae847e2 commit cffe966
Show file tree
Hide file tree
Showing 30 changed files with 604 additions and 571 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ buildscript {
}

dependencies {
classpath 'org.mozilla.apilint:apilint:0.1.5'
classpath 'org.mozilla.apilint:apilint:0.1.6'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath 'org.apache.commons:commons-exec:1.3'
Expand Down
635 changes: 289 additions & 346 deletions mobile/android/geckoview/api.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ContentDelegateTest : BaseSessionTest() {

sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 2)
override fun onTitleChange(session: GeckoSession, title: String) {
override fun onTitleChange(session: GeckoSession, title: String?) {
assertThat("Title should match", title,
equalTo(forEachCall("Title1", "Title2")))
}
Expand Down Expand Up @@ -187,7 +187,7 @@ class ContentDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
@AssertCalled
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URI should match", url, equalTo(startUri))
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
@NullDelegate(GeckoSession.NavigationDelegate::class)
fun delegateDuringNextWait_throwOnNullDelegate() {
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
}
})
}
Expand Down Expand Up @@ -1337,7 +1337,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
@Test(expected = UiThreadUtils.TimeoutException::class)
fun evaluateJS_canTimeout() {
sessionRule.session.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
override fun onAlert(session: GeckoSession, title: String, msg: String, callback: GeckoSession.PromptDelegate.AlertCallback) {
override fun onAlert(session: GeckoSession, title: String?, msg: String?,
callback: GeckoSession.PromptDelegate.AlertCallback) {
// Do nothing for the alert, so it hangs forever.
}
})
Expand Down Expand Up @@ -1494,7 +1495,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {

sessionRule.session.forCallbacksDuringWait(object : Callbacks.PromptDelegate {
@AssertCalled(count = 1)
override fun onAlert(session: GeckoSession, title: String, msg: String, callback: GeckoSession.PromptDelegate.AlertCallback) {
override fun onAlert(session: GeckoSession, title: String?, msg: String?,
callback: GeckoSession.PromptDelegate.AlertCallback) {
}
})
}
Expand All @@ -1510,7 +1512,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
@Test fun waitForJS_delegateDuringWait() {
var count = 0
sessionRule.session.delegateDuringNextWait(object : Callbacks.PromptDelegate {
override fun onAlert(session: GeckoSession, title: String, msg: String, callback: GeckoSession.PromptDelegate.AlertCallback) {
override fun onAlert(session: GeckoSession, title: String?, msg: String?,
callback: GeckoSession.PromptDelegate.AlertCallback) {
count++
callback.dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.junit.runner.RunWith
class LocaleTest : BaseSessionTest() {

@Test fun setLocale() {
sessionRule.runtime.getSettings().setLocales(arrayOf("en-GB"));
sessionRule.runtime.getSettings()!!.setLocales(arrayOf("en-GB"));

val index = sessionRule.waitForChromeJS(String.format(
"(function() {" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ class NavigationDelegateTest : BaseSessionTest() {
if (errorPageUrl != null) {
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
@AssertCalled(count = 1, order = [1])
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, equalTo(testUri))
}

@AssertCalled(count = 1, order = [2])
override fun onTitleChange(session: GeckoSession, title: String) {
override fun onTitleChange(session: GeckoSession, title: String?) {
assertThat("Title should not be empty", title, not(isEmptyOrNullString()))
}
})
Expand Down Expand Up @@ -123,7 +123,7 @@ class NavigationDelegateTest : BaseSessionTest() {
if (errorPageUrl != null) {
sessionRule.waitUntilCalled(object: Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onTitleChange(session: GeckoSession, title: String) {
override fun onTitleChange(session: GeckoSession, title: String?) {
assertThat("Title should not be empty", title, not(isEmptyOrNullString()));
}
})
Expand Down Expand Up @@ -174,13 +174,13 @@ class NavigationDelegateTest : BaseSessionTest() {
@Setting(key = Setting.Key.USE_TRACKING_PROTECTION, value = "true")
@Test fun trackingProtection() {
val category = TrackingProtectionDelegate.CATEGORY_TEST;
sessionRule.runtime.settings.trackingProtectionCategories = category
sessionRule.runtime.settings!!.trackingProtectionCategories = category
sessionRule.session.loadTestPath(TRACKERS_PATH)

sessionRule.waitUntilCalled(
object : Callbacks.TrackingProtectionDelegate {
@AssertCalled(count = 3)
override fun onTrackerBlocked(session: GeckoSession, uri: String,
override fun onTrackerBlocked(session: GeckoSession, uri: String?,
categories: Int) {
assertThat("Category should be set",
categories,
Expand All @@ -199,7 +199,7 @@ class NavigationDelegateTest : BaseSessionTest() {
sessionRule.forCallbacksDuringWait(
object : Callbacks.TrackingProtectionDelegate {
@AssertCalled(false)
override fun onTrackerBlocked(session: GeckoSession, uri: String,
override fun onTrackerBlocked(session: GeckoSession, uri: String?,
categories: Int) {
}
})
Expand Down Expand Up @@ -244,7 +244,7 @@ class NavigationDelegateTest : BaseSessionTest() {
@Test fun bypassClassifier() {
val phishingUri = "https://www.itisatrap.org/firefox/its-a-trap.html"

sessionRule.runtime.settings.blockPhishing = true
sessionRule.runtime.settings!!.blockPhishing = true

sessionRule.session.loadUri(phishingUri + "?bypass=true",
GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)
Expand All @@ -263,14 +263,14 @@ class NavigationDelegateTest : BaseSessionTest() {
@Test fun safebrowsingPhishing() {
val phishingUri = "https://www.itisatrap.org/firefox/its-a-trap.html"

sessionRule.runtime.settings.blockPhishing = true
sessionRule.runtime.settings!!.blockPhishing = true

// Add query string to avoid bypassing classifier check because of cache.
testLoadExpectError(phishingUri + "?block=true",
WebRequestError.ERROR_CATEGORY_SAFEBROWSING,
WebRequestError.ERROR_SAFEBROWSING_PHISHING_URI)

sessionRule.runtime.settings.blockPhishing = false
sessionRule.runtime.settings!!.blockPhishing = false

sessionRule.session.loadUri(phishingUri + "?block=false")
sessionRule.session.waitForPageStop()
Expand All @@ -288,13 +288,13 @@ class NavigationDelegateTest : BaseSessionTest() {
@Test fun safebrowsingMalware() {
val malwareUri = "https://www.itisatrap.org/firefox/its-an-attack.html"

sessionRule.runtime.settings.blockMalware = true
sessionRule.runtime.settings!!.blockMalware = true

testLoadExpectError(malwareUri + "?block=true",
WebRequestError.ERROR_CATEGORY_SAFEBROWSING,
WebRequestError.ERROR_SAFEBROWSING_MALWARE_URI)

sessionRule.runtime.settings.blockMalware = false
sessionRule.runtime.settings!!.blockMalware = false

sessionRule.session.loadUri(malwareUri + "?block=false")
sessionRule.session.waitForPageStop()
Expand All @@ -312,13 +312,13 @@ class NavigationDelegateTest : BaseSessionTest() {
@Test fun safebrowsingUnwanted() {
val unwantedUri = "https://www.itisatrap.org/firefox/unwanted.html"

sessionRule.runtime.settings.blockMalware = true
sessionRule.runtime.settings!!.blockMalware = true

testLoadExpectError(unwantedUri + "?block=true",
WebRequestError.ERROR_CATEGORY_SAFEBROWSING,
WebRequestError.ERROR_SAFEBROWSING_UNWANTED_URI)

sessionRule.runtime.settings.blockMalware = false
sessionRule.runtime.settings!!.blockMalware = false

sessionRule.session.loadUri(unwantedUri + "?block=false")
sessionRule.session.waitForPageStop()
Expand All @@ -336,13 +336,13 @@ class NavigationDelegateTest : BaseSessionTest() {
@Test fun safebrowsingHarmful() {
val harmfulUri = "https://www.itisatrap.org/firefox/harmful.html"

sessionRule.runtime.settings.blockMalware = true
sessionRule.runtime.settings!!.blockMalware = true

testLoadExpectError(harmfulUri + "?block=true",
WebRequestError.ERROR_CATEGORY_SAFEBROWSING,
WebRequestError.ERROR_SAFEBROWSING_HARMFUL_URI)

sessionRule.runtime.settings.blockMalware = false
sessionRule.runtime.settings!!.blockMalware = false

sessionRule.session.loadUri(harmfulUri + "?block=false")
sessionRule.session.waitForPageStop()
Expand Down Expand Up @@ -529,7 +529,7 @@ class NavigationDelegateTest : BaseSessionTest() {
}

@AssertCalled(count = 1, order = [2])
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("Session should not be null", session, notNullValue())
assertThat("URL should not be null", url, notNullValue())
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
Expand Down Expand Up @@ -561,7 +561,7 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match the provided data URL", url, equalTo(dataUrl))
}

Expand All @@ -587,7 +587,7 @@ class NavigationDelegateTest : BaseSessionTest() {
// Test that if we unset the navigation delegate during a load, the load still proceeds.
var onLocationCount = 0
sessionRule.session.navigationDelegate = object : Callbacks.NavigationDelegate {
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
onLocationCount++
}
}
Expand All @@ -613,12 +613,12 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate, Callbacks.ContentDelegate {
@AssertCalled
override fun onTitleChange(session: GeckoSession, title: String) {
override fun onTitleChange(session: GeckoSession, title: String?) {
assertThat("Title should match", title, equalTo("TheTitle"));
}

@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should be a data URL", url,
equalTo(GeckoSession.createDataUri(dataString, mimeType)))
}
Expand All @@ -636,7 +636,7 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should be a data URL", url, startsWith("data:"))
}

Expand All @@ -656,12 +656,12 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate, Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onTitleChange(session: GeckoSession, title: String) {
override fun onTitleChange(session: GeckoSession, title: String?) {
assertThat("Title should match", title, equalTo("Hello, world!"))
}

@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, equalTo(GeckoSession.createDataUri(bytes, "text/html")))
}

Expand All @@ -681,7 +681,7 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, equalTo(GeckoSession.createDataUri(bytes, mimeType)))
}

Expand Down Expand Up @@ -722,7 +722,7 @@ class NavigationDelegateTest : BaseSessionTest() {
}

@AssertCalled(count = 1, order = [2])
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
}

Expand Down Expand Up @@ -752,7 +752,7 @@ class NavigationDelegateTest : BaseSessionTest() {

sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
@AssertCalled(count = 1)
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
}
})
Expand All @@ -774,7 +774,7 @@ class NavigationDelegateTest : BaseSessionTest() {
}

@AssertCalled(count = 1, order = [2])
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
}

Expand Down Expand Up @@ -811,7 +811,7 @@ class NavigationDelegateTest : BaseSessionTest() {
}

@AssertCalled(count = 1, order = [2])
override fun onLocationChange(session: GeckoSession, url: String) {
override fun onLocationChange(session: GeckoSession, url: String?) {
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
}

Expand Down
Loading

0 comments on commit cffe966

Please sign in to comment.