2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

For #21816: Filename in "Open" PDF dialog overflows screen

Changing the download file name length to the max allowed by AS (251 char, won’t compile if more; max would be 260 for latest windows versions, but generally it is 255), and changing the UI test to check if the long file name is fully visible.
Changing the downloaded dialog layout to properly display really long file names.
This commit is contained in:
mike a 2021-11-03 21:45:16 -07:00 committed by mergify[bot]
parent 5b889fdb96
commit d69b5ed456
7 changed files with 18 additions and 10 deletions

View File

@ -1,6 +1,6 @@
<html>
<body>
<a id="link" href="../resources/Globe.svg" download>Page content: Globe.svg</a>
<a id="link" href="../resources/tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFHPSD4wzCkRWiaOorNI574zLtv4Hjiz6O6T7onmUTGgUQ2YQoiQFyrCrPv8ZB9KvmtoRFRVIZh8Pg2a1THrm9gpMoLwP44nDNN5o70USUyVXFxPeTerG9OSdpZIwCWGIVM3AZmjFSaiAyZKxJp8G1oZ2md4DBQYy6F1.svg" download>Page content: tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFHPSD4wzCkRWiaOorNI574zLtv4Hjiz6O6T7onmUTGgUQ2YQoiQFyrCrPv8ZB9KvmtoRFRVIZh8Pg2a1THrm9gpMoLwP44nDNN5o70USUyVXFxPeTerG9OSdpZIwCWGIVM3AZmjFSaiAyZKxJp8G1oZ2md4DBQYy6F1.svg</a>
<script>
(function() {
document.getElementById("link").click()

View File

@ -17,6 +17,11 @@ object TestAssetHelper {
@Suppress("MagicNumber")
val waitingTime: Long = TimeUnit.SECONDS.toMillis(15)
val waitingTimeShort: Long = TimeUnit.SECONDS.toMillis(1)
// File name length in most operating systems is limited to 255 bytes,
// including file extension.
// This string is 251 char long though, as Android Studio won't compile
// with a resource file having a name longer than 251 chars.
const val downloadFileName = "tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFHPSD4wzCkRWiaOorNI574zLtv4Hjiz6O6T7onmUTGgUQ2YQoiQFyrCrPv8ZB9KvmtoRFRVIZh8Pg2a1THrm9gpMoLwP44nDNN5o70USUyVXFxPeTerG9OSdpZIwCWGIVM3AZmjFSaiAyZKxJp8G1oZ2md4DBQYy6F1.svg"
data class TestAsset(val url: Uri, val content: String, val title: String)
@ -70,7 +75,7 @@ object TestAssetHelper {
fun getDownloadAsset(server: MockWebServer): TestAsset {
val url = server.url("pages/download.html").toString().toUri()!!
val content = "Page content: Globe.svg"
val content = "Page content: $downloadFileName"
return TestAsset(url, content, "")
}

View File

@ -15,6 +15,7 @@ import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.downloadFileName
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.ui.robots.downloadRobot
import org.mozilla.fenix.ui.robots.navigationToolbar
@ -31,7 +32,6 @@ import org.mozilla.fenix.ui.robots.notificationShade
class DownloadTest {
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
@ -56,7 +56,7 @@ class DownloadTest {
fun tearDown() {
mockWebServer.shutdown()
TestHelper.deleteDownloadFromStorage("Globe.svg")
TestHelper.deleteDownloadFromStorage(downloadFileName)
}
@Test

View File

@ -30,6 +30,7 @@ import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.downloadFileName
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.appName
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
@ -69,7 +70,6 @@ class SmokeTest {
private var addonsListIdlingResource: RecyclerViewIdlingResource? = null
private var recentlyClosedTabsListIdlingResource: RecyclerViewIdlingResource? = null
private var readerViewNotification: ViewVisibilityIdlingResource? = null
private val downloadFileName = "Globe.svg"
private val collectionName = "First Collection"
private var bookmarksListIdlingResource: RecyclerViewIdlingResource? = null
private var localeListIdlingResource: RecyclerViewIdlingResource? = null

View File

@ -12,6 +12,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withId
@ -132,6 +133,8 @@ private fun assertDownloadNotificationPopup() {
mDevice.waitNotNull(Until.findObjects(By.text("Open")), TestAssetHelper.waitingTime)
onView(withId(R.id.download_dialog_title))
.check(matches(withText(CoreMatchers.containsString("Download completed"))))
onView(withId(R.id.download_dialog_filename))
.check(matches(ViewMatchers.isCompletelyDisplayed()))
}
private fun closePromptButton() =

View File

@ -8,7 +8,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?foundation"
android:paddingBottom="4dp">
android:paddingBottom="12dp">
<ImageView
android:id="@+id/download_dialog_icon"
@ -55,17 +55,19 @@
<TextView
android:id="@+id/download_dialog_filename"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:paddingStart="5dp"
android:paddingTop="4dp"
android:paddingEnd="5dp"
android:textColor="?primaryText"
app:layout_constraintStart_toEndOf="@id/download_dialog_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/download_dialog_title"
tools:text="Firefox_Preview_v2.1.apk" />
tools:text="l38ID7Xze57vCac8C9oD7Z2LXzBw00HDiw7XR6ZDu5G5O8uyODAVEOTS2PrZt8OoBM77CmaFyrdGxUODuEWwpfzwnTsTTRcGDsr6Cez4Q7DK0Kr0KJIRVAFbV4czwMeiI25FIml6QCMvQR8nBZHe1oUPQn23BplLC4c3iXGvuEBGEhyU81UpqqTSwU5tfxZ7mBOYcQUqYNG0A7ixekg9awVeq8PncVdCZKLA0hXgJEW4.svg" />
<com.google.android.material.button.MaterialButton
android:id="@+id/download_dialog_action_button"
@ -73,11 +75,9 @@
android:layout_width="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:backgroundTint="?accent"
android:text="@string/mozac_feature_downloads_button_open"
android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/download_dialog_filename" />
</androidx.constraintlayout.widget.ConstraintLayout>