Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
shineangelic committed Oct 29, 2019
2 parents 4b0c7e5 + efd7617 commit 9426c62
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
4 changes: 2 additions & 2 deletions SoulissApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ android {

defaultConfig {
applicationId "it.angelic.soulissclient"
testApplicationId "it.angelic.soulissclientest"
// testApplicationId "it.angelic.soulissclientest"
minSdkVersion 14
targetSdkVersion rootProject.ext.targetSdkVersion
versionName rootProject.ext.VERSION_NAME
versionCode rootProject.ext.VERSION_CODE
vectorDrawables.useSupportLibrary = true
// multiDexEnabled true
//multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public void testTargetSdk() {
}

try {
final Context localeContext = getContext().createPackageContext(hostPackage, 0);
assertTrue(getContext().getApplicationInfo().targetSdkVersion >= localeContext.getApplicationInfo().targetSdkVersion);
final Context localeContext = context.createPackageContext(hostPackage, 0);
assertTrue(context.getApplicationInfo().targetSdkVersion >= localeContext.getApplicationInfo().targetSdkVersion);
} catch (final NameNotFoundException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package it.angelic.soulissclient.net;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Environment;
import android.util.Log;

import java.io.File;
import java.io.IOException;

import androidx.test.platform.app.InstrumentationRegistry;
import it.angelic.soulissclient.Constants;
Expand All @@ -15,6 +18,8 @@
import it.angelic.soulissclient.model.db.SoulissDBOpenHelper;
import it.angelic.soulissclient.model.typicals.SoulissTypical11DigitalOutput;
import it.angelic.soulissclient.model.typicals.SoulissTypical51AnalogueSensor;
import it.angelic.soulissclient.util.FontAwesomeEnum;
import it.angelic.soulissclient.util.FontAwesomeUtil;


/**
Expand All @@ -41,6 +46,7 @@ protected void addFakeLight() {

protected void addFakeNode() {
SoulissNode testNode = new SoulissNode(context, fakeNodeId);
//testNode.setIconResourceId(null);
// Here i have my new database wich is not connected to the standard database of the App
db.createOrUpdateNode(testNode);
assertEquals(1, db.countNodes());
Expand All @@ -59,15 +65,44 @@ protected void addFakeSensor() {
// Here i have my new database wich is not connected to the standard database of the App
}

private boolean checkDataBase(String path) throws IOException {
SQLiteDatabase checkDB = null;
try {
File file = new File(path);
File dir = new File( file.getParent());
if (file.exists() && !file.isDirectory())
checkDB = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READWRITE);
else if (!dir.exists()){
dir.mkdir();
}else if (!file.exists()){
file.createNewFile();
}
} catch (SQLiteException e) {
// database does't exist yet.

}

if (checkDB != null) {
checkDB.close();
}

return checkDB != null ? true : false;
}

@Override
public void setUp() throws Exception {
super.setUp();
context = InstrumentationRegistry.getInstrumentation().getContext();
//non va perche` il context e` farlocco, mDatabaseDir nulla


db = new SoulissDBHelper(context);
opzioni = new SoulissPreferenceHelper(context);
SoulissDBHelper.open();

checkDataBase(context.getDatabasePath(SoulissDBOpenHelper.DATABASE_NAME).getPath());
//non va perche` il context e` farlocco, mDatabaseDir nulla?
//SoulissDBHelper.open();

assertNotNull(db);

addFakeNode();
addFakeLight();
Expand All @@ -77,7 +112,7 @@ public void setUp() throws Exception {

@Override
public void tearDown() throws Exception {
context.deleteDatabase(SoulissDBOpenHelper.DATABASE_NAME);
//context.deleteDatabase(SoulissDBOpenHelper.DATABASE_NAME);

Log.i(Constants.TAG, "tearDown test DB");
db.close();
Expand All @@ -88,7 +123,9 @@ public void tearDown() throws Exception {
}

public void testExport() {

db = new SoulissDBHelper(context);
opzioni = new SoulissPreferenceHelper(context);
SoulissDBHelper.open();
ExportDatabaseCSVTask tas = new ExportDatabaseCSVTask();

tas.loadContext(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,21 @@ protected void onStart() {

private void startLocationUpdates() {
Log.w(Constants.TAG, "Requesting POS updates ");
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
Log.w(Constants.TAG, "RECEIVE POS updates " + locationResult);
if (locationResult == null) {
return;
}
for (Location location : locationResult.getLocations()) {
if (launcherMainAdapter.getLocationLauncherElements() != null) {
onLocationChanged(location);
}
}
}
};

LocationRequest locReq = createLocationRequest();
locationCallback = new LocationCallback() {
@Override
Expand Down
1 change: 0 additions & 1 deletion soulissLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.1.0'
}

0 comments on commit 9426c62

Please sign in to comment.