Commit eb81ce06 authored by Matyáš Latner's avatar Matyáš Latner

#352 Ability to create IPA package with test bundle and directly run test...

#352 Ability to create IPA package with test bundle and directly run test bundle on IOS device, iPad simulator and iPhone simulator
parent e9dd7e6c
......@@ -51,6 +51,8 @@ allprojects {
applicationIdRelease = 'cz.nic.tablexia'
applicationIdDebugSuffix = '.debug'
applicationIdDebug = applicationIdRelease + applicationIdDebugSuffix
applicationIdITestSuffix = '.itest'
applicationIdITest = applicationIdRelease + applicationIdITestSuffix
applicationIdDevelSuffix = '.devel'
applicationIdDevel = applicationIdRelease + applicationIdDevelSuffix
......
......@@ -70,6 +70,7 @@ public class TablexiaSettings {
// boxes aInfo sInfo dMenu btName bReport
RELEASE ("release", false, false, false, false, false, true, Log.TablexiaLogLevel.ERROR),
DEBUG ("debug", false, false, true, true, true, true, Log.TablexiaLogLevel.DEBUG),
ITEST ("itest", false, true, true, false, true, false, Log.TablexiaLogLevel.DEBUG),
DEVEL ("devel", true, true, true, true, true, false, Log.TablexiaLogLevel.DEBUG);
private final static BuildType FALLBACK_VARIANT = BuildType.DEVEL;
......
sourceSets.main.java.srcDirs = [ "src/" ]
sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets {
main {
java {
srcDir 'src/main'
}
}
iTest {
java {
srcDir 'src/iTest/'
}
compileClasspath += sourceSets.main.runtimeClasspath
}
}
robovm {
iosSkipSigning = false
}
ext {
mainClassName = "cz.nic.tablexia.IOSLauncher"
mainLauncherClassName = "cz.nic.tablexia.IOSLauncher"
iTestLauncherClassName = "cz.nic.tablexia.IOSITestLauncher"
}
configurations {
iTestCompile.extendsFrom compile
iTestRuntime.extendsFrom runtime
}
// Updates or create a robovm.properties file.
def updateRoboVMProperties(String buildType, String applicationId, String iconName) {
def updateRoboVMProperties(String buildType, String applicationId, String mainClassName, String iconName) {
Properties props = new Properties()
def propsFile = file('robovm.properties')
......@@ -77,38 +95,76 @@ task updateRoboVMXML << {
tasks.launchIPadSimulator.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, mainLauncherClassName, 'Icon_devel')
}
tasks.launchIPhoneSimulator.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, mainLauncherClassName, 'Icon_devel')
}
tasks.launchIOSDevice.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, mainLauncherClassName, 'Icon_devel')
}
tasks.create(name: "launchITestOnIPadSimulator", type: org.robovm.gradle.tasks.IPadSimulatorTask) {
doFirst {
project.ext.set("output.classesDir", new File("ios/build/classes/iTest"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("itest", applicationIdDebug, iTestLauncherClassName, 'Icon_devel')
}
}
tasks.create(name: "launchITestOnIPhoneSimulator", type: org.robovm.gradle.tasks.IPhoneSimulatorTask) {
doFirst {
project.ext.set("output.classesDir", new File("ios/build/classes/iTest"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("itest", applicationIdDebug, iTestLauncherClassName, 'Icon_devel')
}
}
tasks.create(name: "launchITestOnIOSDevice", type: org.robovm.gradle.tasks.IOSDeviceTask) {
doFirst {
project.ext.set("output.classesDir", new File("ios/build/classes/iTest"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("itest", applicationIdDebug, iTestLauncherClassName, 'Icon_devel')
}
}
tasks.create(name: "createITestIPA", type: org.robovm.gradle.tasks.ArchiveTask) {
doFirst {
project.ext.set("output.classesDir", new File("ios/build/classes/iTest"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_DEBUG_PROVISIONING
updateRoboVMProperties("itest", applicationIdDebug, iTestLauncherClassName, 'Icon_debug')
}
}
tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.ArchiveTask) {
doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_DEBUG_PROVISIONING
updateRoboVMProperties("debug", applicationIdDebug, 'Icon_debug')
project.ext.set("output.classesDir", new File("do_not_include_any_additional_classes"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_DEBUG_PROVISIONING
updateRoboVMProperties("debug", applicationIdDebug, mainLauncherClassName, 'Icon_debug')
}
}
tasks.create(name: "createReleaseIPA", type: org.robovm.gradle.tasks.ArchiveTask) {
doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_RELEASE_PROVISIONING
updateRoboVMProperties("release", applicationIdRelease, 'Icon_release')
project.ext.set("output.classesDir", new File("do_not_include_any_additional_classes"))
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_RELEASE_PROVISIONING
updateRoboVMProperties("release", applicationIdRelease, mainLauncherClassName, 'Icon_release')
}
}
task createIPAFiles() {
dependsOn createDebugIPA
dependsOn createReleaseIPA
dependsOn createITestIPA
}
launchIPadSimulator.dependsOn assemble
......@@ -119,9 +175,20 @@ launchIOSDevice.dependsOn assemble
launchIOSDevice.dependsOn updateRoboVMXML
updateRoboVMXML.dependsOn(':util:checksum:runChecksum')
launchITestOnIPadSimulator.dependsOn iTestClasses
launchITestOnIPadSimulator.dependsOn assemble
launchITestOnIPadSimulator.dependsOn updateRoboVMXML
launchITestOnIPhoneSimulator.dependsOn iTestClasses
launchITestOnIPhoneSimulator.dependsOn assemble
launchITestOnIPhoneSimulator.dependsOn updateRoboVMXML
launchITestOnIOSDevice.dependsOn iTestClasses
launchITestOnIOSDevice.dependsOn assemble
launchITestOnIOSDevice.dependsOn updateRoboVMXML
updateRoboVMXML.dependsOn copyNatives
build.dependsOn createDebugIPA
build.dependsOn createReleaseIPA
build.dependsOn createITestIPA
tasks.eclipse.dependsOn updateRoboVMXML
//launchIPhoneSimulator.dependsOn build
......@@ -129,6 +196,8 @@ tasks.eclipse.dependsOn updateRoboVMXML
//launchIOSDevice.dependsOn build
//createIPA.dependsOn build
createITestIPA.dependsOn iTestClasses
createITestIPA.dependsOn updateRoboVMXML
createDebugIPA.dependsOn updateRoboVMXML
createReleaseIPA.dependsOn updateRoboVMXML
......
#
#Tue Jul 28 10:13:55 CEST 2015
app.icon=Icon_devel
app.id=cz.nic.tablexia.devel
app.version=55b5a3f
#Fri May 27 14:57:31 CEST 2016
app.icon=Icon_release
app.id=cz.nic.tablexia
app.version=3.2-SNAPSHOT-automated_testing-45
app.mainclass=cz.nic.tablexia.IOSLauncher
app.executable=Tablexia-devel-55b5a3f
app.build=1438069145
app.buildtype=devel
app.executable=Tablexia-release-3.2-SNAPSHOT-automated_testing-45
app.build=1463657946
app.buildtype=release
app.name=Tablexia
package cz.nic.tablexia;
import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.foundation.NSBundle;
import org.robovm.apple.foundation.NSDictionary;
import org.robovm.apple.foundation.NSString;
import org.robovm.apple.glkit.GLKViewDrawableMultisample;
import org.robovm.apple.systemconfiguration.SCNetworkReachability;
import org.robovm.apple.systemconfiguration.SCNetworkReachabilityFlags;
import org.robovm.apple.uikit.UIApplication;
import org.robovm.apple.uikit.UIApplicationLaunchOptions;
import cz.nic.tablexia.testing.TestComponentRegister;
import cz.nic.tablexia.testing.TestScenarioNewUser;
import java.net.InetSocketAddress;
import java.util.Locale;
import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.testing.DummyComponentRegister;
public class IOSITestLauncher extends IOSApplication.Delegate {
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("SQLite.JDBCDriver", "jdbc:sqlite:");
private static final String FALLBACK_CONNECTION_CHECK_HOST = "nic.cz";
private static final Integer FALLBACK_CONNECTION_CHECK_PORT = 80;
private static final String CONNECTION_CHECK_HOST = TablexiaBuildConfig.TABLEXIA_SERVER_HOST != null ? TablexiaBuildConfig.TABLEXIA_SERVER_HOST : FALLBACK_CONNECTION_CHECK_HOST;
private static final Integer CONNECTION_CHECK_PORT = TablexiaBuildConfig.TABLEXIA_SERVER_PORT != null ? TablexiaBuildConfig.TABLEXIA_SERVER_PORT : FALLBACK_CONNECTION_CHECK_PORT;
private static TestComponentRegister register;
private static TestScenarioNewUser testScenario;
private static Tablexia tablexia;
private TablexiaIOSFiles tablexiaIOSFiles;
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.multisample = GLKViewDrawableMultisample._4X;
NSDictionary infoDictionary = NSBundle.getMainBundle().getInfoDictionary();
String buildType = infoDictionary.get(new NSString("cz.nic.tablexia.BuildType")).toString();
register = new TestComponentRegister();
tablexiaIOSFiles = new TablexiaIOSFiles();
IOSApplication iosApplication = new IOSApplication(tablexia = new Tablexia(buildType,
Locale.getDefault(),
SQL_CONNECTION_TYPE,
new IOSConnectionManager(),
false,
register), config) {
@Override
public Files getFiles() {
return tablexiaIOSFiles;
}
};
return iosApplication;
}
@Override
public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
boolean result = super.didFinishLaunching(application, launchOptions);
Gdx.files = tablexiaIOSFiles;
testScenario = new TestScenarioNewUser(register, tablexia);
return result;
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSITestLauncher.class);
pool.close();
}
private static class IOSConnectionManager implements IConnectionManager {
@Override
public boolean isUsingMobileData() {
InetSocketAddress socketAddress = new InetSocketAddress(CONNECTION_CHECK_HOST, CONNECTION_CHECK_PORT);
// RoboVM tries to retrive IP address using network connection. If we don't have it InetSocketAddress.getAddress() returns null
// in that case SCNetworkReachability.create(socketAddress) throws IllegalArgumentException
if (socketAddress.getAddress() == null) {
return false;
}
SCNetworkReachabilityFlags flags = SCNetworkReachability.create(socketAddress).getFlags();
return flags.compareTo(SCNetworkReachabilityFlags.IsWWAN) == 1;
}
}
}
\ No newline at end of file
......@@ -54,6 +54,8 @@ public class IOSLauncher extends IOSApplication.Delegate {
return tablexiaIOSFiles;
}
};
System.out.println("------->> TEST");
return iosApplication;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment