mirror of https://github.com/iSoron/uhabits.git
parent
a7df0bde3e
commit
def9ff9746
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.activities.common.views;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.*;
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.core.models.*;
|
|
||||||
import org.isoron.uhabits.utils.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class FrequencyChartTest extends BaseViewTest
|
|
||||||
{
|
|
||||||
public static final String BASE_PATH = "common/FrequencyChart/";
|
|
||||||
|
|
||||||
private FrequencyChart view;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
fixtures.purgeHabits(habitList);
|
|
||||||
Habit habit = fixtures.createLongHabit();
|
|
||||||
|
|
||||||
view = new FrequencyChart(targetContext);
|
|
||||||
view.setFrequency(habit.getOriginalEntries().computeWeekdayFrequency(
|
|
||||||
habit.isNumerical()
|
|
||||||
));
|
|
||||||
view.setColor(PaletteUtilsKt.toFixedAndroidColor(habit.getColor()));
|
|
||||||
measureView(view, dpToPixels(300), dpToPixels(100));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender() throws Throwable
|
|
||||||
{
|
|
||||||
assertRenders(view, BASE_PATH + "render.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withDataOffset() throws Throwable
|
|
||||||
{
|
|
||||||
view.onScroll(null, null, -dpToPixels(150), 0);
|
|
||||||
view.invalidate();
|
|
||||||
|
|
||||||
assertRenders(view, BASE_PATH + "renderDataOffset.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withDifferentSize() throws Throwable
|
|
||||||
{
|
|
||||||
measureView(view, dpToPixels(200), dpToPixels(200));
|
|
||||||
assertRenders(view, BASE_PATH + "renderDifferentSize.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withTransparentBackground() throws Throwable
|
|
||||||
{
|
|
||||||
view.setIsBackgroundTransparent(true);
|
|
||||||
assertRenders(view, BASE_PATH + "renderTransparent.png");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
|
*
|
||||||
|
* This file is part of Loop Habit Tracker.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.activities.common.views
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.MediumTest
|
||||||
|
import org.isoron.uhabits.BaseViewTest
|
||||||
|
import org.isoron.uhabits.utils.toFixedAndroidColor
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@MediumTest
|
||||||
|
class FrequencyChartTest : BaseViewTest() {
|
||||||
|
private var view: FrequencyChart? = null
|
||||||
|
@Before
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
fixtures.purgeHabits(habitList)
|
||||||
|
val habit = fixtures.createLongHabit()
|
||||||
|
view = FrequencyChart(targetContext)
|
||||||
|
view!!.setFrequency(
|
||||||
|
habit.originalEntries.computeWeekdayFrequency(
|
||||||
|
habit.isNumerical
|
||||||
|
)
|
||||||
|
)
|
||||||
|
view!!.setColor(habit.color.toFixedAndroidColor())
|
||||||
|
measureView(view, dpToPixels(300), dpToPixels(100))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender() {
|
||||||
|
assertRenders(view, BASE_PATH + "render.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withDataOffset() {
|
||||||
|
view!!.onScroll(null, null, -dpToPixels(150), 0f)
|
||||||
|
view!!.invalidate()
|
||||||
|
assertRenders(view, BASE_PATH + "renderDataOffset.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withDifferentSize() {
|
||||||
|
measureView(view, dpToPixels(200), dpToPixels(200))
|
||||||
|
assertRenders(view, BASE_PATH + "renderDifferentSize.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withTransparentBackground() {
|
||||||
|
view!!.setIsBackgroundTransparent(true)
|
||||||
|
assertRenders(view, BASE_PATH + "renderTransparent.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val BASE_PATH = "common/FrequencyChart/"
|
||||||
|
}
|
||||||
|
}
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.activities.common.views;
|
|
||||||
|
|
||||||
import android.graphics.*;
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
import androidx.test.runner.*;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.utils.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class RingViewTest extends BaseViewTest
|
|
||||||
{
|
|
||||||
private static final String BASE_PATH = "common/RingView/";
|
|
||||||
|
|
||||||
private RingView view;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
view = new RingView(targetContext);
|
|
||||||
view.setPercentage(0.6f);
|
|
||||||
view.setText("60%");
|
|
||||||
view.setColor(PaletteUtils.getAndroidTestColor(0));
|
|
||||||
view.setBackgroundColor(Color.WHITE);
|
|
||||||
view.setThickness(dpToPixels(3));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_base() throws IOException
|
|
||||||
{
|
|
||||||
measureView(view, dpToPixels(100), dpToPixels(100));
|
|
||||||
assertRenders(view, BASE_PATH + "render.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withDifferentParams() throws IOException
|
|
||||||
{
|
|
||||||
view.setPercentage(0.25f);
|
|
||||||
view.setColor(PaletteUtils.getAndroidTestColor(5));
|
|
||||||
|
|
||||||
measureView(view, dpToPixels(200), dpToPixels(200));
|
|
||||||
assertRenders(view, BASE_PATH + "renderDifferentParams.png");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
|
*
|
||||||
|
* This file is part of Loop Habit Tracker.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.activities.common.views
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.MediumTest
|
||||||
|
import org.isoron.uhabits.BaseViewTest
|
||||||
|
import org.isoron.uhabits.utils.PaletteUtils.getAndroidTestColor
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@MediumTest
|
||||||
|
class RingViewTest : BaseViewTest() {
|
||||||
|
private var view: RingView? = null
|
||||||
|
@Before
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
view = RingView(targetContext)
|
||||||
|
view!!.setPercentage(0.6f)
|
||||||
|
view!!.setText("60%")
|
||||||
|
view!!.setColor(getAndroidTestColor(0))
|
||||||
|
view!!.setBackgroundColor(Color.WHITE)
|
||||||
|
view!!.setThickness(dpToPixels(3))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun testRender_base() {
|
||||||
|
measureView(view, dpToPixels(100), dpToPixels(100))
|
||||||
|
assertRenders(view, BASE_PATH + "render.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun testRender_withDifferentParams() {
|
||||||
|
view!!.setPercentage(0.25f)
|
||||||
|
view!!.setColor(getAndroidTestColor(5))
|
||||||
|
measureView(view, dpToPixels(200), dpToPixels(200))
|
||||||
|
assertRenders(view, BASE_PATH + "renderDifferentParams.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val BASE_PATH = "common/RingView/"
|
||||||
|
}
|
||||||
|
}
|
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.activities.common.views;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.*;
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.core.models.*;
|
|
||||||
import org.isoron.uhabits.core.ui.screens.habits.show.views.*;
|
|
||||||
import org.isoron.uhabits.utils.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class ScoreChartTest extends BaseViewTest
|
|
||||||
{
|
|
||||||
private static final String BASE_PATH = "common/ScoreChart/";
|
|
||||||
|
|
||||||
private Habit habit;
|
|
||||||
|
|
||||||
private ScoreChart view;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
fixtures.purgeHabits(habitList);
|
|
||||||
habit = fixtures.createLongHabit();
|
|
||||||
ScoreCardState state = ScoreCardPresenter.Companion.buildState(habit, prefs.getFirstWeekdayInt(), 0);
|
|
||||||
|
|
||||||
view = new ScoreChart(targetContext);
|
|
||||||
view.setScores(state.getScores());
|
|
||||||
view.setColor(PaletteUtilsKt.toFixedAndroidColor(state.getColor()));
|
|
||||||
view.setBucketSize(state.getBucketSize());
|
|
||||||
measureView(view, dpToPixels(300), dpToPixels(200));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender() throws Throwable
|
|
||||||
{
|
|
||||||
assertRenders(view, BASE_PATH + "render.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withDataOffset() throws Throwable
|
|
||||||
{
|
|
||||||
view.onScroll(null, null, -dpToPixels(150), 0);
|
|
||||||
view.invalidate();
|
|
||||||
|
|
||||||
assertRenders(view, BASE_PATH + "renderDataOffset.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withDifferentSize() throws Throwable
|
|
||||||
{
|
|
||||||
measureView(view, dpToPixels(200), dpToPixels(200));
|
|
||||||
assertRenders(view, BASE_PATH + "renderDifferentSize.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withMonthlyBucket() throws Throwable
|
|
||||||
{
|
|
||||||
ScoreCardState model = ScoreCardPresenter.Companion.buildState(habit, prefs.getFirstWeekdayInt(), 2);
|
|
||||||
view.setScores(model.getScores());
|
|
||||||
view.setBucketSize(model.getBucketSize());
|
|
||||||
view.invalidate();
|
|
||||||
|
|
||||||
assertRenders(view, BASE_PATH + "renderMonthly.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withTransparentBackground() throws Throwable
|
|
||||||
{
|
|
||||||
view.setIsTransparencyEnabled(true);
|
|
||||||
assertRenders(view, BASE_PATH + "renderTransparent.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withYearlyBucket() throws Throwable
|
|
||||||
{
|
|
||||||
ScoreCardState model = ScoreCardPresenter.Companion.buildState(habit, prefs.getFirstWeekdayInt(), 4);
|
|
||||||
view.setScores(model.getScores());
|
|
||||||
view.setBucketSize(model.getBucketSize());
|
|
||||||
view.invalidate();
|
|
||||||
|
|
||||||
assertRenders(view, BASE_PATH + "renderYearly.png");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
|
*
|
||||||
|
* This file is part of Loop Habit Tracker.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.activities.common.views
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.MediumTest
|
||||||
|
import org.isoron.uhabits.BaseViewTest
|
||||||
|
import org.isoron.uhabits.core.models.Habit
|
||||||
|
import org.isoron.uhabits.core.ui.screens.habits.show.views.ScoreCardPresenter.Companion.buildState
|
||||||
|
import org.isoron.uhabits.utils.toFixedAndroidColor
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@MediumTest
|
||||||
|
class ScoreChartTest : BaseViewTest() {
|
||||||
|
private lateinit var habit: Habit
|
||||||
|
private var view: ScoreChart? = null
|
||||||
|
@Before
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
fixtures.purgeHabits(habitList)
|
||||||
|
habit = fixtures.createLongHabit()
|
||||||
|
val (scores, bucketSize, _, color) = buildState(habit, prefs.firstWeekdayInt, 0)
|
||||||
|
view = ScoreChart(targetContext)
|
||||||
|
view!!.setScores(scores.toMutableList())
|
||||||
|
view!!.setColor(color.toFixedAndroidColor())
|
||||||
|
view!!.setBucketSize(bucketSize)
|
||||||
|
measureView(view, dpToPixels(300), dpToPixels(200))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender() {
|
||||||
|
assertRenders(view, BASE_PATH + "render.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withDataOffset() {
|
||||||
|
view!!.onScroll(null, null, -dpToPixels(150), 0f)
|
||||||
|
view!!.invalidate()
|
||||||
|
assertRenders(view, BASE_PATH + "renderDataOffset.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withDifferentSize() {
|
||||||
|
measureView(view, dpToPixels(200), dpToPixels(200))
|
||||||
|
assertRenders(view, BASE_PATH + "renderDifferentSize.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withMonthlyBucket() {
|
||||||
|
val (scores, bucketSize) = buildState(
|
||||||
|
habit!!,
|
||||||
|
prefs.firstWeekdayInt,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
view!!.setScores(scores.toMutableList())
|
||||||
|
view!!.setBucketSize(bucketSize)
|
||||||
|
view!!.invalidate()
|
||||||
|
assertRenders(view, BASE_PATH + "renderMonthly.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withTransparentBackground() {
|
||||||
|
view!!.setIsTransparencyEnabled(true)
|
||||||
|
assertRenders(view, BASE_PATH + "renderTransparent.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withYearlyBucket() {
|
||||||
|
val (scores, bucketSize) = buildState(
|
||||||
|
habit!!,
|
||||||
|
prefs.firstWeekdayInt,
|
||||||
|
4
|
||||||
|
)
|
||||||
|
view!!.setScores(scores.toMutableList())
|
||||||
|
view!!.setBucketSize(bucketSize)
|
||||||
|
view!!.invalidate()
|
||||||
|
assertRenders(view, BASE_PATH + "renderYearly.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val BASE_PATH = "common/ScoreChart/"
|
||||||
|
}
|
||||||
|
}
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.activities.common.views;
|
|
||||||
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
import androidx.test.runner.*;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.core.models.*;
|
|
||||||
import org.isoron.uhabits.utils.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class StreakChartTest extends BaseViewTest
|
|
||||||
{
|
|
||||||
private static final String BASE_PATH = "common/StreakChart/";
|
|
||||||
|
|
||||||
private StreakChart view;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
fixtures.purgeHabits(habitList);
|
|
||||||
Habit habit = fixtures.createLongHabit();
|
|
||||||
|
|
||||||
view = new StreakChart(targetContext);
|
|
||||||
view.setColor(PaletteUtilsKt.toFixedAndroidColor(habit.getColor()));
|
|
||||||
view.setStreaks(habit.getStreaks().getBest(5));
|
|
||||||
measureView(view, dpToPixels(300), dpToPixels(100));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender() throws Throwable
|
|
||||||
{
|
|
||||||
assertRenders(view, BASE_PATH + "render.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withSmallSize() throws Throwable
|
|
||||||
{
|
|
||||||
measureView(view, dpToPixels(100), dpToPixels(100));
|
|
||||||
assertRenders(view, BASE_PATH + "renderSmallSize.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRender_withTransparentBackground() throws Throwable
|
|
||||||
{
|
|
||||||
view.setIsBackgroundTransparent(true);
|
|
||||||
assertRenders(view, BASE_PATH + "renderTransparent.png");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
|
*
|
||||||
|
* This file is part of Loop Habit Tracker.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.activities.common.views
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.MediumTest
|
||||||
|
import org.isoron.uhabits.BaseViewTest
|
||||||
|
import org.isoron.uhabits.utils.toFixedAndroidColor
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@MediumTest
|
||||||
|
class StreakChartTest : BaseViewTest() {
|
||||||
|
private var view: StreakChart? = null
|
||||||
|
@Before
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
fixtures.purgeHabits(habitList)
|
||||||
|
val (color, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, streaks) = fixtures.createLongHabit()
|
||||||
|
view = StreakChart(targetContext)
|
||||||
|
view!!.setColor(color.toFixedAndroidColor())
|
||||||
|
view!!.setStreaks(streaks.getBest(5))
|
||||||
|
measureView(view, dpToPixels(300), dpToPixels(100))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender() {
|
||||||
|
assertRenders(view, BASE_PATH + "render.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withSmallSize() {
|
||||||
|
measureView(view, dpToPixels(100), dpToPixels(100))
|
||||||
|
assertRenders(view, BASE_PATH + "renderSmallSize.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Throwable::class)
|
||||||
|
fun testRender_withTransparentBackground() {
|
||||||
|
view!!.setIsBackgroundTransparent(true)
|
||||||
|
assertRenders(view, BASE_PATH + "renderTransparent.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val BASE_PATH = "common/StreakChart/"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue