[fenix] For https://github.com/mozilla-mobile/fenix/issues/9100: Follow-up to fix memory leak in NotificationSessionObserver
The observer was moved and is now bound to the activity and its context. If the activity is re-created we leak the observer and therefore the activity itself. With this we make sure to stop the observer and also don't use the activity context to begin with.pull/600/head
parent
8a4c534741
commit
7d50b70b61
@ -0,0 +1,27 @@
|
||||
/* 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.session
|
||||
|
||||
import mozilla.components.support.test.robolectric.testContext
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
|
||||
@RunWith(FenixRobolectricTestRunner::class)
|
||||
class SessionNotificationServiceTest {
|
||||
|
||||
@Test
|
||||
fun `Service keeps tracked of started state`() {
|
||||
assertFalse(SessionNotificationService.started)
|
||||
|
||||
SessionNotificationService.start(testContext, false)
|
||||
assertTrue(SessionNotificationService.started)
|
||||
|
||||
SessionNotificationService.stop(testContext)
|
||||
assertFalse(SessionNotificationService.started)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue