-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lowMemory): align the app.lowMemory field for JVM and NDK
- Loading branch information
Showing
10 changed files
with
107 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...roid-core/src/test/java/com/bugsnag/android/ClientComponentCallbacksMemoryCallbackTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.bugsnag.android | ||
|
||
import android.content.ComponentCallbacks2 | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mock | ||
import org.mockito.junit.MockitoJUnitRunner | ||
|
||
@RunWith(MockitoJUnitRunner::class) | ||
class ClientComponentCallbacksMemoryCallbackTest { | ||
|
||
@Mock | ||
internal lateinit var deviceDataCollector: DeviceDataCollector | ||
private lateinit var clientComponentCallbacks: ClientComponentCallbacks | ||
|
||
private var isLowMemory: Boolean? = null | ||
|
||
@Before | ||
fun setUp() { | ||
clientComponentCallbacks = ClientComponentCallbacks( | ||
deviceDataCollector, | ||
{ _: String?, _: String? -> }, | ||
this::isLowMemory::set | ||
) | ||
isLowMemory = null | ||
} | ||
|
||
@Test | ||
fun testLegacyLowMemory() { | ||
clientComponentCallbacks.onLowMemory() | ||
assertEquals(true, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryRunningModerate() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryRunningLow() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryRunningCritical() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryUiHidden() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryBackground() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryModerate() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_MODERATE) | ||
assertEquals(false, isLowMemory) | ||
} | ||
|
||
@Test | ||
fun trimMemoryComplete() { | ||
clientComponentCallbacks.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE) | ||
assertEquals(true, isLowMemory) | ||
} | ||
} |