-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from SwEnt-Group8/feat/make-icon-change-color…
…-in-function-of-nb-event Feat/make icon change color in function of nb event
- Loading branch information
Showing
3 changed files
with
125 additions
and
1 deletion.
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
45 changes: 45 additions & 0 deletions
45
app/src/test/java/com/android/streetworkapp/ui/map/ColorTest.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,45 @@ | ||
package com.android.streetworkapp.ui.map | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class ColorTest { | ||
// test gradientColor | ||
@Test | ||
fun testGradientColorFraction0() { | ||
val startColor = Color(1f, 0f, 0f, 1f) // Red color | ||
val endColor = Color(0f, 0f, 1f, 1f) // Blue color | ||
val result = gradientColor(startColor, endColor, 0f) | ||
|
||
assertEquals(startColor, result) | ||
} | ||
|
||
@Test | ||
fun testGradientColorFraction1() { | ||
val startColor = Color(1f, 0f, 0f, 1f) // Red color | ||
val endColor = Color(0f, 0f, 1f, 1f) // Blue color | ||
val result = gradientColor(startColor, endColor, 1f) | ||
|
||
assertEquals(endColor, result) | ||
} | ||
|
||
@Test | ||
fun testGradientColorFraction05() { | ||
val startColor = Color(1f, 0f, 0f, 1f) // Red color | ||
val endColor = Color(0f, 0f, 1f, 1f) // Blue color | ||
val expectedColor = Color(0.5f, 0f, 0.5f, 1f) // Expected midpoint color (purple) | ||
|
||
val result = gradientColor(startColor, endColor, 0.5f) | ||
|
||
assertEquals(expectedColor, result) | ||
} | ||
// test colorToHue | ||
@Test | ||
fun testColorToHueRed() { | ||
val color = Color(1f, 0f, 0f, 1f) // Red color | ||
val result = colorToHue(color) | ||
|
||
assertEquals(0f, result, 0.1f) // Red has hue 0 | ||
} | ||
} |