mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 23:07:26 -04:00
Fixed: SearchFragmentTestForCustomApp
was failing.
* Fixed: The appearance of TTS control buttons.
This commit is contained in:
parent
a6eb00f6b9
commit
eca3c355b2
@ -26,7 +26,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.bottomappbar.BottomAppBar
|
import com.google.android.material.bottomappbar.BottomAppBar
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import org.kiwix.kiwixmobile.R
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inspired by James @ https://stackoverflow.com/users/165783/james
|
* Inspired by James @ https://stackoverflow.com/users/165783/james
|
||||||
@ -62,8 +61,7 @@ class ScrollingViewWithBottomNavigationBehavior(context: Context, attrs: Attribu
|
|||||||
navigationBar: BottomNavigationView,
|
navigationBar: BottomNavigationView,
|
||||||
coordinatorLayout: CoordinatorLayout
|
coordinatorLayout: CoordinatorLayout
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val readerBottomAppBar: BottomAppBar? =
|
val readerBottomAppBar: BottomAppBar? = null
|
||||||
fragmentContainer.findViewById(org.kiwix.kiwixmobile.core.R.id.bottom_toolbar)
|
|
||||||
if (readerBottomAppBar != null) {
|
if (readerBottomAppBar != null) {
|
||||||
val newBottomMargin = calculateNewBottomMargin(navigationBar, coordinatorLayout)
|
val newBottomMargin = calculateNewBottomMargin(navigationBar, coordinatorLayout)
|
||||||
if (newBottomMargin != bottomMargin) {
|
if (newBottomMargin != bottomMargin) {
|
||||||
|
@ -72,13 +72,11 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.bottomappbar.BottomAppBar
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import kotlinx.coroutines.CoroutineDispatcher
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
@ -1972,9 +1970,7 @@ abstract class CoreReaderFragment :
|
|||||||
var bottomMargin = requireActivity().resources.getDimensionPixelSize(
|
var bottomMargin = requireActivity().resources.getDimensionPixelSize(
|
||||||
R.dimen.donation_popup_bottom_margin
|
R.dimen.donation_popup_bottom_margin
|
||||||
)
|
)
|
||||||
val bottomAppBar = requireActivity()
|
if (readerScreenState.value.shouldShowBottomAppBar) {
|
||||||
.findViewById<BottomAppBar>(R.id.bottom_toolbar)
|
|
||||||
if (bottomAppBar.isVisible) {
|
|
||||||
// if bottomAppBar is visible then add the height of the bottomAppBar.
|
// if bottomAppBar is visible then add the height of the bottomAppBar.
|
||||||
bottomMargin +=
|
bottomMargin +=
|
||||||
requireActivity().resources.getDimensionPixelSize(
|
requireActivity().resources.getDimensionPixelSize(
|
||||||
|
@ -184,7 +184,7 @@ object ComposeDimens {
|
|||||||
// Reader screen dimens
|
// Reader screen dimens
|
||||||
val READER_BOTTOM_APP_BAR_LAYOUT_HEIGHT = 40.dp
|
val READER_BOTTOM_APP_BAR_LAYOUT_HEIGHT = 40.dp
|
||||||
val READER_BOTTOM_APP_BAR_BUTTON_ICON_SIZE = 30.dp
|
val READER_BOTTOM_APP_BAR_BUTTON_ICON_SIZE = 30.dp
|
||||||
const val TTS_BUTTONS_CONTROL_ALPHA = 0.6f
|
const val TTS_BUTTONS_CONTROL_ALPHA = 0.9f
|
||||||
val CLOSE_ALL_TAB_BUTTON_BOTTOM_PADDING = 24.dp
|
val CLOSE_ALL_TAB_BUTTON_BOTTOM_PADDING = 24.dp
|
||||||
val TAB_SWITCHER_TEXT_SIZE = 12.sp
|
val TAB_SWITCHER_TEXT_SIZE = 12.sp
|
||||||
const val TAB_SWITCHER_ICON_CORNER_RADIUS = 10
|
const val TAB_SWITCHER_ICON_CORNER_RADIUS = 10
|
||||||
@ -193,6 +193,4 @@ object ComposeDimens {
|
|||||||
val BACK_TO_TOP_BUTTON_BOTTOM_MARGIN = 80.dp
|
val BACK_TO_TOP_BUTTON_BOTTOM_MARGIN = 80.dp
|
||||||
const val READER_BOTTOM_APP_BAR_DISABLE_BUTTON_ALPHA = 0.38f
|
const val READER_BOTTOM_APP_BAR_DISABLE_BUTTON_ALPHA = 0.38f
|
||||||
val SEARCH_PLACEHOLDER_TEXT_SIZE = 12.sp
|
val SEARCH_PLACEHOLDER_TEXT_SIZE = 12.sp
|
||||||
val COMPOSE_TOOLBAR_DEFAULT_HEIGHT = 64.dp
|
|
||||||
val COMPOSE_BOTTOM_APP_BAR_DEFAULT_HEIGHT = 80.dp
|
|
||||||
}
|
}
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.google.android.material.bottomappbar.BottomAppBar xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/bottom_toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:padding="8dp"
|
|
||||||
app:fabAlignmentMode="end"
|
|
||||||
app:fabCradleVerticalOffset="@dimen/fab_vertical_offset"
|
|
||||||
app:hideOnScroll="true"
|
|
||||||
tools:ignore="BottomAppBar">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/bottom_toolbar_bookmark"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:contentDescription="@string/bookmarks"
|
|
||||||
android:src="@drawable/ic_bookmark_border_24dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/bottom_toolbar_arrow_back"
|
|
||||||
app:layout_constraintHorizontal_chainStyle="spread"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/bottom_toolbar_arrow_back"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:contentDescription="@string/go_to_previous_page"
|
|
||||||
android:src="@drawable/ic_keyboard_arrow_left_24dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/bottom_toolbar_home"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/bottom_toolbar_bookmark"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/bottom_toolbar_home"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:contentDescription="@string/menu_home"
|
|
||||||
android:src="@drawable/action_home"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/bottom_toolbar_arrow_forward"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/bottom_toolbar_arrow_back"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/bottom_toolbar_arrow_forward"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:contentDescription="@string/go_to_next_page"
|
|
||||||
android:src="@drawable/ic_keyboard_arrow_right_24dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/bottom_toolbar_toc"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/bottom_toolbar_home"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/bottom_toolbar_toc"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:contentDescription="@string/table_of_contents"
|
|
||||||
android:src="@drawable/ic_toc_24dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/bottom_toolbar_arrow_forward"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</com.google.android.material.bottomappbar.BottomAppBar>
|
|
@ -54,10 +54,8 @@ import org.kiwix.kiwixmobile.core.search.viewmodel.Action
|
|||||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils
|
import org.kiwix.kiwixmobile.core.utils.LanguageUtils
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils.COMPOSE_TEST_RULE_ORDER
|
import org.kiwix.kiwixmobile.core.utils.TestingUtils.COMPOSE_TEST_RULE_ORDER
|
||||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils.RETRY_RULE_ORDER
|
|
||||||
import org.kiwix.kiwixmobile.custom.main.CustomMainActivity
|
import org.kiwix.kiwixmobile.custom.main.CustomMainActivity
|
||||||
import org.kiwix.kiwixmobile.custom.main.CustomReaderFragment
|
import org.kiwix.kiwixmobile.custom.main.CustomReaderFragment
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.RetryRule
|
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.closeSystemDialogs
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.closeSystemDialogs
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.isSystemUINotRespondingDialogVisible
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.isSystemUINotRespondingDialogVisible
|
||||||
@ -83,9 +81,9 @@ class SearchFragmentTestForCustomApp {
|
|||||||
InstrumentationRegistry.getInstrumentation().targetContext.applicationContext
|
InstrumentationRegistry.getInstrumentation().targetContext.applicationContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule(order = RETRY_RULE_ORDER)
|
// @Rule(order = RETRY_RULE_ORDER)
|
||||||
@JvmField
|
// @JvmField
|
||||||
var retryRule = RetryRule()
|
// var retryRule = RetryRule()
|
||||||
|
|
||||||
@get:Rule(order = COMPOSE_TEST_RULE_ORDER)
|
@get:Rule(order = COMPOSE_TEST_RULE_ORDER)
|
||||||
val composeTestRule = createComposeRule()
|
val composeTestRule = createComposeRule()
|
||||||
@ -295,7 +293,7 @@ class SearchFragmentTestForCustomApp {
|
|||||||
openZimFileInReader(zimFile = downloadingZimFile)
|
openZimFileInReader(zimFile = downloadingZimFile)
|
||||||
search {
|
search {
|
||||||
// click on home button to load the main page of ZIM file.
|
// click on home button to load the main page of ZIM file.
|
||||||
clickOnHomeButton()
|
clickOnHomeButton(composeTestRule, customMainActivity)
|
||||||
// click on an article to load the other page.
|
// click on an article to load the other page.
|
||||||
clickOnAFoolForYouArticle()
|
clickOnAFoolForYouArticle()
|
||||||
assertAFoolForYouArticleLoaded()
|
assertAFoolForYouArticleLoaded()
|
||||||
|
@ -23,16 +23,14 @@ import androidx.compose.ui.test.assert
|
|||||||
import androidx.compose.ui.test.hasText
|
import androidx.compose.ui.test.hasText
|
||||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||||
import androidx.compose.ui.test.onAllNodesWithTag
|
import androidx.compose.ui.test.onAllNodesWithTag
|
||||||
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithTag
|
import androidx.compose.ui.test.onNodeWithTag
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performTextClearance
|
import androidx.compose.ui.test.performTextClearance
|
||||||
import androidx.compose.ui.test.performTextInput
|
import androidx.compose.ui.test.performTextInput
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.test.espresso.Espresso
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions
|
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.matcher.ViewMatchers
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches
|
import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches
|
||||||
import androidx.test.espresso.web.sugar.Web
|
import androidx.test.espresso.web.sugar.Web
|
||||||
@ -51,6 +49,7 @@ import org.kiwix.kiwixmobile.core.page.SEARCH_ICON_TESTING_TAG
|
|||||||
import org.kiwix.kiwixmobile.core.search.SEARCH_FIELD_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.search.SEARCH_FIELD_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.search.SEARCH_ITEM_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.search.SEARCH_ITEM_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.custom.R.id
|
import org.kiwix.kiwixmobile.custom.R.id
|
||||||
|
import org.kiwix.kiwixmobile.custom.main.CustomMainActivity
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.TEST_PAUSE_MS
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.TEST_PAUSE_MS
|
||||||
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.testFlakyView
|
import org.kiwix.kiwixmobile.custom.testutils.TestUtils.testFlakyView
|
||||||
@ -147,11 +146,14 @@ class SearchRobot {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnHomeButton() {
|
fun clickOnHomeButton(
|
||||||
testFlakyView({
|
composeTestRule: ComposeContentTestRule,
|
||||||
Espresso.onView(ViewMatchers.withId(R.id.bottom_toolbar_home))
|
customMainActivity: CustomMainActivity
|
||||||
.perform(ViewActions.click())
|
) {
|
||||||
})
|
composeTestRule.apply {
|
||||||
|
onNodeWithContentDescription(customMainActivity.getString(R.string.menu_home))
|
||||||
|
.performClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnAFoolForYouArticle() {
|
fun clickOnAFoolForYouArticle() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user