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
The Tor Project
Applications
android-components
Commits
c39efcbc
Commit
c39efcbc
authored
Feb 14, 2020
by
Simon Chae
Browse files
Closes #5940: Use notifyItemRemoved when uninstalling unsupported add-on
parent
1a11c13b
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/feature/addons/src/main/java/mozilla/components/feature/addons/ui/UnsupportedAddonsAdapter.kt
View file @
c39efcbc
...
...
@@ -63,7 +63,7 @@ class UnsupportedAddonsAdapter(
val
uninstalledAddon
=
unsupportedAddons
[
position
]
unsupportedAddons
.
remove
(
uninstalledAddon
)
notifyItem
Chang
ed
(
position
)
notifyItem
Remov
ed
(
position
)
unsupportedAddonsAdapterDelegate
.
onUninstallSuccess
()
}
...
...
components/feature/addons/src/test/java/mozilla/components/feature/addons/ui/UnsupportedAddonsAdapterTest.kt
View file @
c39efcbc
...
...
@@ -17,6 +17,7 @@ import org.junit.Assert.assertEquals
import
org.junit.Rule
import
org.junit.Test
import
org.junit.runner.RunWith
import
org.mockito.Mockito.spy
import
org.mockito.Mockito.times
import
org.mockito.Mockito.verify
...
...
@@ -35,24 +36,29 @@ class UnsupportedAddonsAdapterTest {
val
unsupportedAddonsAdapterDelegate
:
UnsupportedAddonsAdapterDelegate
=
mock
()
val
unsupportedAddons
=
listOf
(
Addon
(
"id1"
),
Addon
(
"id2"
))
val
adapter
=
UnsupportedAddonsAdapter
(
addonManager
,
unsupportedAddonsAdapterDelegate
,
unsupportedAddons
val
adapter
=
spy
(
UnsupportedAddonsAdapter
(
addonManager
,
unsupportedAddonsAdapterDelegate
,
unsupportedAddons
)
)
adapter
.
removeUninstalledAddonAtPosition
(
0
)
testDispatcher
.
advanceUntilIdle
()
verify
(
unsupportedAddonsAdapterDelegate
,
times
(
1
)).
onUninstallSuccess
()
verify
(
adapter
,
times
(
1
)).
notifyItemRemoved
(
0
)
assertEquals
(
1
,
adapter
.
itemCount
)
adapter
.
removeUninstalledAddonAtPosition
(
0
)
testDispatcher
.
advanceUntilIdle
()
verify
(
unsupportedAddonsAdapterDelegate
,
times
(
2
)).
onUninstallSuccess
()
verify
(
adapter
,
times
(
2
)).
notifyItemRemoved
(
0
)
assertEquals
(
0
,
adapter
.
itemCount
)
adapter
.
removeUninstalledAddonAtPosition
(
0
)
testDispatcher
.
advanceUntilIdle
()
verify
(
unsupportedAddonsAdapterDelegate
,
times
(
2
)).
onUninstallSuccess
()
verify
(
adapter
,
times
(
2
)).
notifyItemRemoved
(
0
)
}
}
Write
Preview
Supports
Markdown
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