Revision control

Copy as Markdown

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.focus.privacy
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.MockWebServerHelper
import org.mozilla.focus.helpers.TestAssetHelper.getStorageTestAsset
import java.io.IOException
/**
* Test that Global Privacy Control is always enabled in Focus.
*/
@RunWith(AndroidJUnit4ClassRunner::class)
class GlobalPrivacyControlTest {
private lateinit var webServer: MockWebServer
private val featureSettingsHelper = FeatureSettingsHelper()
@get: Rule
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)
@Before
fun setUp() {
webServer = MockWebServer().apply {
dispatcher = MockWebServerHelper.AndroidAssetDispatcher()
start()
}
featureSettingsHelper.setCfrForTrackingProtectionEnabled(false)
featureSettingsHelper.setSearchWidgetDialogEnabled(false)
}
@After
fun tearDown() {
try {
webServer.shutdown()
} catch (e: IOException) {
throw AssertionError("Could not stop web server", e)
}
}
@Test
fun gpcTest() {
val storageStartUrl = getStorageTestAsset(webServer, "global_privacy_control.html").url
searchScreen {
}.loadPage(storageStartUrl) {
verifyPageContent("GPC is enabled.")
}
}
}