This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor AddSettingsTest, added new tests based on the manual test ca…
…ses. Added new test robots.
- Loading branch information
1 parent
09ea191
commit 9436242
Showing
8 changed files
with
368 additions
and
58 deletions.
There are no files selected for viewing
58 changes: 0 additions & 58 deletions
58
app/src/androidTest/java/org/mozilla/focus/activity/AccessSettingsTest.kt
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
app/src/androidTest/java/org/mozilla/focus/activity/SettingsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- | ||
* 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.activity | ||
|
||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mozilla.focus.activity.robots.homeScreen | ||
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule | ||
|
||
// This test checks all the headings in the Settings menu are there | ||
@RunWith(AndroidJUnit4ClassRunner::class) | ||
class SettingsTest { | ||
@get: Rule | ||
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false) | ||
|
||
@Test | ||
fun accessSettingsMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
verifySettingsMenuItems() | ||
} | ||
} | ||
|
||
@Test | ||
fun verifyGeneralSettingsMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
}.openGeneralSettingsMenu { | ||
verifyGeneralSettingsItems() | ||
} | ||
} | ||
|
||
@Test | ||
fun verifyPrivacySettingsMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
}.openPrivacySettingsMenu { | ||
verifyPrivacySettingsItems() | ||
} | ||
} | ||
|
||
@Test | ||
fun verifySearchSettingsMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
}.openSearchSettingsMenu { | ||
verifySearchSettingsItems() | ||
} | ||
} | ||
|
||
@Test | ||
fun verifyAdvancedSettingsMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
}.openAdvancedSettingsMenu { | ||
verifyAdvancedSettingsItems() | ||
} | ||
} | ||
|
||
@Test | ||
fun verifyMozillaMenuTest() { | ||
homeScreen { | ||
}.openMainMenu { | ||
}.openSettings { | ||
}.openMozillaSettingsMenu { | ||
verifyMozillaMenuItems() | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/androidTest/java/org/mozilla/focus/activity/robots/SettingsAdvancedMenuRobot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* 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.activity.robots | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.uiautomator.UiScrollable | ||
import androidx.test.uiautomator.UiSelector | ||
import org.mozilla.focus.helpers.TestHelper.appName | ||
import org.mozilla.focus.helpers.TestHelper.waitingTime | ||
|
||
class SettingsAdvancedMenuRobot { | ||
fun verifyAdvancedSettingsItems() { | ||
advancedSettingsList.waitForExists(waitingTime) | ||
remoteDebuggingSwitch.check(matches(isDisplayed())) | ||
} | ||
|
||
class Transition | ||
} | ||
|
||
private val advancedSettingsList = | ||
UiScrollable(UiSelector().resourceId("$appName:id/recycler_view")) | ||
|
||
private val remoteDebuggingSwitch = onView(ViewMatchers.withText("Remote debugging via USB/Wi-Fi")) |
32 changes: 32 additions & 0 deletions
32
app/src/androidTest/java/org/mozilla/focus/activity/robots/SettingsGeneralMenuRobot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 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.activity.robots | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import org.mozilla.focus.helpers.TestHelper.pressBackKey | ||
|
||
class SettingsGeneralMenuRobot { | ||
|
||
fun verifyGeneralSettingsItems() { | ||
defaultBrowserSwitch.check(matches(isDisplayed())) | ||
switchToLinkToggleButton.check(matches(isDisplayed())) | ||
} | ||
|
||
class Transition { | ||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { | ||
pressBackKey() | ||
|
||
SettingsRobot().interact() | ||
return SettingsRobot.Transition() | ||
} | ||
} | ||
} | ||
|
||
private val defaultBrowserSwitch = onView(withText("Make Firefox Focus default browser")) | ||
|
||
private val switchToLinkToggleButton = onView(withText("Switch to link in new tab immediately")) |
40 changes: 40 additions & 0 deletions
40
app/src/androidTest/java/org/mozilla/focus/activity/robots/SettingsMozillaMenuRobot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* 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.activity.robots | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.uiautomator.UiScrollable | ||
import androidx.test.uiautomator.UiSelector | ||
import org.mozilla.focus.helpers.TestHelper | ||
import org.mozilla.focus.helpers.TestHelper.waitingTime | ||
|
||
class SettingsMozillaMenuRobot { | ||
fun verifyMozillaMenuItems() { | ||
mozillaSettingsList.waitForExists(waitingTime) | ||
showTipsSwitch.check(matches(isDisplayed())) | ||
aboutFocusPageLink.check(matches(isDisplayed())) | ||
helpPageLink.check(matches(isDisplayed())) | ||
rightsPageLink.check(matches(isDisplayed())) | ||
privacyNoticeLink.check(matches(isDisplayed())) | ||
} | ||
|
||
class Transition | ||
} | ||
|
||
private val mozillaSettingsList = | ||
UiScrollable(UiSelector().resourceId("${TestHelper.appName}:id/recycler_view")) | ||
|
||
private val showTipsSwitch = onView(withText("Show home screen tips")) | ||
|
||
private val aboutFocusPageLink = onView(withText("About Firefox Focus")) | ||
|
||
private val helpPageLink = onView(withText("Help")) | ||
|
||
private val rightsPageLink = onView(withText("Your Rights")) | ||
|
||
private val privacyNoticeLink = onView(withText("Privacy Notice")) |
105 changes: 105 additions & 0 deletions
105
app/src/androidTest/java/org/mozilla/focus/activity/robots/SettingsPrivacyMenuRobot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* 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/. */ | ||
|
||
@file:Suppress("TooManyFunctions") | ||
package org.mozilla.focus.activity.robots | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.ViewInteraction | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.uiautomator.UiScrollable | ||
import androidx.test.uiautomator.UiSelector | ||
import org.mozilla.focus.helpers.TestHelper.appName | ||
import org.mozilla.focus.helpers.TestHelper.waitingTime | ||
|
||
class SettingsPrivacyMenuRobot { | ||
|
||
fun verifyPrivacySettingsItems() { | ||
privacySettingsList.waitForExists(waitingTime) | ||
adTrackersBlockSwitch().check(matches(isDisplayed())) | ||
analyticTrackersBlockSwitch().check(matches(isDisplayed())) | ||
socialTrackersBlockSwitch().check(matches(isDisplayed())) | ||
otherContentTrackersBlockSwitch().check(matches(isDisplayed())) | ||
blockWebFontsSwitch().check(matches(isDisplayed())) | ||
blockJavaScriptSwitch().check(matches(isDisplayed())) | ||
blockCookiesMenu().check(matches(isDisplayed())) | ||
useFingerprintSwitch().check(matches(isDisplayed())) | ||
stealthModeSwitch().check(matches(isDisplayed())) | ||
safeBrowsingSwitch().check(matches(isDisplayed())) | ||
sendDataSwitch().check(matches(isDisplayed())) | ||
} | ||
|
||
class Transition | ||
} | ||
|
||
private val privacySettingsList = | ||
UiScrollable(UiSelector().resourceId("$appName:id/recycler_view")) | ||
|
||
private fun adTrackersBlockSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block ad trackers") | ||
return onView(withText("Block ad trackers")) | ||
} | ||
|
||
private fun analyticTrackersBlockSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block analytic trackers") | ||
return onView(withText("Block analytic trackers")) | ||
} | ||
|
||
private fun socialTrackersBlockSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block social trackers") | ||
return onView(withText("Block social trackers")) | ||
} | ||
|
||
private fun otherContentTrackersBlockSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block other content trackers") | ||
return onView(withText("Block other content trackers")) | ||
} | ||
|
||
private fun blockWebFontsSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block Web fonts") | ||
return onView(withText("Block Web fonts")) | ||
} | ||
|
||
private fun blockJavaScriptSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block JavaScript") | ||
return onView(withText("Block JavaScript")) | ||
} | ||
|
||
private fun blockCookiesMenu(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block cookies") | ||
return onView(withText("Block cookies")) | ||
} | ||
|
||
private fun useFingerprintSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Use fingerprint to unlock app") | ||
return onView(withText("Use fingerprint to unlock app")) | ||
} | ||
|
||
private fun stealthModeSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Stealth") | ||
return onView(withText("Stealth")) | ||
} | ||
|
||
private fun safeBrowsingSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Block potentially dangerous and deceptive sites") | ||
return onView(withText("Block potentially dangerous and deceptive sites")) | ||
} | ||
|
||
private fun sendDataSwitch(): ViewInteraction { | ||
privacySettingsList | ||
.scrollTextIntoView("Send usage data") | ||
return onView(withText("Send usage data")) | ||
} |
Oops, something went wrong.