This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #4118 - Creates setting for auto closing tabs
- Loading branch information
Showing
18 changed files
with
358 additions
and
7 deletions.
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuTabsRobot.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,58 @@ | ||
/* 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.fenix.ui.robots | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import org.hamcrest.CoreMatchers.allOf | ||
|
||
/** | ||
* Implementation of Robot Pattern for the settings Tabs sub menu. | ||
*/ | ||
class SettingsSubMenuTabsRobot { | ||
|
||
fun verifyOptions() = assertOptions() | ||
|
||
class Transition { | ||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
|
||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { | ||
mDevice.waitForIdle() | ||
goBackButton().perform(ViewActions.click()) | ||
|
||
SettingsRobot().interact() | ||
return SettingsRobot.Transition() | ||
} | ||
} | ||
} | ||
|
||
private fun assertOptions() { | ||
afterOneDayToggle() | ||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) | ||
manualToggle() | ||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) | ||
afterOneWeekToggle() | ||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) | ||
afterOneMonthToggle() | ||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) | ||
} | ||
|
||
private fun manualToggle() = onView(withText("Manually")) | ||
|
||
private fun afterOneDayToggle() = onView(withText("After one day")) | ||
|
||
private fun afterOneWeekToggle() = onView(withText("After one week")) | ||
|
||
private fun afterOneMonthToggle() = onView(withText("After one month")) | ||
|
||
private fun goBackButton() = | ||
onView(allOf(ViewMatchers.withContentDescription("Navigate up"))) |
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
48 changes: 48 additions & 0 deletions
48
app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.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,48 @@ | ||
/* 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.fenix.settings | ||
|
||
import android.os.Bundle | ||
import androidx.preference.PreferenceFragmentCompat | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.ext.showToolbar | ||
import org.mozilla.fenix.utils.view.addToRadioGroup | ||
|
||
/** | ||
* Lets the user customize auto closing tabs. | ||
*/ | ||
class CloseTabsSettingsFragment : PreferenceFragmentCompat() { | ||
private lateinit var radioManual: RadioButtonPreference | ||
private lateinit var radioOneDay: RadioButtonPreference | ||
private lateinit var radioOneWeek: RadioButtonPreference | ||
private lateinit var radioOneMonth: RadioButtonPreference | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
setPreferencesFromResource(R.xml.close_tabs_preferences, rootKey) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
showToolbar(getString(R.string.preferences_close_tabs)) | ||
setupPreferences() | ||
} | ||
|
||
private fun setupPreferences() { | ||
radioManual = requirePreference(R.string.pref_key_close_tabs_manually) | ||
radioOneDay = requirePreference(R.string.pref_key_close_tabs_after_one_day) | ||
radioOneWeek = requirePreference(R.string.pref_key_close_tabs_after_one_week) | ||
radioOneMonth = requirePreference(R.string.pref_key_close_tabs_after_one_month) | ||
setupRadioGroups() | ||
} | ||
|
||
private fun setupRadioGroups() { | ||
addToRadioGroup( | ||
radioManual, | ||
radioOneDay, | ||
radioOneMonth, | ||
radioOneWeek | ||
) | ||
} | ||
} |
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
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
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
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
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
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- 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/. --> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M15.22 22H5.78A3.78 3.78 0 0 1 2 18.22V8.78C2 6.69 3.7 5 5.78 5h9.44C17.31 5 19 6.7 19 8.78v9.44c0 2-1.7 3.78-3.78 3.78zM5.86 7C4.83 7 4 7.83 4 8.86v9.28C4 19.17 4.83 20 5.86 20h9.28c1 0 1.86-0.83 1.86-1.86V8.86C17 8 16.17 7 15 7H6zM6 4c0-1.1 1-2 2-2h8a6 6 0 0 1 6 6v0L22 16a2 2 0 0 1-2 2L20 8V8a4 4 0 0 0-4-4H6z" | ||
android:fillColor="?primaryText" /> | ||
</vector> |
Oops, something went wrong.