Merge remote-tracking branch 'upstream/develop' into party-invite

This commit is contained in:
Zoe Abrams 2020-04-15 12:00:47 -07:00
commit f79cae4290
18 changed files with 185 additions and 175 deletions

View file

@ -1,6 +1,9 @@
language: android
dist: trusty
jdk: oraclejdk8
udo: required
sudo: required
services:
- mongodb
addons:
apt:
sources:
@ -11,19 +14,19 @@ before_install:
- $CXX --version
- export JAVA7_HOME=/usr/lib/jvm/java-7-oracle
- export JAVA8_HOME=/usr/lib/jvm/java-8-oracle
- if [ $REQUIRES_SERVER ]; then nvm install 6.9.3; fi
- if [ $REQUIRES_SERVER ]; then nvm use 6.9.3; fi
- if [ $REQUIRES_SERVER ]; then npm i -g npm@4; fi
- if [ $REQUIRES_SERVER ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10; fi
- if [ $REQUIRES_SERVER ]; then echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list; fi
- if [ $REQUIRES_SERVER ]; then sudo apt-get update; fi
- if [ $REQUIRES_SERVER ]; then sudo apt-get install mongodb-org-server; fi
- if [ $REQUIRES_SERVER ]; then git clone https://github.com/HabitRPG/habitrpg.git ../habitrpg; fi
- if [ $REQUIRES_SERVER ]; then until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 2; done; fi
- if [ $REQUIRES_SERVER ]; then cd ../habitrpg && cp config.json.example config.json && npm install; fi
- if [ $REQUIRES_SERVER ]; then npm start; fi &
- if [ $REQUIRES_SERVER ]; then until nc -z localhost 3000; do echo Waiting for Habitica Server; sleep 2; done; fi
- if [ $REQUIRES_SERVER ]; then cd -; fi
- if [ $REQUIRES_SERVER = "true" ]; then nvm install 6.9.3; fi
- if [ $REQUIRES_SERVER = "true" ]; then nvm use 6.9.3; fi
- if [ $REQUIRES_SERVER = "true" ]; then npm i -g npm@6; fi
- if [ $REQUIRES_SERVER = "true" ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10; fi
- if [ $REQUIRES_SERVER = "true" ]; then echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list; fi
- if [ $REQUIRES_SERVER = "true" ]; then sudo apt-get update || true; fi
- if [ $REQUIRES_SERVER = "true" ]; then sudo apt-get -y install mongodb; fi
- if [ $REQUIRES_SERVER = "true" ]; then git clone https://github.com/HabitRPG/habitica.git; fi
- if [ $REQUIRES_SERVER = "true" ]; then until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 2; done; fi
- if [ $REQUIRES_SERVER = "true" ]; then cd habitica && cp config.json.example config.json && npm install; fi
- if [ $REQUIRES_SERVER = "true" ]; then npm start; fi &
- if [ $REQUIRES_SERVER = "true" ]; then until nc -z localhost 3000; do echo Waiting for Habitica Server; sleep 2; done; fi
- if [ $REQUIRES_SERVER = "true" ]; then cd -; fi
android:
components:
# Uncomment the lines below if you want to
@ -35,7 +38,7 @@ android:
- build-tools-28.0.3
# The SDK version used to compile your project
- android-28
- android-29
# Additional components
- extra-google-google_play_services
@ -55,11 +58,11 @@ before_script:
- cp habitica.resources.example habitica.resources
- cp Habitica/google-services.json.example Habitica/google-services.json
script:
- ./gradlew $TEST
- ./gradlew $TEST2
env:
global:
- CXX=g++-4.8
- DISABLE_REQUEST_LOGGING=true
matrix:
- TEST="assembleDebug -PdisablePreDex"
- TEST="testProdDebugUnitTest -PdisablePreDex --stacktrace" REQUIRES_SERVER=true
- TEST1="assembleDebug -PdisablePreDex"
- TEST2="testProdDebugUnitTest -PdisablePreDex --stacktrace" REQUIRES_SERVER=false

View file

@ -18,6 +18,7 @@ buildscript {
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.android.tools.build:gradle:3.6.2'
classpath('com.noveogroup.android:check:1.2.5') {
exclude module: 'checkstyle'
exclude module: 'pmd-java'
@ -60,6 +61,7 @@ dependencies {
implementation 'com.google.dagger:dagger:2.25.4'
kapt 'com.google.dagger:dagger-compiler:2.25.4'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
compileOnly 'com.github.pengrad:jdk9-deps:1.0'
//App Compatibility and Material Design
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
@ -106,9 +108,9 @@ dependencies {
testImplementation "com.google.truth:truth:1.0.1"
testImplementation 'org.assertj:assertj-core:2.6.0'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.robolectric:shadows-multidex:3.8'
testImplementation 'org.mockito:mockito-core:2.8.9'
testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.0'
testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.7.0'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.7.0'
@ -144,7 +146,12 @@ dependencies {
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
buildToolsVersion '28.0.3'
testOptions {
unitTests {
includeAndroidResources = true
}
}
defaultConfig {
minSdkVersion 21

View file

@ -1,6 +1,5 @@
package com.habitrpg.android.habitica;
import com.habitrpg.android.habitica.modules.DeveloperModule;
//change debug proxy here by override methods

View file

@ -11,7 +11,6 @@ import java.util.Map;
/**
* Created by viirus on 23-Sep-16.
*/
public class AmplitudeManager {
public static String EVENT_CATEGORY_BEHAVIOUR = "behaviour";

View file

@ -17,7 +17,7 @@ class UserStatComputer {
var conVal: Float = 0.toFloat()
var perVal: Float = 0.toFloat()
var roundDown: Boolean = false
var isSummary: Boolean = false
var summary: Boolean = false
}
inner class EquipmentRow : StatsRow {
@ -125,7 +125,7 @@ class UserStatComputer {
attributeRow.conVal = conAttributes
attributeRow.perVal = perAttributes
attributeRow.roundDown = true
attributeRow.isSummary = false
attributeRow.summary = false
skillRows.add(attributeRow)
@ -136,7 +136,7 @@ class UserStatComputer {
attributeRow2.conVal = conClassBonus
attributeRow2.perVal = perClassBonus
attributeRow2.roundDown = false
attributeRow2.isSummary = false
attributeRow2.summary = false
skillRows.add(attributeRow2)
return skillRows

View file

@ -62,8 +62,6 @@ public class SubscriptionPlan extends RealmObject {
return totalNumberOfGems() - gemsBought;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
if (consecutive != null && !consecutive.isManaged()) {

View file

@ -369,7 +369,7 @@ class FullProfileActivity : BaseActivity() {
if (row is UserStatComputer.EquipmentRow) {
addEquipmentRow(equipmentTableLayout, row.gearKey, row.text, row.stats)
} else if (row is UserStatComputer.AttributeRow) {
addAttributeRow(getString(row.labelId), row.strVal, row.intVal, row.conVal, row.perVal, row.roundDown, row.isSummary)
addAttributeRow(getString(row.labelId), row.strVal, row.intVal, row.conVal, row.perVal, row.roundDown, row.summary)
}
}

View file

@ -224,6 +224,10 @@ class TaskFormActivity : BaseActivity() {
when (item?.itemId) {
R.id.action_save -> saveTask()
R.id.action_delete -> deleteTask()
android.R.id.home -> {
onBackPressed()
return true
}
}
return super.onOptionsItemSelected(item)
}

View file

@ -9,7 +9,6 @@ import io.realm.Realm;
class TestRepositoryModule extends RepositoryModule {
@Provides
@Override
public Realm providesRealm() {

View file

@ -2,27 +2,27 @@ package com.habitrpg.android.habitica.helpers;
import android.content.Context;
import com.habitrpg.android.habitica.BuildConfig;
import com.habitrpg.android.habitica.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@Config(constants = BuildConfig.class)
@RunWith(value = RobolectricTestRunner.class)
public class NumberAbbreviatorTest {
private Context context;
@Before
public void setUp() {
context = RuntimeEnvironment.application;
context = mock(Context.class);
when(context.getString(R.string.thousand_abbrev)).thenReturn("k");
when(context.getString(R.string.million_abbrev)).thenReturn("m");
when(context.getString(R.string.billion_abbrev)).thenReturn("b");
when(context.getString(R.string.trillion_abbrev)).thenReturn("t");
}
@Test

View file

@ -1,127 +1,127 @@
package com.habitrpg.android.habitica.helpers;
//package com.habitrpg.android.habitica.helpers;
//
//import com.habitrpg.android.habitica.BuildConfig;
//import com.habitrpg.android.habitica.api.HostConfig;
//import com.habitrpg.android.habitica.models.Notification;
//import com.habitrpg.android.habitica.models.notifications.LoginIncentiveData;
//
//import org.junit.Before;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.mockito.Mockito;
//import org.robolectric.RobolectricTestRunner;
//import org.robolectric.RuntimeEnvironment;
//import org.robolectric.annotation.Config;
//import org.robolectric.shadows.ShadowAlertDialog;
//
//import android.app.AlertDialog;
//import android.content.Context;
//import android.os.Build;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import static org.junit.Assert.assertNull;
//import static org.mockito.Mockito.mock;
//import static org.mockito.Mockito.times;
//import static org.mockito.Mockito.verify;
//
///**
// * Created by krh12 on 12/9/2016.
// */
//
//@Config(sdk = Build.VERSION_CODES.M)
//public class PopupNotificationsManagerTest {
//
// public HostConfig hostConfig;
// private Context context;
// private NotificationsManager notificationsManager;
//
// @Before
// public void setUp() {
// context = mock(Context.class);
// hostConfig = new HostConfig(BuildConfig.BASE_URL,
// BuildConfig.PORT,
// "",
// "");
// notificationsManager = new NotificationsManager(context);
// }
import com.habitrpg.android.habitica.BuildConfig;
import com.habitrpg.android.habitica.api.HostConfig;
import com.habitrpg.android.habitica.models.Notification;
import com.habitrpg.android.habitica.models.notifications.LoginIncentiveData;
// @Test
// public void itDoesNothingWhenNotificationsListIsEmpty() {
// List<Notification> notifications = new ArrayList<>();
// notificationsManager.handlePopupNotifications(notifications);
//
// AlertDialog alert =
// ShadowAlertDialog.getLatestAlertDialog();
// assertNull(alert);
// }
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowAlertDialog;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Build;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* Created by krh12 on 12/9/2016.
*/
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.M)
@RunWith(RobolectricTestRunner.class)
public class PopupNotificationsManagerTest {
public HostConfig hostConfig;
private Context context;
private NotificationsManager notificationsManager;
@Before
public void setUp() {
context = RuntimeEnvironment.application;
hostConfig = new HostConfig(BuildConfig.BASE_URL,
BuildConfig.PORT,
"",
"");
notificationsManager =new NotificationsManager(context);
}
@Test
public void itDoesNothingWhenNotificationsListIsEmpty() {
List<Notification> notifications = new ArrayList<>();
notificationsManager.handlePopupNotifications(notifications);
AlertDialog alert =
ShadowAlertDialog.getLatestAlertDialog();
assertNull(alert);
}
@Test
// @TODO: Eventually, we should have a list of implemented notifications and only use those
public void itShouldNotDisplayNotificationsThatAreNotLoginIncentives() {
List<Notification> notifications = new ArrayList<>();
Notification notification = new Notification();
notification.setType("NOT_LOGIN_INCENTIVE");
notifications.add(notification);
final NotificationsManager testClass = Mockito.mock(NotificationsManager.class);
Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
testClass.handlePopupNotifications(notifications);
verify(testClass, times(0)).displayLoginIncentiveNotification(notification);
}
@Test
public void itShouldDisplayADialogueForANotification() {
String testTitle = "Test Title";
List<Notification> notifications = new ArrayList<>();
LoginIncentiveData notificationData = new LoginIncentiveData();
notificationData.setMessage(testTitle);
Notification notification = new Notification();
notification.setType("LOGIN_INCENTIVE");
notification.setData(notificationData);
notifications.add(notification);
final NotificationsManager testClass = Mockito.mock(NotificationsManager.class);
Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
testClass.handlePopupNotifications(notifications);
verify(testClass, times(1)).displayLoginIncentiveNotification(notification);
}
@Test
public void itShouldNotDisplayANotificationTwice() {
String testTitle = "Test Title";
List<Notification> notifications = new ArrayList<>();
LoginIncentiveData notificationData = new LoginIncentiveData();
notificationData.setMessage(testTitle);
Notification notification = new Notification();
notification.setType("LOGIN_INCENTIVE");
notification.setData(notificationData);
notifications.add(notification);
notifications.add(notification);
final NotificationsManager testClass = Mockito.mock(NotificationsManager.class);
Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
testClass.handlePopupNotifications(notifications);
verify(testClass, times(1)).displayLoginIncentiveNotification(notification);
}
}
// @Test
// // @TODO: Eventually, we should have a list of implemented notifications and only use those
// public void itShouldNotDisplayNotificationsThatAreNotLoginIncentives() {
// List<Notification> notifications = new ArrayList<>();
//
// Notification notification = new Notification();
// notification.setType("NOT_LOGIN_INCENTIVE");
//
// notifications.add(notification);
//
// final NotificationsManager testClass = mock(NotificationsManager.class);
// Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
// Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
//
// testClass.handlePopupNotifications(notifications);
//
// verify(testClass, times(0)).displayLoginIncentiveNotification(notification);
// }
//
// @Test
// public void itShouldDisplayADialogueForANotification() {
// String testTitle = "Test Title";
//
// List<Notification> notifications = new ArrayList<>();
//
// LoginIncentiveData notificationData = new LoginIncentiveData();
// notificationData.setMessage(testTitle);
//
// Notification notification = new Notification();
// notification.setType("LOGIN_INCENTIVE");
// notification.setData(notificationData);
//
// notifications.add(notification);
//
// final NotificationsManager testClass = mock(NotificationsManager.class);
// Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
// Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
//
// testClass.handlePopupNotifications(notifications);
//
// verify(testClass, times(1)).displayLoginIncentiveNotification(notification);
// }
//
// @Test
// public void itShouldNotDisplayANotificationTwice() {
// String testTitle = "Test Title";
//
// List<Notification> notifications = new ArrayList<>();
//
// LoginIncentiveData notificationData = new LoginIncentiveData();
// notificationData.setMessage(testTitle);
//
// Notification notification = new Notification();
// notification.setType("LOGIN_INCENTIVE");
// notification.setData(notificationData);
//
// notifications.add(notification);
// notifications.add(notification);
//
// final NotificationsManager testClass = mock(NotificationsManager.class);
// Mockito.when(testClass.displayLoginIncentiveNotification(notification)).thenReturn(true);
// Mockito.when(testClass.handlePopupNotifications(notifications)).thenCallRealMethod();
//
// testClass.handlePopupNotifications(notifications);
//
// verify(testClass, times(1)).displayLoginIncentiveNotification(notification);
// }
//}

View file

@ -73,7 +73,7 @@ public class UserStatComputerTest {
Assert.assertEquals(con * 0.0f, attributeRow.getConVal());
Assert.assertEquals(per * 0.5f, attributeRow.getPerVal());
Assert.assertFalse(attributeRow.getRoundDown());
Assert.assertFalse(attributeRow.getIsSummary());
Assert.assertFalse(attributeRow.getSummary());
}
@Test
@ -91,7 +91,7 @@ public class UserStatComputerTest {
Assert.assertEquals(con * 0.0f, attributeRow.getConVal());
Assert.assertEquals(per * 0.5f, attributeRow.getPerVal());
Assert.assertFalse(attributeRow.getRoundDown());
Assert.assertFalse(attributeRow.getIsSummary());
Assert.assertFalse(attributeRow.getSummary());
}
@Test
@ -109,6 +109,6 @@ public class UserStatComputerTest {
Assert.assertEquals(con * 0.0f, attributeRow.getConVal());
Assert.assertEquals(per * 0.0f, attributeRow.getPerVal());
Assert.assertFalse(attributeRow.getRoundDown());
Assert.assertFalse(attributeRow.getIsSummary());
Assert.assertFalse(attributeRow.getSummary());
}
}

View file

@ -16,14 +16,15 @@ public class SubscriptionPlanTest {
@Before
public void setUp() throws Exception {
this.plan = new SubscriptionPlan();
this.plan.setCustomerId("fake_customer_id");
this.plan.planId = "test";
}
@Test
public void isInactiveForNoPlanId() throws Exception {
this.plan.planId = null;
assertFalse(this.plan.isActive());
}
// @Test
// public void isInactiveForNoPlanId() throws Exception {
// this.plan.planId = null;
// assertFalse(this.plan.isActive());
// }
@Test
public void isActiveForNoTerminationDate() throws Exception {

View file

@ -18,7 +18,6 @@ import io.realm.RealmList;
import static org.junit.Assert.assertEquals;
@Config(constants = BuildConfig.class)
public class UserTest {
private User user;

View file

@ -21,8 +21,6 @@ import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@Config(constants = BuildConfig.class)
@RunWith(RobolectricTestRunner.class)
public class DateDeserializerTest {
DateDeserializer deserializer;
JsonDeserializationContext deserializationContext;

View file

@ -2,6 +2,7 @@ android.enableJetifier=true
android.useAndroidX=true
android.enableR8=true
android.debug.obsoleteApi=true
android.enableUnitTestBinaryResources=true
org.gradle.configureondemand=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx6656M

View file

@ -15,3 +15,4 @@ BASE_URL=https://habitica.com
STAGING_KEY=
ANDROID_TESTING_UUID=
APPLE_AUTH_CLIENT_ID=

View file

@ -2,3 +2,4 @@ PORT=3000
BASE_URL=http://localhost:3000
STAGING_KEY=
ANDROID_TESTING_UUID=
APPLE_AUTH_CLIENT_ID=