File tree Expand file tree Collapse file tree
androidTest/java/org/nitri/opentopo/util
test/java/org/nitri/opentopo/ui/color Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org.nitri.opentopo.util
2+
3+ import androidx.preference.PreferenceManager
4+ import androidx.test.ext.junit.runners.AndroidJUnit4
5+ import androidx.test.platform.app.InstrumentationRegistry
6+ import org.junit.Assert.assertEquals
7+ import org.junit.Before
8+ import org.junit.Test
9+ import org.junit.runner.RunWith
10+ import org.nitri.opentopo.defaultGpxTrackColor
11+ import org.nitri.opentopo.SettingsActivity
12+ import org.nitri.opentopo.ui.color.DEFAULT_GPX_TRACK_COLOR
13+
14+ @RunWith(AndroidJUnit4 ::class )
15+ class GpxPreferenceTest {
16+
17+ private val context = InstrumentationRegistry .getInstrumentation().targetContext
18+
19+ @Before
20+ fun setup () {
21+ PreferenceManager .getDefaultSharedPreferences(context).edit().clear().commit()
22+ }
23+
24+ @Test
25+ fun defaultGpxTrackColor_returnsDefaultWhenUnset () {
26+ assertEquals(DEFAULT_GPX_TRACK_COLOR , context.defaultGpxTrackColor())
27+ }
28+
29+ @Test
30+ fun defaultGpxTrackColor_returnsStoredValue () {
31+ val customColor = 0xFF654321 .toInt()
32+ PreferenceManager .getDefaultSharedPreferences(context).edit()
33+ .putInt(SettingsActivity .PREF_GPX_TRACK_COLOR , customColor)
34+ .commit()
35+
36+ assertEquals(customColor, context.defaultGpxTrackColor())
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ package org.nitri.opentopo.ui.color
2+
3+ import org.junit.Assert.assertTrue
4+ import org.junit.Test
5+
6+ class PaletteTest {
7+
8+ @Test
9+ fun testPalette () {
10+ assertTrue(" Default GPX color should be in the palette" ,
11+ APP_COLOR_PALETTE .contains(DEFAULT_GPX_TRACK_COLOR ))
12+
13+ assertTrue(" Legacy marker color should be in the palette" ,
14+ APP_COLOR_PALETTE .contains(DEFAULT_MARKER_COLOR ))
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments