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

Removed Spoon dependency

parent 586e7298
......@@ -72,9 +72,6 @@ android {
java.srcDir file('src/main/java')
jniLibs.srcDirs = ['libs']
}
androidTest {
java.srcDir file('src/androidTest/java')
}
test {
java.srcDir file('src/test/java')
}
......@@ -250,11 +247,3 @@ idea {
}
}
}
spoon {
debug = true
failOnFailure = false
//testSizes = ['small', 'medium']
adbTimeout = 10*60
failIfNoDeviceConnected = false
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program 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.
*
* This program 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 cz.nic.tablexia.android.test.instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import com.squareup.spoon.Spoon;
import java.io.File;
import cz.nic.tablexia.android.AndroidLauncher;
/**
* Created by lhoracek on 5/13/15.
*/
public abstract class AbstractOpenglTest<T extends AndroidLauncher> extends ActivityInstrumentationTestCase2<T> {
public AbstractOpenglTest(Class<T> activityClass) {
super(activityClass);
}
/**
* Sleep the thread to wait for animations to complete
*
* @param seconds
*/
protected void sleep(float seconds) {
try {
Thread.sleep((int) (seconds * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* Take screenshot using custom OpenGL readPixels buffer method instead of using decorView. Lets the Spoon create the file first and then just overwrites it.
* Not the best method, but the simplest.
* @param name
*/
protected void screenshot(String name) {
File screenshot = Spoon.screenshot(getActivity(), name);
getActivity().takeScreenshot(screenshot);
sleep(3);
}
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program 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.
*
* This program 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 cz.nic.tablexia.android.test.instrumentation;
import android.test.suitebuilder.annotation.SmallTest;
import cz.nic.tablexia.android.AndroidLauncher;
public class ScreenTest extends AbstractOpenglTest<AndroidLauncher> {
public ScreenTest() {
super(AndroidLauncher.class);
}
@SmallTest
public void testScreenshot() throws Throwable {
final AndroidLauncher act = getActivity();
sleep(10);
screenshot("startup");
sleep(10);
screenshot("startup");
}
}
......@@ -19,27 +19,20 @@ package cz.nic.tablexia.android;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.net.ConnectivityManager;
import android.os.Build;
import android.os.Bundle;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.flurry.android.FlurryAgent;
import java.io.File;
import java.io.FileOutputStream;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaBuildConfig;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.debug.BuildConfig;
import cz.nic.tablexia.debug.R;
import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.Log;
public class AndroidLauncher extends AndroidApplication {
......@@ -85,41 +78,6 @@ public class AndroidLauncher extends AndroidApplication {
}
}
/**
* Method supporting screenshots during UI testing the application using OpenGL
*
* @param file
*/
public void takeScreenshot(final File file) {
tablexia.takeScreenShot(new Tablexia.ScreenshotListener() {
@Override
public void screenshotTaken(int[] screen) {
int width = Gdx.graphics.getWidth();
int height = Gdx.graphics.getHeight();
try {
for (int i = 0; i < screen.length; ++i) {
// The alpha and green channels' positions are preserved while the red and blue are swapped
screen[i] = ((screen[i] & 0xff00ff00)) | ((screen[i] & 0x000000ff) << 16) | ((screen[i] & 0x00ff0000) >> 16);
}
Bitmap sb = Bitmap.createBitmap(screen, width, height, Bitmap.Config.RGB_565);
// flip bitmap vertically
Matrix matrixMirror = new Matrix();
matrixMirror.preScale(1.0f, -1.0f);
sb = Bitmap.createBitmap(sb, 0, 0, sb.getWidth(), sb.getHeight(), matrixMirror, false);
// overwrite file
FileOutputStream fOut = new FileOutputStream(file);
sb.compress(Bitmap.CompressFormat.PNG, 100, fOut);
sb.recycle();
fOut.flush();
fOut.close();
} catch (Exception e) {
e.printStackTrace();
Log.err(this.getClass().getSimpleName(), e.getMessage());
}
}
});
}
public void post(Runnable r) {
handler.post(r);
}
......
......@@ -27,7 +27,6 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
classpath 'de.felixschulze.gradle:gradle-spoon-plugin:2.1'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
classpath 'com.novoda:gradle-android-command-plugin:1.3.0'
classpath 'com.badlogicgames.gdx:gdx-tools:1.6.1'
......@@ -371,7 +370,6 @@ project(":desktop") {
project(":android") {
apply plugin: 'android-sdk-manager'
apply plugin: "android"
apply plugin: "spoon"
apply plugin: 'android-command'
configurations { natives }
......@@ -393,7 +391,6 @@ project(":android") {
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
testCompile 'org.robolectric:robolectric:2.3'
androidTestCompile "com.squareup.spoon:spoon-client:1.1.7"
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
}
}
......
......@@ -22,7 +22,6 @@ import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.google.zxing.qrcode.encoder.QRCode;
import net.engio.mbassy.bus.error.IPublicationErrorHandler;
import net.engio.mbassy.bus.error.PublicationError;
......
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