Verified Commit 32b3025a authored by RobLoach's avatar RobLoach
Browse files

Clean the NativeTest

parent 5f1c3df9
......@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## 0.14.1 - Unreleased
### Changed
- Updated documentation
- Fixed native test
## 0.14.0 - 2018-01-16
### Changed
......
......@@ -85,7 +85,7 @@ tests: dependencies
$(MAKE) HAVE_CHAISCRIPT=0 HAVE_TESTS=1
test-native: tests
retroarch -L $(TARGET) test/main.chai
retroarch -L $(TARGET) test/native/main.chai
PREFIX := /usr
INSTALLDIR := $(PREFIX)/lib/libretro
......
......@@ -76,7 +76,7 @@
#include "love/event.h"
#ifdef __HAVE_TESTS__
#include "../test/native/Main.h"
#include "../test/native/NativeTest.h"
#endif
class ChaiLove {
......@@ -118,7 +118,7 @@ class ChaiLove {
SDL_Event sdlEvent;
#ifdef __HAVE_TESTS__
Main test;
NativeTest test;
#endif
};
......
......@@ -8,18 +8,18 @@
#ifdef __HAVE_TESTS__
#include "Main.h"
#include "NativeTest.h"
#include "../../src/ChaiLove.h"
using love::config;
void Main::conf(config& t) {
void NativeTest::conf(config& t) {
t.window.width = 1080;
t.window.height = 768;
}
bool Main::load() {
app = ChaiLove::getInstance();
bool NativeTest::load() {
ChaiLove* app = ChaiLove::getInstance();
app->filesystem.mount("test", "/");
secondfont = app->graphics.newFont("assets/Raleway-Regular.ttf", 60);
thefont = app->graphics.newFont("assets/c64_16x16.png", 16, 16, "\x7f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
......@@ -28,13 +28,15 @@ bool Main::load() {
jump = app->sound.newSoundData("assets/jump.wav");
}
void Main::update(float delta) {
void NativeTest::update(float delta) {
ChaiLove* app = ChaiLove::getInstance();
if (app->joystick.isDown(0, 0) && !jump->isPlaying()) {
app->audio.play(jump);
}
}
void Main::draw() {
void NativeTest::draw() {
ChaiLove* app = ChaiLove::getInstance();
app->graphics.setColor(77, 182, 172);
app->graphics.ellipse("fill", 0, 768, 200, 180);
......
#ifdef __HAVE_TESTS__
#ifndef CHAILOVE_TEST_NATIVE_MAIN_H
#define CHAILOVE_TEST_NATIVE_MAIN_H
#ifndef CHAILOVE_TEST_NATIVE_NATIVETEST_H
#define CHAILOVE_TEST_NATIVE_NATIVETEST_H
#include "../../src/love/Types/Graphics/Image.h"
#include "../../src/love/Types/Graphics/Font.h"
#include "../../src/love/config.h"
#include "../../src/love/Types/Audio/SoundData.h"
#include "../../src/ChaiLove.h"
using love::Types::Graphics::Image;
using love::Types::Graphics::Font;
using love::config;
using love::Types::Audio::SoundData;
using ::ChaiLove;
class Main {
class NativeTest {
public:
void conf(config& t);
bool load();
......@@ -27,7 +24,6 @@ public:
Font* secondfont;
SoundData* jump;
Image* img;
ChaiLove* app;
};
#endif
......
# Native Tests
This provides some native tests to call ChaiLove directly through C++.
## Usage
```
make test-native
```
...or...
```
make tests
retroarch -L chailove_libretro.so test/native/main.chai
```
def draw() {
love.graphics.print("See NativeTests.cpp for the test cases", 5, 5)
}
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