Bug 1880466 - Add logs to SettingsSubMenuAccessibilityRobot

fenix/124.1.0
AndiAJ 4 months ago committed by mergify[bot]
parent e1fc09fe7e
commit a66d8287c8

@ -6,6 +6,7 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.util.Log
import android.view.KeyEvent import android.view.KeyEvent
import android.view.KeyEvent.ACTION_DOWN import android.view.KeyEvent.ACTION_DOWN
import android.view.KeyEvent.KEYCODE_DPAD_LEFT import android.view.KeyEvent.KEYCODE_DPAD_LEFT
@ -28,7 +29,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Matcher import org.hamcrest.Matcher
import org.junit.Assert.assertTrue
import org.mozilla.fenix.components.Components import org.mozilla.fenix.components.Components
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.assertIsEnabled import org.mozilla.fenix.helpers.assertIsEnabled
import org.mozilla.fenix.helpers.isEnabled import org.mozilla.fenix.helpers.isEnabled
@ -53,50 +56,65 @@ class SettingsSubMenuAccessibilityRobot {
fun clickFontSizingSwitch() = toggleFontSizingSwitch() fun clickFontSizingSwitch() = toggleFontSizingSwitch()
fun verifyEnabledMenuItems() { fun verifyEnabledMenuItems() {
val view = onView(withText("Font Size")) Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Font Size\" title is visible")
view.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(withText("Font Size")).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.check(matches(isEnabled(true))) Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Font Size\" title is visible")
Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Font Size\" title is enabled")
val strFont = "Make text on websites larger or smaller" onView(withText("Font Size")).check(matches(isEnabled(true)))
onView(withText(strFont)) Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Font Size\" title is enabled")
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Make text on websites larger or smaller\" summary is visible")
.check(matches(isEnabled(true))) onView(withText("Make text on websites larger or smaller")).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Make text on websites larger or smaller\" summary is visible")
Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the \"Make text on websites larger or smaller\" summary is enabled")
onView(withText("Make text on websites larger or smaller")).check(matches(isEnabled(true)))
Log.i(TAG, "verifyEnabledMenuItems: Verified that the \"Make text on websites larger or smaller\" summary is enabled")
Log.i(TAG, "verifyEnabledMenuItems: Trying to verify the \"This is sample text. It is here to show how text will appear\" sample text")
onView(withId(org.mozilla.fenix.R.id.sampleText)) onView(withId(org.mozilla.fenix.R.id.sampleText))
.check(matches(withText("This is sample text. It is here to show how text will appear when you increase or decrease the size with this setting."))) .check(matches(withText("This is sample text. It is here to show how text will appear when you increase or decrease the size with this setting.")))
Log.i(TAG, "verifyEnabledMenuItems: Verified the \"This is sample text. It is here to show how text will appear\" sample text")
onView(withId(org.mozilla.fenix.R.id.seekbar_value)) Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar value is set to 100%")
.check(matches(withText("100%"))) onView(withId(org.mozilla.fenix.R.id.seekbar_value)).check(matches(withText("100%")))
Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar value is set to 100%")
onView(withId(org.mozilla.fenix.R.id.seekbar)) Log.i(TAG, "verifyEnabledMenuItems: Trying to verify that the seek bar is visible")
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(withId(org.mozilla.fenix.R.id.seekbar)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyEnabledMenuItems: Verified that the seek bar is visible")
} }
fun verifyMenuItemsAreDisabled() { fun verifyMenuItemsAreDisabled() {
Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"Font Size\" title is not enabled")
onView(withText("Font Size")).assertIsEnabled(false) onView(withText("Font Size")).assertIsEnabled(false)
Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"Font Size\" title is not enabled")
val strFont = "Make text on websites larger or smaller" Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"Make text on websites larger or smaller\" summary is not enabled")
onView(withText("Make text on websites larger or smaller")).assertIsEnabled(false)
onView(withText(strFont)).assertIsEnabled(false) Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"Make text on websites larger or smaller\" summary is not enabled")
Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the \"This is sample text. It is here to show how text will appear\" sample text is not enabled")
onView(withId(org.mozilla.fenix.R.id.sampleText)).assertIsEnabled(false) onView(withId(org.mozilla.fenix.R.id.sampleText)).assertIsEnabled(false)
Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the \"This is sample text. It is here to show how text will appear\" sample text is not enabled")
Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the seek bar value is not enabled")
onView(withId(org.mozilla.fenix.R.id.seekbar_value)).assertIsEnabled(false) onView(withId(org.mozilla.fenix.R.id.seekbar_value)).assertIsEnabled(false)
Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the seek bar value is not enabled")
Log.i(TAG, "verifyMenuItemsAreDisabled: Trying to verify that the seek bar is not enabled")
onView(withId(org.mozilla.fenix.R.id.seekbar)).assertIsEnabled(false) onView(withId(org.mozilla.fenix.R.id.seekbar)).assertIsEnabled(false)
Log.i(TAG, "verifyMenuItemsAreDisabled: Verified that the seek bar is not enabled")
} }
fun changeTextSizeSlider(seekBarPercentage: Int) = adjustTextSizeSlider(seekBarPercentage) fun changeTextSizeSlider(seekBarPercentage: Int) = adjustTextSizeSlider(seekBarPercentage)
fun verifyTextSizePercentage(textSize: Int) { fun verifyTextSizePercentage(textSize: Int) {
Log.i(TAG, "verifyTextSizePercentage: Trying to verify that the text size percentage is set to: $textSize")
onView(withId(org.mozilla.fenix.R.id.sampleText)) onView(withId(org.mozilla.fenix.R.id.sampleText))
.check(textSizePercentageEquals(textSize)) .check(textSizePercentageEquals(textSize))
Log.i(TAG, "verifyTextSizePercentage: Verified that the text size percentage is set to: $textSize")
} }
class Transition { class Transition {
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
Log.i(TAG, "goBack: Waiting for device to be idle")
mDevice.waitForIdle() mDevice.waitForIdle()
Log.i(TAG, "goBack: Waited for device to be idle")
Log.i(TAG, "goBack: Trying to click the navigate up toolbar button")
goBackButton().perform(click()) goBackButton().perform(click())
Log.i(TAG, "goBack: Clicked the navigate up toolbar button")
SettingsRobot().interact() SettingsRobot().interact()
return SettingsRobot.Transition() return SettingsRobot.Transition()
@ -105,15 +123,19 @@ class SettingsSubMenuAccessibilityRobot {
} }
private fun toggleFontSizingSwitch() { private fun toggleFontSizingSwitch() {
Log.i(TAG, "toggleFontSizingSwitch: Trying to click the \"Automatic font sizing\" toggle")
// Toggle font size to off // Toggle font size to off
onView(withText("Automatic font sizing")) onView(withText("Automatic font sizing"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.perform(click()) .perform(click())
Log.i(TAG, "toggleFontSizingSwitch: Clicked the \"Automatic font sizing\" toggle")
} }
private fun adjustTextSizeSlider(seekBarPercentage: Int) { private fun adjustTextSizeSlider(seekBarPercentage: Int) {
Log.i(TAG, "adjustTextSizeSlider: Trying to set the seek bar value to: $seekBarPercentage")
onView(withId(org.mozilla.fenix.R.id.seekbar)) onView(withId(org.mozilla.fenix.R.id.seekbar))
.perform(SeekBarChangeProgressViewAction(seekBarPercentage)) .perform(SeekBarChangeProgressViewAction(seekBarPercentage))
Log.i(TAG, "adjustTextSizeSlider: Seek bar value was set to: $seekBarPercentage")
} }
private fun goBackButton() = private fun goBackButton() =
@ -167,9 +189,11 @@ fun calculateStepSizeFromPercentage(textSizePercentage: Int): Int {
return ((textSizePercentage - MIN_VALUE) / STEP_SIZE) return ((textSizePercentage - MIN_VALUE) / STEP_SIZE)
} }
fun checkTextSizeOnWebsite(textSizePercentage: Int, components: Components): Boolean { fun checkTextSizeOnWebsite(textSizePercentage: Int, components: Components) {
Log.i(TAG, "checkTextSizeOnWebsite: Trying to verify that text size on website is: $textSizePercentage")
// Checks the Gecko engine settings for the font size // Checks the Gecko engine settings for the font size
val textSize = calculateStepSizeFromPercentage(textSizePercentage) val textSize = calculateStepSizeFromPercentage(textSizePercentage)
val newTextScale = ((textSize * STEP_SIZE) + MIN_VALUE).toFloat() / DECIMAL_CONVERSION val newTextScale = ((textSize * STEP_SIZE) + MIN_VALUE).toFloat() / DECIMAL_CONVERSION
return components.core.engine.settings.fontSizeFactor == newTextScale assertTrue("$TAG: text size on website was not set to: $textSizePercentage", components.core.engine.settings.fontSizeFactor == newTextScale)
Log.i(TAG, "checkTextSizeOnWebsite: Verified that text size on website is: $textSizePercentage")
} }

Loading…
Cancel
Save