Reorganize instrumented tests

pull/145/head
Alinson S. Xavier 9 years ago
parent 440706882b
commit 14364901ff

@ -26,7 +26,6 @@ import android.support.test.InstrumentationRegistry;
import org.isoron.uhabits.models.HabitList;
import org.isoron.uhabits.tasks.BaseTask;
import org.isoron.uhabits.unit.HabitFixtures;
import org.isoron.uhabits.utils.DateUtils;
import org.isoron.uhabits.utils.InterfaceUtils;
import org.isoron.uhabits.utils.Preferences;

@ -17,29 +17,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.SystemClock;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.graphics.*;
import android.os.*;
import android.view.*;
import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.utils.FileUtils;
import org.isoron.uhabits.utils.InterfaceUtils;
import org.isoron.uhabits.tasks.BaseTask;
import org.isoron.uhabits.ui.habits.show.views.HabitDataView;
import org.isoron.uhabits.tasks.*;
import org.isoron.uhabits.ui.habits.show.views.*;
import org.isoron.uhabits.utils.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import static junit.framework.Assert.fail;
import static junit.framework.Assert.*;
public class ViewTest extends BaseAndroidTest
public class BaseViewTest extends BaseAndroidTest
{
protected static final double DEFAULT_SIMILARITY_CUTOFF = 0.09;
public static final int HISTOGRAM_BIN_SIZE = 8;

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit;
package org.isoron.uhabits;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.models.HabitList;

@ -17,22 +17,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit;
package org.isoron.uhabits;
import android.os.Build;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import android.os.*;
import android.support.test.runner.*;
import android.test.suitebuilder.annotation.*;
import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.HabitsApplication;
import org.isoron.uhabits.ui.BaseSystem;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.isoron.uhabits.ui.*;
import org.junit.*;
import org.junit.runner.*;
import java.io.IOException;
import java.io.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
@RunWith(AndroidJUnit4.class)
@SmallTest

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.ui;
package org.isoron.uhabits.espresso;
import android.preference.Preference;
import android.view.View;

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.ui;
package org.isoron.uhabits.espresso;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;

@ -17,11 +17,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.ui;
package org.isoron.uhabits.espresso;
import android.support.test.espresso.NoMatchingViewException;
import android.support.test.espresso.contrib.RecyclerViewActions;
import org.hamcrest.*;
import org.isoron.uhabits.R;
import org.isoron.uhabits.models.sqlite.records.HabitRecord;
@ -53,8 +54,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.isoron.uhabits.ui.HabitMatchers.containsHabit;
import static org.isoron.uhabits.ui.HabitMatchers.withName;
public class MainActivityActions
{
@ -93,7 +92,8 @@ public class MainActivityActions
onView(withId(R.id.buttonSave))
.perform(click());
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.label));
return name;
@ -135,7 +135,8 @@ public class MainActivityActions
boolean first = true;
for(String name : names)
{
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.label))
.perform(first ? longClick() : click());
@ -147,7 +148,8 @@ public class MainActivityActions
{
for(String name : names)
onView(withId(R.id.listView))
.check(matches(not(containsHabit(withName(name)))));
.check(matches(Matchers.not(
HabitMatchers.containsHabit(HabitMatchers.withName(name)))));
}
public static void assertHabitExists(String name)
@ -160,7 +162,8 @@ public class MainActivityActions
public static void assertHabitsExist(List<String> names)
{
for(String name : names)
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.check(matches(isDisplayed()));
}

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.ui;
package org.isoron.uhabits.espresso;
import android.app.Activity;
import android.app.Instrumentation;
@ -29,6 +29,7 @@ import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.hamcrest.*;
import org.isoron.uhabits.R;
import org.isoron.uhabits.models.sqlite.records.HabitRecord;
import org.isoron.uhabits.utils.DateUtils;
@ -67,21 +68,20 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.isoron.uhabits.ui.HabitMatchers.withName;
import static org.isoron.uhabits.ui.HabitViewActions.clickAtRandomLocations;
import static org.isoron.uhabits.ui.HabitViewActions.toggleAllCheckmarks;
import static org.isoron.uhabits.ui.MainActivityActions.addHabit;
import static org.isoron.uhabits.ui.MainActivityActions.assertHabitExists;
import static org.isoron.uhabits.ui.MainActivityActions.assertHabitsDontExist;
import static org.isoron.uhabits.ui.MainActivityActions.assertHabitsExist;
import static org.isoron.uhabits.ui.MainActivityActions.clickMenuItem;
import static org.isoron.uhabits.ui.MainActivityActions.clickSettingsItem;
import static org.isoron.uhabits.ui.MainActivityActions.deleteHabit;
import static org.isoron.uhabits.ui.MainActivityActions.deleteHabits;
import static org.isoron.uhabits.ui.MainActivityActions.selectHabit;
import static org.isoron.uhabits.ui.MainActivityActions.selectHabits;
import static org.isoron.uhabits.ui.MainActivityActions.typeHabitData;
import static org.isoron.uhabits.ui.ShowHabitActivityActions.openHistoryEditor;
import static org.isoron.uhabits.espresso.HabitViewActions.clickAtRandomLocations;
import static org.isoron.uhabits.espresso.HabitViewActions.toggleAllCheckmarks;
import static org.isoron.uhabits.espresso.MainActivityActions.addHabit;
import static org.isoron.uhabits.espresso.MainActivityActions.assertHabitExists;
import static org.isoron.uhabits.espresso.MainActivityActions.assertHabitsDontExist;
import static org.isoron.uhabits.espresso.MainActivityActions.assertHabitsExist;
import static org.isoron.uhabits.espresso.MainActivityActions.clickMenuItem;
import static org.isoron.uhabits.espresso.MainActivityActions.clickSettingsItem;
import static org.isoron.uhabits.espresso.MainActivityActions.deleteHabit;
import static org.isoron.uhabits.espresso.MainActivityActions.deleteHabits;
import static org.isoron.uhabits.espresso.MainActivityActions.selectHabit;
import static org.isoron.uhabits.espresso.MainActivityActions.selectHabits;
import static org.isoron.uhabits.espresso.MainActivityActions.typeHabitData;
import static org.isoron.uhabits.espresso.ShowHabitActivityActions.openHistoryEditor;
@RunWith(AndroidJUnit4.class)
@LargeTest
@ -190,13 +190,15 @@ public class MainTest
{
String name = addHabit(true);
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.checkmarkPanel))
.perform(toggleAllCheckmarks());
Thread.sleep(1200);
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.label))
.perform(click());
@ -217,7 +219,8 @@ public class MainTest
{
String name = addHabit();
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.label))
.perform(longClick());
@ -247,7 +250,8 @@ public class MainTest
{
String name = addHabit();
onData(allOf(is(instanceOf(HabitRecord.class)), withName(name)))
onData(
Matchers.allOf(is(instanceOf(HabitRecord.class)), HabitMatchers.withName(name)))
.onChildView(withId(R.id.label))
.perform(click());

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.ui;
package org.isoron.uhabits.espresso;
import android.support.test.espresso.matcher.ViewMatchers;

@ -1,4 +1,23 @@
package org.isoron.uhabits.ui;
/*
* 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.espresso;
import android.app.KeyguardManager;
import android.content.Context;

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.io;
package org.isoron.uhabits.io;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
@ -25,7 +25,6 @@ import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.io.HabitsCSVExporter;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.utils.FileUtils;
import org.junit.Before;

@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.io;
package org.isoron.uhabits.io;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
@ -28,7 +28,6 @@ import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.utils.FileUtils;
import org.isoron.uhabits.utils.DateUtils;
import org.isoron.uhabits.io.GenericImporter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@ -17,14 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.tasks;
package org.isoron.uhabits.tasks;
import android.support.test.runner.*;
import android.test.suitebuilder.annotation.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import org.isoron.uhabits.tasks.*;
import org.junit.*;
import org.junit.runner.*;

@ -17,13 +17,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.tasks;
package org.isoron.uhabits.tasks;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.tasks.ExportDBTask;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@ -17,14 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.tasks;
package org.isoron.uhabits.tasks;
import android.support.annotation.NonNull;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.BaseAndroidTest;
import org.isoron.uhabits.tasks.ImportDataTask;
import org.isoron.uhabits.utils.FileUtils;
import org.junit.Before;
import org.junit.Test;

@ -17,14 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.ui.habits.list.view;
package org.isoron.uhabits.ui.habits.list.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.models.Checkmark;
import org.isoron.uhabits.ui.habits.list.views.CheckmarkButtonView;
import org.isoron.uhabits.unit.views.ViewTest;
import org.isoron.uhabits.BaseViewTest;
import org.isoron.uhabits.utils.ColorUtils;
import org.junit.Before;
import org.junit.Test;
@ -35,7 +34,7 @@ import java.util.concurrent.CountDownLatch;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class CheckmarkButtonViewTest extends ViewTest
public class CheckmarkButtonViewTest extends BaseViewTest
{
public static final String PATH = "ui/habits/list/CheckmarkButtonView/";

@ -17,15 +17,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.ui.habits.list.view;
package org.isoron.uhabits.ui.habits.list.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.models.Checkmark;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.ui.habits.list.views.CheckmarkPanelView;
import org.isoron.uhabits.unit.views.ViewTest;
import org.isoron.uhabits.BaseViewTest;
import org.isoron.uhabits.utils.ColorUtils;
import org.junit.Before;
import org.junit.Test;
@ -35,7 +34,7 @@ import java.util.concurrent.CountDownLatch;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class CheckmarkPanelViewTest extends ViewTest
public class CheckmarkPanelViewTest extends BaseViewTest
{
public static final String PATH = "ui/habits/list/CheckmarkPanelView/";

@ -17,20 +17,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.ui.habits.show.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.ui.habits.show.views.HabitFrequencyView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class HabitFrequencyViewTest extends ViewTest
public class HabitFrequencyViewTest extends BaseViewTest
{
private HabitFrequencyView view;

@ -17,14 +17,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.ui.habits.show.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.utils.DateUtils;
import org.isoron.uhabits.ui.habits.show.views.HabitHistoryView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.equalTo;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class HabitHistoryViewTest extends ViewTest
public class HabitHistoryViewTest extends BaseViewTest
{
private Habit habit;

@ -17,21 +17,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.ui.habits.show.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.ui.habits.show.views.HabitScoreView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class HabitScoreViewTest extends ViewTest
public class HabitScoreViewTest extends BaseViewTest
{
private Habit habit;

@ -17,20 +17,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.ui.habits.show.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.ui.habits.show.views.HabitStreakView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class HabitStreakViewTest extends ViewTest
public class HabitStreakViewTest extends BaseViewTest
{
private HabitStreakView view;

@ -17,14 +17,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.ui.habits.show.views;
import android.graphics.Color;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.*;
import org.isoron.uhabits.utils.ColorUtils;
import org.isoron.uhabits.ui.habits.show.views.RingView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -33,7 +33,7 @@ import java.io.IOException;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class RingViewTest extends ViewTest
public class RingViewTest extends BaseViewTest
{
private RingView view;

@ -17,16 +17,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.unit.views;
package org.isoron.uhabits.widgets.views;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.isoron.uhabits.R;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.utils.DateUtils;
import org.isoron.uhabits.utils.InterfaceUtils;
import org.isoron.uhabits.widgets.views.CheckmarkWidgetView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -35,7 +34,7 @@ import java.io.IOException;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class CheckmarkWidgetViewTest extends ViewTest
public class CheckmarkWidgetViewTest extends BaseViewTest
{
private CheckmarkWidgetView view;
Loading…
Cancel
Save