Skip to content

Commit

Permalink
Rename HistoryApi to NavigationHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisBarreiro committed Apr 23, 2024
1 parent 1825b3d commit 2b66c89
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.duckduckgo.autoconsent.api.Autoconsent
import com.duckduckgo.browser.api.WebViewVersionProvider
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.utils.device.DeviceInfo
import com.duckduckgo.history.api.HistoryApi
import com.duckduckgo.history.api.NavigationHistory
import kotlinx.coroutines.test.TestScope
import org.junit.Assert
import org.junit.Before
Expand All @@ -29,7 +29,7 @@ class PageLoadedHandlerTest {
private val webViewVersionProvider: WebViewVersionProvider = mock()
private val pageLoadedPixelDao: PageLoadedPixelDao = mock()
private val autoconsent: Autoconsent = mock()
private val historyApi: HistoryApi = mock()
private val navigationHistory: NavigationHistory = mock()

private val testee = RealPageLoadedHandler(
deviceInfo,
Expand All @@ -42,7 +42,7 @@ class PageLoadedHandlerTest {
override val enabled: Boolean
get() = true
},
historyApi,
navigationHistory,
)

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.duckduckgo.browser.api.WebViewVersionProvider
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.common.utils.device.DeviceInfo
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.history.api.HistoryApi
import com.duckduckgo.history.api.NavigationHistory
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
Expand All @@ -44,7 +44,7 @@ class RealPageLoadedHandler @Inject constructor(
private val dispatcherProvider: DispatcherProvider,
private val autoconsent: Autoconsent,
private val optimizeTrackerEvaluationRCWrapper: OptimizeTrackerEvaluationRCWrapper,
private val historyApi: HistoryApi,
private val navigationHistory: NavigationHistory,
) : PageLoadedHandler {

override fun onPageLoaded(url: String, title: String?, start: Long, end: Long) {
Expand All @@ -60,7 +60,7 @@ class RealPageLoadedHandler @Inject constructor(
),
)
}
historyApi.saveToHistory(url, title)
navigationHistory.saveToHistory(url, title)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.duckduckgo.history.api

import io.reactivex.Single

interface HistoryApi {
interface NavigationHistory {

/**
* Stores a history entry.
Expand All @@ -29,8 +29,9 @@ interface HistoryApi {
fun saveToHistory(url: String, title: String?)

/**
* Retrieves history entries.
* @return [Single] of all sites stored in history.
* Retrieves all [HistoryEntry].
* @return [Single] of all [HistoryEntry].
*/
@Deprecated("RxJava is deprecated, except for Auto-Complete")
fun getHistorySingle(): Single<List<HistoryEntry>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ package com.duckduckgo.history.impl
import com.duckduckgo.app.browser.DuckDuckGoUrlDetector
import com.duckduckgo.app.di.AppCoroutineScope
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.history.api.HistoryApi
import com.duckduckgo.history.api.HistoryEntry
import com.duckduckgo.history.api.NavigationHistory
import com.squareup.anvil.annotations.ContributesBinding
import io.reactivex.Single
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

@ContributesBinding(AppScope::class)
class History @Inject constructor(
class RealNavigationHistory @Inject constructor(
private val historyRepository: HistoryRepository,
private val duckDuckGoUrlDetector: DuckDuckGoUrlDetector,
@AppCoroutineScope private val appCoroutineScope: CoroutineScope,
) : HistoryApi {
) : NavigationHistory {
override fun saveToHistory(
url: String,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HistoryTest {
private val mockDuckDuckGoUrlDetector: DuckDuckGoUrlDetector = mock()
private val testScope = TestScope()

val testee = History(mockHistoryRepository, mockDuckDuckGoUrlDetector, testScope)
val testee = RealNavigationHistory(mockHistoryRepository, mockDuckDuckGoUrlDetector, testScope)

@Test
fun whenUrlIsSerpThenSaveToHistoryWithQueryAndSerpIsTrue() {
Expand Down

0 comments on commit 2b66c89

Please sign in to comment.