Reactivate widget view tests; update widget previews
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 585 B |
|
Before Width: | Height: | Size: 543 B |
|
Before Width: | Height: | Size: 583 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 15 KiB |
@@ -78,15 +78,49 @@ public class HabitFixtures
|
||||
return habit;
|
||||
}
|
||||
|
||||
public Habit createVeryLongHabit()
|
||||
{
|
||||
Habit habit = createEmptyHabit();
|
||||
habit.setFrequency(new Frequency(1, 2));
|
||||
habit.setColor(11);
|
||||
|
||||
Timestamp today = DateUtils.getToday();
|
||||
int marks[] = {0, 3, 5, 6, 7, 10, 13, 14, 15, 18, 21, 22, 23, 24, 27, 28, 30, 31, 34, 37,
|
||||
39, 42, 43, 46, 47, 48, 51, 52, 54, 55, 57, 59, 62, 65, 68, 71, 73, 76, 79,
|
||||
80, 81, 83, 85, 86, 89, 90, 91, 94, 96, 98, 100, 103, 104, 106, 109, 111,
|
||||
112, 113, 115, 117, 120, 123, 126, 129, 132, 134, 136, 139, 141, 142, 145,
|
||||
148, 149, 151, 152, 154, 156, 157, 159, 161, 162, 163, 164, 166, 168, 170,
|
||||
172, 173, 174, 175, 176, 178, 180, 181, 184, 185, 188, 189, 190, 191, 194,
|
||||
195, 197, 198, 199, 200, 202, 205, 208, 211, 213, 215, 216, 218, 220, 222,
|
||||
223, 225, 227, 228, 230, 231, 232, 234, 235, 238, 241, 242, 244, 247, 250,
|
||||
251, 253, 254, 257, 260, 261, 263, 264, 266, 269, 272, 273, 276, 279, 281,
|
||||
284, 285, 288, 291, 292, 294, 296, 297, 299, 300, 301, 303, 306, 307, 308,
|
||||
309, 310, 313, 316, 319, 322, 324, 326, 329, 330, 332, 334, 335, 337, 338,
|
||||
341, 344, 345, 346, 347, 350, 352, 355, 358, 360, 361, 362, 363, 365, 368,
|
||||
371, 373, 374, 376, 379, 380, 382, 384, 385, 387, 389, 390, 392, 393, 395,
|
||||
396, 399, 401, 404, 407, 410, 411, 413, 414, 416, 417, 419, 420, 423, 424,
|
||||
427, 429, 431, 433, 436, 439, 440, 442, 445, 447, 450, 453, 454, 456, 459,
|
||||
460, 461, 464, 466, 468, 470, 473, 474, 475, 477, 479, 481, 482, 483, 486,
|
||||
489, 491, 493, 495, 497, 498, 500, 503, 504, 507, 510, 511, 512, 515, 518,
|
||||
519, 521, 522, 525, 528, 531, 532, 534, 537, 539, 541, 543, 544, 547, 550,
|
||||
551, 554, 556, 557, 560, 561, 564, 567, 568, 569, 570, 572, 575, 576, 579,
|
||||
582, 583, 584, 586, 589};
|
||||
|
||||
for (int mark : marks)
|
||||
habit.getRepetitions().toggle(today.minus(mark));
|
||||
|
||||
return habit;
|
||||
}
|
||||
|
||||
public Habit createLongNumericalHabit()
|
||||
{
|
||||
Habit habit = modelFactory.buildHabit();
|
||||
habit.setName("Take a walk");
|
||||
habit.setQuestion("How many steps did you walk today?");
|
||||
habit.setName("Read");
|
||||
habit.setQuestion("How many pages did you walk today?");
|
||||
habit.setType(Habit.NUMBER_HABIT);
|
||||
habit.setTargetType(Habit.AT_LEAST);
|
||||
habit.setTargetValue(200.0);
|
||||
habit.setUnit("steps");
|
||||
habit.setUnit("pages");
|
||||
habitList.add(habit);
|
||||
|
||||
Timestamp timestamp = DateUtils.getToday();
|
||||
|
||||
@@ -51,11 +51,12 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createShortHabit();
|
||||
habit = fixtures.createVeryLongHabit();
|
||||
checkmarks = habit.getCheckmarks();
|
||||
CheckmarkWidget widget = new CheckmarkWidget(targetContext, 0, habit);
|
||||
view = convertToView(widget, 200, 250);
|
||||
view = convertToView(widget, 150, 200);
|
||||
|
||||
assertThat(checkmarks.getTodayValue(), equalTo(CHECKED_EXPLICITLY));
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ public class FrequencyWidgetTest extends BaseViewTest
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createLongHabit();
|
||||
habit = fixtures.createVeryLongHabit();
|
||||
FrequencyWidget widget = new FrequencyWidget(targetContext, 0, habit, Calendar.SUNDAY);
|
||||
view = convertToView(widget, 400, 400);
|
||||
}
|
||||
@@ -59,9 +60,9 @@ public class FrequencyWidgetTest extends BaseViewTest
|
||||
assertWidgetProviderIsInstalled(FrequencyWidgetProvider.class);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testRender() throws Exception
|
||||
// {
|
||||
// assertRenders(view, PATH + "render.png");
|
||||
// }
|
||||
@Test
|
||||
public void testRender() throws Exception
|
||||
{
|
||||
assertRenders(view, PATH + "render.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ 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.*;
|
||||
|
||||
@@ -47,8 +48,9 @@ public class HistoryWidgetTest extends BaseViewTest
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createLongHabit();
|
||||
habit = fixtures.createVeryLongHabit();
|
||||
HistoryWidget widget = new HistoryWidget(targetContext, 0, habit, Calendar.SUNDAY);
|
||||
view = convertToView(widget, 400, 400);
|
||||
}
|
||||
@@ -59,9 +61,9 @@ public class HistoryWidgetTest extends BaseViewTest
|
||||
assertWidgetProviderIsInstalled(HistoryWidgetProvider.class);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testRender() throws Exception
|
||||
// {
|
||||
// assertRenders(view, PATH + "render.png");
|
||||
// }
|
||||
@Test
|
||||
public void testRender() throws Exception
|
||||
{
|
||||
assertRenders(view, PATH + "render.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,9 @@ public class ScoreWidgetTest extends BaseViewTest
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createLongHabit();
|
||||
habit = fixtures.createVeryLongHabit();
|
||||
ScoreWidget widget = new ScoreWidget(targetContext, 0, habit);
|
||||
view = convertToView(widget, 400, 400);
|
||||
}
|
||||
@@ -57,9 +58,9 @@ public class ScoreWidgetTest extends BaseViewTest
|
||||
assertWidgetProviderIsInstalled(ScoreWidgetProvider.class);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testRender() throws Exception
|
||||
// {
|
||||
// assertRenders(view, PATH + "render.png");
|
||||
// }
|
||||
@Test
|
||||
public void testRender() throws Exception
|
||||
{
|
||||
assertRenders(view, PATH + "render.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,9 @@ public class StreakWidgetTest extends BaseViewTest
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createLongHabit();
|
||||
habit = fixtures.createVeryLongHabit();
|
||||
StreakWidget widget = new StreakWidget(targetContext, 0, habit);
|
||||
view = convertToView(widget, 400, 400);
|
||||
}
|
||||
@@ -57,9 +58,9 @@ public class StreakWidgetTest extends BaseViewTest
|
||||
assertWidgetProviderIsInstalled(StreakWidgetProvider.class);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testRender() throws Exception
|
||||
// {
|
||||
// assertRenders(view, PATH + "render.png");
|
||||
// }
|
||||
@Test
|
||||
public void testRender() throws Exception
|
||||
{
|
||||
assertRenders(view, PATH + "render.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* 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.widgets;
|
||||
|
||||
import android.widget.*;
|
||||
|
||||
import androidx.test.ext.junit.runners.*;
|
||||
import androidx.test.filters.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
public class TargetWidgetTest extends BaseViewTest
|
||||
{
|
||||
private static final String PATH = "widgets/TargetWidget/";
|
||||
|
||||
private Habit habit;
|
||||
|
||||
private FrameLayout view;
|
||||
|
||||
@Override
|
||||
public void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
setTheme(R.style.WidgetTheme);
|
||||
prefs.setWidgetOpacity(255);
|
||||
|
||||
habit = fixtures.createLongNumericalHabit();
|
||||
habit.setColor(11);
|
||||
TargetWidget widget = new TargetWidget(targetContext, 0, habit);
|
||||
view = convertToView(widget, 400, 400);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInstalled()
|
||||
{
|
||||
assertWidgetProviderIsInstalled(TargetWidgetProvider.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRender() throws Exception
|
||||
{
|
||||
assertRenders(view, PATH + "render.png");
|
||||
}
|
||||
}
|
||||