Skip to content
  •  
  •  
  •  
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../versioning.gradle'
apply from: "$rootDir/ktlint.gradle"

ext {
USE_ORCHESTRATOR = project.hasProperty('orchestrator') ? project.property('orchestrator') : false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ class CoroutineTestRule(val testDispatcher: TestCoroutineDispatcher = TestCorout
@ExperimentalCoroutinesApi
fun CoroutineTestRule.runBlocking(block: suspend () -> Unit) = this.testDispatcher.runBlockingTest {
block()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ object FileUtilities {
return javaClass.classLoader!!.getResource(resourceName).openStream().bufferedReader()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

package com.duckduckgo.app


import io.reactivex.android.plugins.RxAndroidPlugins
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.Schedulers
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement


class InstantSchedulersRule : TestRule {

override fun apply(base: Statement, description: Description): Statement {
Expand Down Expand Up @@ -53,4 +51,4 @@ class InstantSchedulersRule : TestRule {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.duckduckgo.app
import com.duckduckgo.app.di.DaggerTestAppComponent
import com.duckduckgo.app.global.DuckDuckGoApplication


class TestApplication : DuckDuckGoApplication() {

/**
Expand All @@ -34,4 +33,4 @@ class TestApplication : DuckDuckGoApplication() {
.build()
daggerAppComponent.inject(this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ fun getApp(): TestApplication {

fun getDaggerComponent(): TestAppComponent {
return getApp().daggerAppComponent as TestAppComponent
}
}
3 changes: 1 addition & 2 deletions app/src/androidTest/java/com/duckduckgo/app/TestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner


@Suppress("unused")
class TestRunner : AndroidJUnitRunner() {
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
return super.newApplication(cl, TestApplication::class.java.name, context)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ class AutoCompleteApiTest {

assertSame("https://example.com", value.suggestions[0].phrase)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ class BookmarksDaoTest {
assertFalse(dao.hasBookmarks())
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ class BookmarksViewModelTest {
assertNotNull(captor.value)
assertNotNull(captor.value.bookmarks)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ class BrokenSiteDataTest {
companion object {
private const val SITE_URL = "foo.com"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ class BrowserChromeClientTest {
}

private class TestWebView(context: Context) : WebView(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ class BrowserViewModelTest {
companion object {
const val TAB_ID = "TAB_ID"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ class BrowserWebViewClientTest {
companion object {
const val EXAMPLE_URL = "example.com"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ class DuckDuckGoRequestRewriterTest {
assertFalse(uri.queryParameterNames.contains(ParamKey.ATB))
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ class DuckDuckGoUrlDetectorTest {
assertFalse(testee.isDuckDuckGoQueryUrl("https://example.com?q=test%20search"))
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ class DuckDuckGoWebViewTest {
assertFalse(testee.settings.safeBrowsingEnabled)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class EmptyNavigationStateTest {
hasNavigationHistory = true
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class QueryUrlConverterTest {
assertNotNull(encodedQuery)
assertTrue("Query string doesn't match. Expected `q=$query` somewhere in query ${uri.encodedQuery}", encodedQuery!!.contains("q=$query"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ class SpecialUrlDetectorImplTest {
val charList: List<Char> = ('a'..'z') + ('0'..'9')
return List(length) { charList.random() }.joinToString("")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ class WebViewDataManagerTest {
clearedFormData = true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ class WebViewLongPressHandlerTest {
verify(mockMenu, never()).add(anyInt(), anyInt(), anyInt(), anyInt())
verify(mockMenu, never()).add(anyInt(), anyInt(), anyInt(), anyString())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class WebViewRequestInterceptorTest {
assertRequestCanContinueToLoad(response)
}


@Test
fun whenRequestShouldBlockAndNoSurrogateThenCancellingResponseReturned() = runBlocking<Unit> {
whenever(mockResourceSurrogates.get(any())).thenReturn(SurrogateResponse(responseAvailable = false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ class DefaultBrowserObserverTest {

verify(mockPixel).fire(Pixel.PixelName.DEFAULT_BROWSER_UNSET)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ class DataUriParserTest {
val filename = testee.generate("data:,AAAA") as ParsedDataUri
assertFalse(filename.toString().contains("."))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ class FileChooserIntentBuilderTest {
val actual = flags and expectedFlag
return expectedFlag == actual
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ class TestWebViewThrowsNullPointerException(context: Context) : WebView(context)
override fun copyBackForwardList(): WebBackForwardList {
throw NullPointerException("Deliberate")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class AppEnjoymentDatabaseRepositoryTest {
private lateinit var database: AppDatabase
private lateinit var dao: AppEnjoymentDao


@Before
fun setup() {
database = Room.inMemoryDatabaseBuilder(InstrumentationRegistry.getInstrumentation().targetContext, AppDatabase::class.java)
Expand Down Expand Up @@ -127,4 +126,4 @@ class AppEnjoymentDatabaseRepositoryTest {
private val FIRST_PROMPT = PromptCount(1)
private val SECOND_PROMPT = PromptCount(2)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ class FileBasedWebViewPreviewPersisterTest {
private fun verifyTabPreviewDirectoryUse(path: String) {
assertTrue(path.contains("/${FileBasedWebViewPreviewPersister.TAB_PREVIEW_DIRECTORY}"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ class UserAgentProviderTest {
val actual = testee.getUserAgent(desktopSiteRequested = false)
assertTrue(MOBILE_UA_REGEX_MISSING_APPLE_WEBKIT_DETAILS.matches(actual))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class DismissedCtaDaoTest {
dao.insert(DismissedCta(CtaId.ADD_WIDGET))
assertTrue(dao.exists(CtaId.ADD_WIDGET))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class CtaTest {
assertTrue(testee.pixelShownParameters().isEmpty())
}


@Test
fun whenCtaIsAddWidgetInstructionsReturnEmptyOkParameters() {
val testee = HomePanelCta.AddWidgetInstructions
Expand Down Expand Up @@ -350,4 +349,4 @@ class CtaTest {
whenever(site.calculateGrades()).thenReturn(Site.SiteGrades(grade, improvedGrade))
return site
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ class CtaViewModelTest {
assertTrue(value is DaxDialogCta.DaxSerpCta)
}


@Test
fun whenRefreshCtaWhileBrowsingThenReturnNoSerpCta() = coroutineRule.runBlocking {
givenDaxOnboardingActive()
Expand Down Expand Up @@ -431,7 +430,7 @@ class CtaViewModelTest {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING)
}

private suspend fun givenDaxOnboardingCompleted() {
private suspend fun givenDaxOnboardingCompleted() {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.ESTABLISHED)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class StubAppConfigurationDownloadModule {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import dagger.Module
import dagger.Provides
import javax.inject.Singleton


@Module(includes = [DaoModule::class])
class StubDatabaseModule {

Expand All @@ -34,4 +33,4 @@ class StubDatabaseModule {
.allowMainThreadQueries()
.build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ class StubJobSchedulerModule {
fun providesWorkScheduler(notificationScheduler: AndroidNotificationScheduler, jobCleaner: JobCleaner): WorkScheduler {
return AndroidWorkScheduler(notificationScheduler, jobCleaner)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ class StubStatisticsModule {
): AtbInitializer {
return AtbInitializer(statisticsDataStore, statisticsUpdater, appReferrerStateListener)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ interface TestAppComponent : AppComponent {

@Named("api")
fun retrofit(): Retrofit
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ class BrokenSiteViewModelTest {
private const val message = "Feedback message"
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,10 @@ class AutomaticDataClearerTest {
}
}


@Test
fun whenNotFreshAppLaunchAndIconNotChangedThenShouldClear() = runBlocking<Unit> {
val isFreshAppLaunch = false

configureAppIconNotChanged()
configureAppNotUsedSinceLastClear()
configureUserOptions(ClearWhatOption.CLEAR_TABS_AND_DATA, ClearWhenOption.APP_EXIT_OR_5_MINS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ class DataClearerTimeKeeperTest(private val testCase: TestCase) {
val durationBackgrounded: Long,
val timeNow: Long
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ class GetCookieHostsToPreserveTest {
private fun givenFireproofWebsitesStored(fireproofWebsiteEntity: FireproofWebsiteEntity) {
fireproofWebsiteDao.insert(fireproofWebsiteEntity)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class RemoveCookiesTest {
private suspend fun CookieRemover.fails() {
whenever(this.removeCookies()).thenReturn(false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ class SQLCookieRemoverTest {
dispatcherProvider
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ class UnsentForgetAllPixelStoreSharedPreferencesTest {
testee.resetCount()
assertEquals(0, testee.pendingPixelCountClearData)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ class WebViewCookieManagerTest {
companion object {
private const val DDG_HOST = "duckduckgo.com"
}
}
}
Loading