Skip to content

Commit

Permalink
For mozilla-mobile#4508: Treats warnings as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Aug 7, 2019
1 parent f9288c7 commit 2626a03
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import kotlinx.coroutines.launch
import mozilla.components.browser.search.SearchEngine
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.intent.EXTRA_SESSION_ID
import mozilla.components.concept.engine.EngineView
import mozilla.components.feature.intent.IntentProcessor
import mozilla.components.lib.crash.Crash
import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.ktx.kotlin.isUrl
Expand Down Expand Up @@ -206,7 +206,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
var customTabSessionId: String? = null

if (isCustomTab) {
customTabSessionId = SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID)
customTabSessionId = SafeIntent(intent).getStringExtra(EXTRA_SESSION_ID)
}

openToBrowser(BrowserDirection.FromGlobal, customTabSessionId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import kotlinx.android.synthetic.main.component_search.*
import kotlinx.android.synthetic.main.fragment_browser.view.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.feature.readerview.ReaderViewFeature
import mozilla.components.feature.session.ThumbnailsFeature
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
Expand All @@ -46,6 +47,7 @@ import org.mozilla.fenix.customtabs.CustomTabsIntegration
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.home.sessioncontrol.SessionControlChange
import org.mozilla.fenix.home.sessioncontrol.TabCollection
import org.mozilla.fenix.mvi.getManagedEmitter
import org.mozilla.fenix.quickactionsheet.DefaultQuickActionSheetController
import org.mozilla.fenix.quickactionsheet.QuickActionSheetView
Expand Down Expand Up @@ -85,12 +87,15 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
return view
}

@Suppress("LongMethod", "ComplexMethod")
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val sessionManager = requireComponents.core.sessionManager

getSessionById()?.let { session ->
getSessionById()?.let {
quickActionSheetView = QuickActionSheetView(view.nestedScrollQuickAction, browserInteractor)

customTabSessionId?.let { customTabSessionId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class BrowserToolbarView(
val toolbarIntegration: ToolbarIntegration

init {
// We need access to the customSessionId. We don't directly have access since we aren't passing session id in
// So we need to access it through the store...?

with(container.context) {
val sessionManager = components.core.sessionManager
val isCustomTabSession = currentSession.isCustomTabSession()
Expand Down Expand Up @@ -100,7 +97,6 @@ class BrowserToolbarView(
toolbarIntegration = ToolbarIntegration(
this,
view,
container,
menuToolbar,
ShippedDomainsProvider().also { it.initialize(this) },
components.core.historyStorage,
Expand All @@ -111,8 +107,9 @@ class BrowserToolbarView(
}
}

@Suppress("UNUSED_PARAMETER")
fun update(state: BrowserState) {
// TODO Leaving this as a stub for now since we don't actually have anything to update ever...?
// Intentionally leaving this as a stub for now since we don't actually want to update currently
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.mozilla.fenix.components.toolbar

import android.content.Context
import android.view.ViewGroup
import androidx.navigation.NavOptions
import androidx.navigation.Navigation
import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider
Expand All @@ -28,7 +27,6 @@ import org.mozilla.fenix.utils.Settings
class ToolbarIntegration(
context: Context,
toolbar: BrowserToolbar,
browserLayout: ViewGroup,
toolbarMenu: ToolbarMenu,
domainAutocompleteProvider: DomainAutocompleteProvider,
historyStorage: HistoryStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.lifecycle.lifecycleScope
import kotlinx.android.synthetic.main.fragment_exceptions.view.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import mozilla.components.lib.state.ext.consumeFrom
Expand Down Expand Up @@ -53,6 +55,8 @@ class ExceptionsFragment : Fragment() {
return view
}

@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
consumeFrom(exceptionsStore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_bookmark.view.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import mozilla.appservices.places.BookmarkRoot
Expand Down Expand Up @@ -95,6 +97,8 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), BackHandler, Accou
return view
}

@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
consumeFrom(bookmarkStore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import kotlinx.android.synthetic.main.fragment_history.view.*
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.support.base.feature.BackHandler
Expand Down Expand Up @@ -105,6 +107,8 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), BackHandler {
}
}

@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_search.*
import kotlinx.android.synthetic.main.fragment_search.view.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.concept.storage.HistoryStorage
import mozilla.components.feature.qr.QrFeature
import mozilla.components.lib.state.ext.consumeFrom
Expand Down Expand Up @@ -100,6 +102,8 @@ class SearchFragment : Fragment(), BackHandler {
return view
}

@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down
2 changes: 2 additions & 0 deletions app/src/test/java/org/mozilla/fenix/TestApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

package org.mozilla.fenix

import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.mozilla.fenix.components.Components
import org.mozilla.fenix.components.TestComponents

@ObsoleteCoroutinesApi
class TestApplication : FenixApplication() {

override val components: Components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.mozilla.fenix.components

import androidx.fragment.app.Fragment
import androidx.fragment.app.testing.launchFragmentInContainer
import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.lib.state.Action
import mozilla.components.lib.state.State
import mozilla.components.lib.state.Store
Expand All @@ -18,6 +19,7 @@ import org.mozilla.fenix.TestApplication
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@ObsoleteCoroutinesApi
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
class StoreProviderTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package org.mozilla.fenix.components

import android.content.Context
import io.mockk.mockk
import kotlinx.coroutines.ObsoleteCoroutinesApi

@ObsoleteCoroutinesApi
class TestComponents(private val context: Context) : Components(context) {
override val backgroundServices by lazy {
mockk<BackgroundServices>(relaxed = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import io.mockk.mockkStatic
import io.mockk.slot
import io.mockk.spyk
import io.mockk.verify
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertNull

import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.mozilla.fenix.components.metrics

import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.browser.search.SearchEngine
import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.search.provider.AssetsSearchEngineProvider
Expand All @@ -20,6 +21,7 @@ import org.mozilla.fenix.components.FenixLocaleSearchLocalizationProvider
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@ObsoleteCoroutinesApi
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
class PerformedSearchTest {
Expand Down
4 changes: 3 additions & 1 deletion app/src/test/java/org/mozilla/fenix/ext/TabCollectionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
package org.mozilla.fenix.ext

import androidx.core.content.ContextCompat
import junit.framework.Assert.assertEquals
import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -18,6 +19,7 @@ import org.mozilla.fenix.TestApplication
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@ObsoleteCoroutinesApi
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
class TabCollectionTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.mozilla.fenix.library.bookmarks
import io.mockk.mockk
import io.mockk.spyk
import io.mockk.verifyOrder
import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import org.junit.Before
Expand All @@ -16,6 +17,7 @@ import org.mozilla.fenix.TestApplication
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@ObsoleteCoroutinesApi
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
internal class BookmarkAdapterTest {
Expand Down
2 changes: 2 additions & 0 deletions app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.fenix.utils

import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ASK_TO_ALLOW
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED
Expand All @@ -19,6 +20,7 @@ import org.mozilla.fenix.TestApplication
import org.mozilla.fenix.ext.clearAndCommit
import org.robolectric.annotation.Config

@ObsoleteCoroutinesApi
@RunWith(AndroidJUnit4::class)
@Config(application = TestApplication::class)
class SettingsTest {
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ allprojects {
}
jcenter()
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.allWarningsAsErrors = true
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", "-Xskip-runtime-version-check"]
}
}

task clean(type: Delete) {
Expand Down

0 comments on commit 2626a03

Please sign in to comment.