Skip to content

Commit

Permalink
Merge branch 'feature/refactoring-mvc' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed Jun 29, 2016
2 parents aa41717 + 5d61fdd commit 31fdae1
Show file tree
Hide file tree
Showing 329 changed files with 19,627 additions and 10,324 deletions.
48 changes: 38 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion 23
Expand All @@ -13,7 +15,7 @@ android {
buildConfigField "String", "databaseFilename", "\"uhabits.db\""

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//testInstrumentationRunnerArgument "size", "small"
testInstrumentationRunnerArgument "size", "medium"
}

buildTypes {
Expand All @@ -29,6 +31,22 @@ android {
lintOptions {
checkReleaseBuilds false
}

compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}

testOptions {
unitTests.all {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}

}

dependencies {
Expand All @@ -40,12 +58,29 @@ dependencies {
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.opencsv:opencsv:3.7'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'org.jetbrains:annotations-java5:15.0'

compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'

compile 'com.google.dagger:dagger:2.2'
apt 'com.google.dagger:dagger-compiler:2.2'
testApt 'com.google.dagger:dagger-compiler:2.2'
androidTestApt 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'

compile project(':libs:drag-sort-listview:library')

testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-core:1.10.19'

androidTestCompile 'com.android.support:support-annotations:23.3.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude group: 'com.android.support'
Expand All @@ -60,13 +95,6 @@ dependencies {
}
}


task grantAnimationPermission(type: Exec, dependsOn: 'installDebug') {
commandLine "adb shell pm grant org.isoron.uhabits android.permission.SET_ANIMATION_SCALE".split(' ')
}

tasks.whenTaskAdded { task ->
if (task.name.startsWith('connected')) {
task.dependsOn grantAnimationPermission
}
retrolambda {
defaultMethods true
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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;

import javax.inject.Singleton;

import dagger.Component;

@Singleton
@Component(modules = {AndroidModule.class})
public interface AndroidTestComponent extends BaseComponent
{
void inject(BaseAndroidTest baseAndroidTest);
}

135 changes: 135 additions & 0 deletions app/src/androidTest/java/org/isoron/uhabits/BaseAndroidTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* 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;

import android.appwidget.*;
import android.content.*;
import android.os.*;
import android.support.annotation.*;
import android.support.test.*;

import org.isoron.uhabits.commands.*;
import org.isoron.uhabits.models.*;
import org.isoron.uhabits.tasks.*;
import org.isoron.uhabits.utils.*;
import org.junit.*;

import java.util.*;
import java.util.concurrent.*;

import javax.inject.*;

import static junit.framework.Assert.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;

public class BaseAndroidTest
{
// 8:00am, January 25th, 2015 (UTC)
public static final long FIXED_LOCAL_TIME = 1422172800000L;

private static boolean isLooperPrepared;

protected Context testContext;

protected Context targetContext;

@Inject
protected Preferences prefs;

@Inject
protected HabitList habitList;

@Inject
protected CommandRunner commandRunner;

protected AndroidTestComponent androidTestComponent;

protected HabitFixtures fixtures;

protected CountDownLatch latch;

@Before
public void setUp()
{
if (!isLooperPrepared)
{
Looper.prepare();
isLooperPrepared = true;
}

targetContext = InstrumentationRegistry.getTargetContext();
testContext = InstrumentationRegistry.getContext();

InterfaceUtils.setFixedTheme(R.style.AppBaseTheme);
DateUtils.setFixedLocalTime(FIXED_LOCAL_TIME);

androidTestComponent = DaggerAndroidTestComponent.builder().build();
HabitsApplication.setComponent(androidTestComponent);
androidTestComponent.inject(this);

fixtures = new HabitFixtures(habitList);

latch = new CountDownLatch(1);
}

protected void assertWidgetProviderIsInstalled(Class componentClass)
{
ComponentName provider =
new ComponentName(targetContext, componentClass);
AppWidgetManager manager = AppWidgetManager.getInstance(targetContext);

List<ComponentName> installedProviders = new LinkedList<>();
for (AppWidgetProviderInfo info : manager.getInstalledProviders())
installedProviders.add(info.provider);

assertThat(installedProviders, hasItems(provider));
}

protected void setTheme(@StyleRes int themeId)
{
InterfaceUtils.setFixedTheme(themeId);
targetContext.setTheme(themeId);
}

protected void sleep(int time)
{
try
{
Thread.sleep(time);
}
catch (InterruptedException e)
{
fail();
}
}

protected void waitForAsyncTasks()
throws InterruptedException, TimeoutException
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
{
Thread.sleep(1000);
return;
}

BaseTask.waitForTasks(10000);
}
}
68 changes: 0 additions & 68 deletions app/src/androidTest/java/org/isoron/uhabits/BaseTest.java

This file was deleted.

Loading

0 comments on commit 31fdae1

Please sign in to comment.