Rename checkmark values to NO, YES_AUTO, YES_MANUAL and SKIP

This makes the source code consistent with the user interface.
pull/638/head
Alinson S. Xavier 5 years ago
parent d59ab89426
commit b72cad5316

@ -80,11 +80,11 @@ public class HistoryChartTest extends BaseViewTest
chart.setIsEditable(true);
chart.tap(dpToPixels(340), dpToPixels(40));
verify(controller).onToggleCheckmark(today, Checkmark.SKIPPED);
verify(controller).onToggleCheckmark(today, Checkmark.SKIP);
chart.tap(dpToPixels(340), dpToPixels(40));
verify(controller).onToggleCheckmark(today, Checkmark.UNCHECKED);
verify(controller).onToggleCheckmark(today, Checkmark.NO);
chart.tap(dpToPixels(340), dpToPixels(40));
verify(controller).onToggleCheckmark(today, Checkmark.CHECKED_EXPLICITLY);
verify(controller).onToggleCheckmark(today, Checkmark.YES_MANUAL);
verifyNoMoreInteractions(controller);
}
@ -94,7 +94,7 @@ public class HistoryChartTest extends BaseViewTest
chart.setIsEditable(true);
chart.setCheckmarks(new int[]{});
chart.tap(dpToPixels(340), dpToPixels(40));
verify(controller).onToggleCheckmark(today, Checkmark.CHECKED_EXPLICITLY);
verify(controller).onToggleCheckmark(today, Checkmark.YES_MANUAL);
verifyNoMoreInteractions(controller);
}

@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.list.views
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.*
import androidx.test.runner.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.utils.*
@ -41,7 +40,7 @@ class CheckmarkButtonViewTest : BaseViewTest() {
override fun setUp() {
super.setUp()
view = component.getCheckmarkButtonViewFactory().create().apply {
value = Checkmark.UNCHECKED
value = Checkmark.NO
color = PaletteUtils.getAndroidTestColor(5)
onToggle = { toggled = true }
}
@ -50,19 +49,19 @@ class CheckmarkButtonViewTest : BaseViewTest() {
@Test
fun testRender_explicitCheck() {
view.value = Checkmark.CHECKED_EXPLICITLY
view.value = Checkmark.YES_MANUAL
assertRendersCheckedExplicitly()
}
@Test
fun testRender_implicitCheck() {
view.value = Checkmark.CHECKED_IMPLICITLY
view.value = Checkmark.YES_AUTO
assertRendersCheckedImplicitly()
}
@Test
fun testRender_unchecked() {
view.value = Checkmark.UNCHECKED
view.value = Checkmark.NO
assertRendersUnchecked()
}

@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.list.views
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.*
import androidx.test.runner.*
import org.hamcrest.CoreMatchers.*
import org.hamcrest.MatcherAssert.*
import org.isoron.uhabits.*
@ -43,13 +42,13 @@ class CheckmarkPanelViewTest : BaseViewTest() {
super.setUp()
prefs.isCheckmarkSequenceReversed = false
val checkmarks = intArrayOf(CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_IMPLICITLY,
UNCHECKED,
UNCHECKED,
UNCHECKED,
CHECKED_EXPLICITLY)
val checkmarks = intArrayOf(YES_MANUAL,
YES_MANUAL,
YES_AUTO,
NO,
NO,
NO,
YES_MANUAL)
view = component.getCheckmarkPanelViewFactory().create().apply {
values = checkmarks

@ -20,7 +20,7 @@
package org.isoron.uhabits.widgets;
import androidx.test.filters.*;
import androidx.test.runner.*;
import android.widget.*;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@ -58,7 +58,7 @@ public class CheckmarkWidgetTest extends BaseViewTest
CheckmarkWidget widget = new CheckmarkWidget(targetContext, 0, habit);
view = convertToView(widget, 150, 200);
assertThat(checkmarks.getTodayValue(), equalTo(CHECKED_EXPLICITLY));
assertThat(checkmarks.getTodayValue(), equalTo(YES_MANUAL));
}
@Test
@ -71,11 +71,11 @@ public class CheckmarkWidgetTest extends BaseViewTest
// possible to capture intents sent to BroadcastReceivers.
button.performClick();
sleep(1000);
assertThat(checkmarks.getTodayValue(), equalTo(SKIPPED));
assertThat(checkmarks.getTodayValue(), equalTo(SKIP));
button.performClick();
sleep(1000);
assertThat(checkmarks.getTodayValue(), equalTo(UNCHECKED));
assertThat(checkmarks.getTodayValue(), equalTo(NO));
}
@Test

@ -70,7 +70,7 @@ public class CheckmarkWidgetViewTest extends BaseViewTest
// @Test
// public void testRender_implicitlyChecked() throws IOException
// {
// view.setCheckmarkValue(Checkmark.CHECKED_IMPLICITLY);
// view.setCheckmarkValue(Checkmark.YES_AUTO);
// view.refresh();
// assertRenders(view, PATH + "implicitly_checked.png");
// }
@ -85,7 +85,7 @@ public class CheckmarkWidgetViewTest extends BaseViewTest
// @Test
// public void testRender_unchecked() throws IOException
// {
// view.setCheckmarkValue(Checkmark.UNCHECKED);
// view.setCheckmarkValue(Checkmark.NO);
// view.refresh();
// assertRenders(view, PATH + "unchecked.png");
// }

@ -149,7 +149,7 @@ public class HistoryChart extends ScrollableChart
if (timestamp == null) return false;
Timestamp today = DateUtils.getToday();
int newValue = CHECKED_EXPLICITLY;
int newValue = YES_MANUAL;
int offset = timestamp.daysUntil(today);
if (offset < checkmarks.length)
{
@ -385,7 +385,7 @@ public class HistoryChart extends ScrollableChart
pSquareBg.setColor(colors[0]);
pSquareFg.setColor(textColors[1]);
}
else if ((isNumerical && checkmark < target) || checkmark != CHECKED_EXPLICITLY)
else if ((isNumerical && checkmark < target) || checkmark != YES_MANUAL)
{
pSquareBg.setColor(colors[1]);
pSquareFg.setColor(textColors[2]);
@ -400,7 +400,7 @@ public class HistoryChart extends ScrollableChart
float round = dpToPixels(getContext(), 2);
canvas.drawRoundRect(location, round, round, pSquareBg);
if (!isNumerical && checkmark == SKIPPED)
if (!isNumerical && checkmark == SKIP)
{
pSquareBg.setColor(backgroundColor);
pSquareBg.setStrokeWidth(columnWidth * 0.025f);

@ -103,14 +103,14 @@ class CheckmarkButtonView(
fun draw(canvas: Canvas) {
paint.color = when (value) {
CHECKED_EXPLICITLY -> color
SKIPPED -> color
YES_MANUAL -> color
SKIP -> color
else -> lowContrastColor
}
val id = when (value) {
SKIPPED -> R.string.fa_skipped
CHECKED_IMPLICITLY -> R.string.fa_skipped
UNCHECKED -> R.string.fa_times
SKIP -> R.string.fa_skipped
YES_AUTO -> R.string.fa_skipped
NO -> R.string.fa_times
else -> R.string.fa_check
}
val label = resources.getString(id)

@ -62,7 +62,7 @@ class CheckmarkPanelView(
val timestamp = today.minus(index + dataOffset)
button.value = when {
index + dataOffset < values.size -> values[index + dataOffset]
else -> UNCHECKED
else -> NO
}
button.color = color
button.onToggle = { value -> onToggle(timestamp, value) }

@ -67,9 +67,9 @@ open class CheckmarkWidget(
private fun getNumericalCheckmarkState(): Int {
return if (habit.isCompletedToday) {
Checkmark.CHECKED_EXPLICITLY
Checkmark.YES_MANUAL
} else {
Checkmark.UNCHECKED
Checkmark.NO
}
}

@ -75,8 +75,8 @@ public class CheckmarkWidgetView extends HabitWidgetView {
int fgColor;
switch (checkmarkState) {
case Checkmark.CHECKED_EXPLICITLY:
case Checkmark.SKIPPED:
case Checkmark.YES_MANUAL:
case Checkmark.SKIP:
bgColor = activeColor;
fgColor = res.getColor(R.attr.highContrastReverseTextColor);
setShadowAlpha(0x4f);
@ -84,8 +84,8 @@ public class CheckmarkWidgetView extends HabitWidgetView {
frame.setBackgroundDrawable(background);
break;
case Checkmark.CHECKED_IMPLICITLY:
case Checkmark.UNCHECKED:
case Checkmark.YES_AUTO:
case Checkmark.NO:
default:
getResources().getString(R.string.fa_times);
bgColor = res.getColor(R.attr.cardBgColor);
@ -115,12 +115,12 @@ public class CheckmarkWidgetView extends HabitWidgetView {
{
if (isNumerical) return NumberButtonViewKt.toShortString(checkmarkValue / 1000.0);
switch (checkmarkState) {
case Checkmark.CHECKED_EXPLICITLY:
case Checkmark.YES_MANUAL:
return getResources().getString(R.string.fa_check);
case Checkmark.CHECKED_IMPLICITLY:
case Checkmark.SKIPPED:
case Checkmark.YES_AUTO:
case Checkmark.SKIP:
return getResources().getString(R.string.fa_skipped);
case Checkmark.UNCHECKED:
case Checkmark.NO:
default:
return getResources().getString(R.string.fa_times);
}
@ -204,7 +204,7 @@ public class CheckmarkWidgetView extends HabitWidgetView {
percentage = 0.75f;
name = "Wake up early";
activeColor = PaletteUtils.getAndroidTestColor(6);
checkmarkValue = Checkmark.CHECKED_EXPLICITLY;
checkmarkValue = Checkmark.YES_MANUAL;
refresh();
}
}

@ -62,7 +62,7 @@ public class WidgetControllerTest extends BaseAndroidJVMTest
{
habit.getRepetitions().toggle(today);
int todayValue = habit.getCheckmarks().getTodayValue();
assertThat(todayValue, equalTo(CHECKED_EXPLICITLY));
assertThat(todayValue, equalTo(YES_MANUAL));
controller.onAddRepetition(habit, today);
verifyZeroInteractions(commandRunner);
}
@ -71,7 +71,7 @@ public class WidgetControllerTest extends BaseAndroidJVMTest
public void testOnAddRepetition_whenUnchecked() throws Exception
{
int todayValue = habit.getCheckmarks().getTodayValue();
assertThat(todayValue, equalTo(UNCHECKED));
assertThat(todayValue, equalTo(NO));
controller.onAddRepetition(habit, today);
verify(commandRunner).execute(any(), isNull());
verify(notificationTray).cancel(habit);
@ -82,7 +82,7 @@ public class WidgetControllerTest extends BaseAndroidJVMTest
{
habit.getRepetitions().toggle(today);
int todayValue = habit.getCheckmarks().getTodayValue();
assertThat(todayValue, equalTo(CHECKED_EXPLICITLY));
assertThat(todayValue, equalTo(YES_MANUAL));
controller.onRemoveRepetition(habit, today);
verify(commandRunner).execute(any(), isNull());
}
@ -91,7 +91,7 @@ public class WidgetControllerTest extends BaseAndroidJVMTest
public void testOnRemoveRepetition_whenUnchecked() throws Exception
{
int todayValue = habit.getCheckmarks().getTodayValue();
assertThat(todayValue, equalTo(UNCHECKED));
assertThat(todayValue, equalTo(NO));
controller.onRemoveRepetition(habit, today);
verifyZeroInteractions(commandRunner);
}

@ -40,32 +40,31 @@ public final class Checkmark
/**
* Indicates that there was an explicit skip at the timestamp.
*/
public static final int SKIPPED = 3;
public static final int SKIP = 3;
/**
* Indicates that there was a repetition at the timestamp.
*/
public static final int CHECKED_EXPLICITLY = 2;
public static final int YES_MANUAL = 2;
/**
* Indicates that there was no repetition at the timestamp, but one was not
* expected in any case, due to the frequency of the habit.
*/
public static final int CHECKED_IMPLICITLY = 1;
public static final int YES_AUTO = 1;
/**
* Indicates that there was no repetition at the timestamp, even though a
* repetition was expected.
*/
public static final int UNCHECKED = 0;
public static final int NO = 0;
private final Timestamp timestamp;
/**
* The value of the checkmark.
* <p>
* For boolean habits, this equals either UNCHECKED, CHECKED_EXPLICITLY, CHECKED_IMPLICITLY
* or SKIPPED.
* For boolean habits, this equals either NO, YES_AUTO, YES_MANUAL or SKIP.
* <p>
* For numerical habits, this number is stored in thousandths. That
* is, if the user enters value 1.50 on the app, it is stored as 1500.

@ -62,7 +62,7 @@ public abstract class CheckmarkList
int nDays = begin.daysUntil(today) + 1;
List<Checkmark> checkmarks = new ArrayList<>(nDays);
for (int i = 0; i < nDays; i++)
checkmarks.add(new Checkmark(today.minus(i), UNCHECKED));
checkmarks.add(new Checkmark(today.minus(i), NO));
for (Interval interval : intervals)
{
@ -71,7 +71,7 @@ public abstract class CheckmarkList
Timestamp date = interval.begin.plus(i);
int offset = date.daysUntil(today);
if (offset < 0) continue;
checkmarks.set(offset, new Checkmark(date, CHECKED_IMPLICITLY));
checkmarks.set(offset, new Checkmark(date, YES_AUTO));
}
}
@ -102,7 +102,7 @@ public abstract class CheckmarkList
{
ArrayList<Repetition> filteredReps = new ArrayList<>();
for (Repetition r : reps)
if (r.getValue() == CHECKED_EXPLICITLY)
if (r.getValue() == YES_MANUAL)
filteredReps.add(r);
int num = freq.getNumerator();
@ -224,7 +224,7 @@ public abstract class CheckmarkList
{
Checkmark today = getToday();
if (today != null) return today.getValue();
else return UNCHECKED;
else return NO;
}
public synchronized int getThisWeekValue(int firstWeekday)
@ -480,7 +480,7 @@ public abstract class CheckmarkList
if(habit.isNumerical())
values[count - 1] += rep.getValue();
else if(rep.getValue() == Checkmark.CHECKED_EXPLICITLY)
else if(rep.getValue() == Checkmark.YES_MANUAL)
values[count - 1] += 1000;
}

@ -331,7 +331,7 @@ public class Habit
else
return todayCheckmark / 1000.0 <= data.targetValue;
}
else return (todayCheckmark != UNCHECKED);
else return (todayCheckmark != NO);
}
public synchronized boolean isNumerical()

@ -20,12 +20,6 @@
package org.isoron.uhabits.core.models;
import org.apache.commons.lang3.builder.*;
import org.isoron.uhabits.core.utils.DateFormats;
import org.isoron.uhabits.core.utils.DateUtils;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.utils.StringUtils.defaultToStringStyle;
@ -42,7 +36,7 @@ public final class Repetition
/**
* The value of the repetition.
*
* For boolean habits, this equals CHECKED_EXPLICITLY if performed or SKIPPED if skipped.
* For boolean habits, this equals YES_MANUAL if performed or SKIP if skipped.
* For numerical habits, this number is stored in thousandths. That is, if the user enters
* value 1.50 on the app, it is here stored as 1500.
*/
@ -65,14 +59,14 @@ public final class Repetition
public static int nextToggleValue(int value)
{
switch(value) {
case UNCHECKED:
case CHECKED_IMPLICITLY:
return CHECKED_EXPLICITLY;
case CHECKED_EXPLICITLY:
return SKIPPED;
case NO:
case YES_AUTO:
return YES_MANUAL;
case YES_MANUAL:
return SKIP;
default:
case SKIPPED:
return UNCHECKED;
case SKIP:
return NO;
}
}

@ -140,7 +140,7 @@ public abstract class RepetitionList
for (Repetition r : reps)
{
if (!habit.isNumerical() && r.getValue() != Checkmark.CHECKED_EXPLICITLY)
if (!habit.isNumerical() && r.getValue() != Checkmark.YES_MANUAL)
continue;
Calendar date = r.getTimestamp().toCalendar();
@ -197,7 +197,7 @@ public abstract class RepetitionList
if (rep != null) remove(rep);
else
{
rep = new Repetition(timestamp, Checkmark.CHECKED_EXPLICITLY);
rep = new Repetition(timestamp, Checkmark.YES_MANUAL);
add(rep);
}

@ -68,7 +68,7 @@ public class MemoryCheckmarkList extends CheckmarkList
{
Timestamp t = to.minus(i);
if(t.isNewerThan(newestComputed) || t.isOlderThan(oldestComputed))
filtered.add(new Checkmark(t, Checkmark.UNCHECKED));
filtered.add(new Checkmark(t, Checkmark.NO));
else
filtered.add(list.get(t.daysUntil(newestComputed)));
}

@ -123,7 +123,7 @@ public class MemoryRepetitionList extends RepetitionList
{
int count = 0;
for (Repetition rep : list)
if (rep.getValue() == Checkmark.CHECKED_EXPLICITLY)
if (rep.getValue() == Checkmark.YES_MANUAL)
count++;
return count;
}

@ -186,7 +186,7 @@ public class NotificationTray
{
systemTray.log("Showing notification for habit=" + habit.id);
if (todayValue != Checkmark.UNCHECKED) {
if (todayValue != Checkmark.NO) {
systemTray.log(String.format(
Locale.US,
"Habit %d already checked. Skipping.",

@ -110,7 +110,7 @@ public class ShowHabitMenuBehavior
if (i % 7 == 0) strength = max(0, min(100, strength + 10 * random.nextGaussian()));
if (random.nextInt(100) > strength) continue;
int value = Checkmark.CHECKED_EXPLICITLY;
int value = Checkmark.YES_MANUAL;
if (habit.isNumerical())
value = (int) (1000 + 250 * random.nextGaussian() * strength / 100) * 1000;

@ -51,7 +51,7 @@ public class WidgetBehavior
notificationTray.cancel(habit);
Repetition rep = habit.getRepetitions().getByTimestamp(timestamp);
if (rep != null) return;
performToggle(habit, timestamp, Checkmark.CHECKED_EXPLICITLY);
performToggle(habit, timestamp, Checkmark.YES_MANUAL);
}
public void onRemoveRepetition(@NonNull Habit habit, Timestamp timestamp)
@ -59,13 +59,13 @@ public class WidgetBehavior
notificationTray.cancel(habit);
Repetition rep = habit.getRepetitions().getByTimestamp(timestamp);
if (rep == null) return;
performToggle(habit, timestamp, Checkmark.UNCHECKED);
performToggle(habit, timestamp, Checkmark.NO);
}
public void onToggleRepetition(@NonNull Habit habit, Timestamp timestamp)
{
Repetition previous = habit.getRepetitions().getByTimestamp(timestamp);
if(previous == null) performToggle(habit, timestamp, Checkmark.CHECKED_EXPLICITLY);
if(previous == null) performToggle(habit, timestamp, Checkmark.YES_MANUAL);
else performToggle(habit, timestamp, Repetition.nextToggleValue(previous.getValue()));
}

@ -57,7 +57,7 @@ public class CreateRepetitionCommandTest extends BaseUnitTest
Repetition rep = reps.getByTimestamp(today);
assertNotNull(rep);
assertEquals(CHECKED_EXPLICITLY, rep.getValue());
assertEquals(YES_MANUAL, rep.getValue());
command.execute();
rep = reps.getByTimestamp(today);
@ -67,7 +67,7 @@ public class CreateRepetitionCommandTest extends BaseUnitTest
command.undo();
rep = reps.getByTimestamp(today);
assertNotNull(rep);
assertEquals(CHECKED_EXPLICITLY, rep.getValue());
assertEquals(YES_MANUAL, rep.getValue());
}
@Test

@ -29,7 +29,6 @@ import java.util.*;
import nl.jqno.equalsverifier.*;
import static java.util.Calendar.*;
import static junit.framework.TestCase.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
@ -69,10 +68,10 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildCheckmarksFromIntervals_1() throws Exception
{
Repetition reps[] = new Repetition[]{
new Repetition(day(10), CHECKED_EXPLICITLY),
new Repetition(day(5), CHECKED_EXPLICITLY),
new Repetition(day(2), CHECKED_EXPLICITLY),
new Repetition(day(1), CHECKED_EXPLICITLY),
new Repetition(day(10), YES_MANUAL),
new Repetition(day(5), YES_MANUAL),
new Repetition(day(2), YES_MANUAL),
new Repetition(day(1), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
@ -81,17 +80,17 @@ public class CheckmarkListTest extends BaseUnitTest
intervals.add(new CheckmarkList.Interval(day(2), day(2), day(1)));
List<Checkmark> expected = new ArrayList<>();
expected.add(new Checkmark(day(0), UNCHECKED));
expected.add(new Checkmark(day(1), CHECKED_EXPLICITLY));
expected.add(new Checkmark(day(2), CHECKED_EXPLICITLY));
expected.add(new Checkmark(day(3), UNCHECKED));
expected.add(new Checkmark(day(4), CHECKED_IMPLICITLY));
expected.add(new Checkmark(day(5), CHECKED_EXPLICITLY));
expected.add(new Checkmark(day(6), CHECKED_IMPLICITLY));
expected.add(new Checkmark(day(7), UNCHECKED));
expected.add(new Checkmark(day(8), CHECKED_IMPLICITLY));
expected.add(new Checkmark(day(9), CHECKED_IMPLICITLY));
expected.add(new Checkmark(day(10), CHECKED_EXPLICITLY));
expected.add(new Checkmark(day(0), NO));
expected.add(new Checkmark(day(1), YES_MANUAL));
expected.add(new Checkmark(day(2), YES_MANUAL));
expected.add(new Checkmark(day(3), NO));
expected.add(new Checkmark(day(4), YES_AUTO));
expected.add(new Checkmark(day(5), YES_MANUAL));
expected.add(new Checkmark(day(6), YES_AUTO));
expected.add(new Checkmark(day(7), NO));
expected.add(new Checkmark(day(8), YES_AUTO));
expected.add(new Checkmark(day(9), YES_AUTO));
expected.add(new Checkmark(day(10), YES_MANUAL));
List<Checkmark> actual =
CheckmarkList.buildCheckmarksFromIntervals(reps, intervals);
@ -102,14 +101,14 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildCheckmarksFromIntervals_2() throws Exception
{
Repetition reps[] = new Repetition[]{
new Repetition(day(0), CHECKED_EXPLICITLY),
new Repetition(day(0), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
intervals.add(new CheckmarkList.Interval(day(0), day(0), day(-10)));
List<Checkmark> expected = new ArrayList<>();
expected.add(new Checkmark(day(0), CHECKED_EXPLICITLY));
expected.add(new Checkmark(day(0), YES_MANUAL));
List<Checkmark> actual =
CheckmarkList.buildCheckmarksFromIntervals(reps, intervals);
@ -120,9 +119,9 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildIntervals_1() throws Exception
{
Repetition reps[] = new Repetition[]{
new Repetition(day(23), CHECKED_EXPLICITLY),
new Repetition(day(18), CHECKED_EXPLICITLY),
new Repetition(day(8), CHECKED_EXPLICITLY),
new Repetition(day(23), YES_MANUAL),
new Repetition(day(18), YES_MANUAL),
new Repetition(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -139,9 +138,9 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildIntervals_2() throws Exception
{
Repetition reps[] = new Repetition[]{
new Repetition(day(23), CHECKED_EXPLICITLY),
new Repetition(day(18), CHECKED_EXPLICITLY),
new Repetition(day(8), CHECKED_EXPLICITLY),
new Repetition(day(23), YES_MANUAL),
new Repetition(day(18), YES_MANUAL),
new Repetition(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -158,11 +157,11 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildIntervals_3() throws Exception
{
Repetition reps[] = new Repetition[]{
new Repetition(day(23), CHECKED_EXPLICITLY),
new Repetition(day(22), CHECKED_EXPLICITLY),
new Repetition(day(18), CHECKED_EXPLICITLY),
new Repetition(day(15), CHECKED_EXPLICITLY),
new Repetition(day(8), CHECKED_EXPLICITLY),
new Repetition(day(23), YES_MANUAL),
new Repetition(day(22), YES_MANUAL),
new Repetition(day(18), YES_MANUAL),
new Repetition(day(15), YES_MANUAL),
new Repetition(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -181,9 +180,9 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_buildIntervals_4() throws Exception
{
Repetition[] reps = new Repetition[]{
new Repetition(day(30), CHECKED_EXPLICITLY),
new Repetition(day(20), SKIPPED),
new Repetition(day(10), CHECKED_EXPLICITLY),
new Repetition(day(30), YES_MANUAL),
new Repetition(day(20), SKIP),
new Repetition(day(10), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -201,13 +200,13 @@ public class CheckmarkListTest extends BaseUnitTest
travelInTime(-3);
int[] expectedValues = {
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY
YES_MANUAL,
YES_MANUAL,
YES_MANUAL,
YES_AUTO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getCheckmarks().getAllValues();
@ -221,19 +220,19 @@ public class CheckmarkListTest extends BaseUnitTest
travelInTime(3);
int[] expectedValues = {
UNCHECKED,
UNCHECKED,
UNCHECKED,
CHECKED_EXPLICITLY,
UNCHECKED,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY
NO,
NO,
NO,
YES_MANUAL,
NO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL,
YES_MANUAL,
YES_AUTO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getCheckmarks().getAllValues();
@ -254,16 +253,16 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_getAllValues_withNonDailyHabit()
{
int[] expectedValues = {
CHECKED_EXPLICITLY,
UNCHECKED,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY
YES_MANUAL,
NO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL,
YES_MANUAL,
YES_AUTO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getCheckmarks().getAllValues();
@ -291,13 +290,13 @@ public class CheckmarkListTest extends BaseUnitTest
CheckmarkList checkmarks = nonDailyHabit.getCheckmarks();
travelInTime(-1);
assertThat(checkmarks.getTodayValue(), equalTo(UNCHECKED));
assertThat(checkmarks.getTodayValue(), equalTo(NO));
travelInTime(0);
assertThat(checkmarks.getTodayValue(), equalTo(CHECKED_EXPLICITLY));
assertThat(checkmarks.getTodayValue(), equalTo(YES_MANUAL));
travelInTime(1);
assertThat(checkmarks.getTodayValue(), equalTo(UNCHECKED));
assertThat(checkmarks.getTodayValue(), equalTo(NO));
}
@Test
@ -316,17 +315,17 @@ public class CheckmarkListTest extends BaseUnitTest
Timestamp to = today.minus(5);
int[] expectedValues = {
CHECKED_EXPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_IMPLICITLY,
CHECKED_EXPLICITLY,
CHECKED_EXPLICITLY,
UNCHECKED,
UNCHECKED,
UNCHECKED,
UNCHECKED,
UNCHECKED,
UNCHECKED
YES_MANUAL,
YES_AUTO,
YES_AUTO,
YES_MANUAL,
YES_MANUAL,
NO,
NO,
NO,
NO,
NO,
NO
};
int[] actualValues = nonDailyHabit.getCheckmarks().getValues(from, to);

@ -70,12 +70,12 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
RepetitionRecord record = getByTimestamp(today.plus(1));
assertNull(record);
Repetition rep = new Repetition(today.plus(1), CHECKED_EXPLICITLY);
Repetition rep = new Repetition(today.plus(1), YES_MANUAL);
habit.getRepetitions().add(rep);
record = getByTimestamp(today.plus(1));
assertNotNull(record);
assertThat(record.value, equalTo(CHECKED_EXPLICITLY));
assertThat(record.value, equalTo(YES_MANUAL));
}
@Test

@ -84,7 +84,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
{
Habit h2 = habitList.getByPosition(2);
Timestamp today = DateUtils.getToday();
commandRunner.execute(new CreateRepetitionCommand(habitList, h2, today, Checkmark.UNCHECKED), h2.getId());
commandRunner.execute(new CreateRepetitionCommand(habitList, h2, today, Checkmark.NO), h2.getId());
verify(listener).onItemChanged(2);
verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener);

@ -173,7 +173,7 @@ public class ListHabitsBehaviorTest extends BaseUnitTest
public void testOnToggle()
{
assertTrue(habit1.isCompletedToday());
behavior.onToggle(habit1, DateUtils.getToday(), Checkmark.UNCHECKED);
behavior.onToggle(habit1, DateUtils.getToday(), Checkmark.NO);
assertFalse(habit1.isCompletedToday());
}

Loading…
Cancel
Save