Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaba
fenix
Commits
6c68e79a
Commit
6c68e79a
authored
Nov 11, 2020
by
Kate Glazko
Committed by
kglazko
Nov 11, 2020
Browse files
For #14772: Crash in Downloads
parent
729f46ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/library/downloads/DownloadFragment.kt
View file @
6c68e79a
...
...
@@ -91,7 +91,7 @@ class DownloadFragment : LibraryPageFragment<DownloadItem>(), UserInteractionHan
it
.
id
,
it
.
fileName
,
it
.
filePath
,
it
.
contentLength
.
toString
(),
it
.
contentLength
?
.
toString
()
?:
"0"
,
it
.
contentType
,
it
.
status
)
...
...
app/src/test/java/org/mozilla/fenix/library/downloads/DownloadFragmentTest.kt
View file @
6c68e79a
...
...
@@ -48,7 +48,7 @@ class DownloadFragmentTest {
"3"
,
"3.pdf"
,
downloadedFile3
.
path
,
"
null
"
,
"
0
"
,
null
,
DownloadState
.
Status
.
COMPLETED
),
...
...
@@ -56,7 +56,7 @@ class DownloadFragmentTest {
"2"
,
"2.pdf"
,
downloadedFile2
.
path
,
"
null
"
,
"
0
"
,
null
,
DownloadState
.
Status
.
COMPLETED
),
...
...
@@ -64,7 +64,7 @@ class DownloadFragmentTest {
"1"
,
"1.pdf"
,
downloadedFile1
.
path
,
"
null
"
,
"
0
"
,
null
,
DownloadState
.
Status
.
COMPLETED
)
...
...
@@ -104,4 +104,43 @@ class DownloadFragmentTest {
downloadedFile2
.
delete
()
downloadedFile3
.
delete
()
}
@Test
fun
`downloads
with
null
content
length
don
'
t
crash`
()
{
val
downloadedFile0
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
),
"1.pdf"
)
downloadedFile0
.
createNewFile
()
val
fragment
=
DownloadFragment
()
val
expectedList
=
listOf
(
DownloadItem
(
"1"
,
"1.pdf"
,
downloadedFile0
.
path
,
"0"
,
null
,
DownloadState
.
Status
.
COMPLETED
)
)
val
state
:
BrowserState
=
mockk
(
relaxed
=
true
)
every
{
state
.
downloads
}
returns
mapOf
(
"1"
to
DownloadState
(
id
=
"1"
,
createdTime
=
1
,
url
=
"url"
,
fileName
=
"1.pdf"
,
contentLength
=
null
,
status
=
DownloadState
.
Status
.
COMPLETED
)
)
val
list
=
fragment
.
provideDownloads
(
state
)
assertEquals
(
expectedList
[
0
].
size
,
list
[
0
].
size
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment