-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50483fd
commit 045895c
Showing
3 changed files
with
131 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package android.content; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* mocks ContentValues for non-instrumented tests | ||
*/ | ||
public class ContentValues | ||
{ | ||
protected HashMap<String, String> stringValues = new HashMap<>(); | ||
protected HashMap<String, Boolean> boolValues = new HashMap<>(); | ||
protected HashMap<String, CharSequence> charSequenceValues = new HashMap<>(); | ||
protected HashMap<String, Integer> intValues = new HashMap<>(); | ||
protected HashMap<String, Double> doubleValues = new HashMap<>(); | ||
protected HashMap<String, Long> longValues = new HashMap<>(); | ||
protected HashMap<String, Short> shortValues = new HashMap<>(); | ||
protected HashMap<String, Float> floatValues = new HashMap<>(); | ||
|
||
public void put(String key, String value) { | ||
stringValues.put(key, value); | ||
} | ||
public String getAsString(String key) { | ||
return stringValues.containsKey(key) ? stringValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, CharSequence value) { | ||
charSequenceValues.put(key, value); | ||
} | ||
public CharSequence getAsCharSequence(String key) { | ||
return charSequenceValues.containsKey(key) ? charSequenceValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Boolean value) { | ||
boolValues.put(key, value); | ||
} | ||
public Boolean getAsBoolean(String key) { | ||
return boolValues.containsKey(key) ? boolValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Integer value) { | ||
intValues.put(key, value); | ||
} | ||
public Integer getAsInteger(String key) { | ||
return intValues.containsKey(key) ? intValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Double value) { | ||
doubleValues.put(key, value); | ||
} | ||
public Double getAsDouble(String key) { | ||
return doubleValues.containsKey(key) ? doubleValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Long value) { | ||
longValues.put(key, value); | ||
} | ||
public Long getAsLong(String key) { | ||
return longValues.containsKey(key) ? longValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Short value) { | ||
shortValues.put(key, value); | ||
} | ||
public Short getAsShort(String key) { | ||
return shortValues.containsKey(key) ? shortValues.get(key) : null; | ||
} | ||
|
||
public void put(String key, Float value) { floatValues.put(key, value); | ||
} | ||
public Float getAsFloat(String key) { | ||
return floatValues.containsKey(key) ? floatValues.get(key) : null; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/test/java/com/forrestguice/suntimeswidget/events/EventSettingsTest0.java
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,58 @@ | ||
/** | ||
Copyright (C) 2022 Forrest Guice | ||
This file is part of SuntimesWidget. | ||
SuntimesWidget is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
SuntimesWidget is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with SuntimesWidget. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.forrestguice.suntimeswidget.events; | ||
|
||
import android.graphics.Color; | ||
|
||
import com.forrestguice.suntimeswidget.alarmclock.AlarmEventProvider; | ||
|
||
import org.junit.Test; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
|
||
public class EventSettingsTest0 | ||
{ | ||
@Test | ||
public void test_eventAlias() | ||
{ | ||
AlarmEventProvider.EventType type0 = AlarmEventProvider.EventType.SUN_ELEVATION; | ||
String id0 = "TEST0"; | ||
String label0 = "label0"; | ||
String uri0 = "uri0"; | ||
Integer color0 = Color.GREEN; | ||
|
||
EventSettings.EventAlias alias0 = new EventSettings.EventAlias(AlarmEventProvider.EventType.SUN_ELEVATION, id0, label0, color0, uri0, false); | ||
verify_eventAlias(type0, id0, label0, color0, uri0, alias0); | ||
|
||
EventSettings.EventAlias alias1 = new EventSettings.EventAlias(alias0); | ||
verify_eventAlias(type0, id0, label0, color0, uri0, alias1); | ||
|
||
EventSettings.EventAlias alias2 = new EventSettings.EventAlias(alias0.toContentValues()); | ||
verify_eventAlias(type0, id0, label0, color0, uri0, alias2); | ||
} | ||
|
||
protected void verify_eventAlias(AlarmEventProvider.EventType type, String id, String label, Integer color, String uri, EventSettings.EventAlias alias) | ||
{ | ||
assertEquals(type, alias.getType()); | ||
assertEquals(id, alias.getID()); | ||
assertEquals(label, alias.getLabel()); | ||
assertEquals(color, alias.getColor()); | ||
assertEquals(uri, alias.getUri()); | ||
} | ||
} |