-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
207 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
sample-game/src/test/java/com/b3dgs/sample/ConstantTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2013-2023 Byron 3D Games Studio (www.b3dgs.com) Pierre-Alexandre (contact@b3dgs.com) | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.b3dgs.sample; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test {@link Constant}. | ||
*/ | ||
public class ConstantTest | ||
{ | ||
/** | ||
* Test all. | ||
*/ | ||
@Test | ||
public void testAll() | ||
{ | ||
Assertions.assertEquals("Sample", Constant.PROGRAM_NAME); | ||
Assertions.assertEquals("1.0.0", Constant.PROGRAM_VERSION.toString()); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
sample-pc/src/test/java/com/b3dgs/sample/pc/SampleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2013-2023 Byron 3D Games Studio (www.b3dgs.com) Pierre-Alexandre (contact@b3dgs.com) | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.b3dgs.sample.pc; | ||
|
||
import java.util.OptionalInt; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.b3dgs.lionengine.Config; | ||
import com.b3dgs.lionengine.Engine; | ||
import com.b3dgs.lionengine.awt.graphic.EngineAwt; | ||
import com.b3dgs.lionengine.graphic.engine.Loader; | ||
import com.b3dgs.lionengine.graphic.engine.TaskFuture; | ||
import com.b3dgs.sample.Constant; | ||
import com.b3dgs.sample.Scene; | ||
|
||
/** | ||
* Test correct {@link Scene} loading. | ||
*/ | ||
final class SampleTest | ||
{ | ||
/** | ||
* Init engine. | ||
*/ | ||
@BeforeAll | ||
static void prepareAll() | ||
{ | ||
EngineAwt.start(Constant.PROGRAM_NAME, Constant.PROGRAM_VERSION, AppSample.class); | ||
} | ||
|
||
/** | ||
* Init engine. | ||
*/ | ||
@BeforeEach | ||
void prepare() | ||
{ | ||
if (!Engine.isStarted()) | ||
{ | ||
EngineAwt.start(Constant.PROGRAM_NAME, Constant.PROGRAM_VERSION, AppSample.class); | ||
} | ||
} | ||
|
||
/** | ||
* Test scene. | ||
*/ | ||
@Test | ||
void testScene() | ||
{ | ||
final TaskFuture task = Loader.start(Config.windowed(Constant.NATIVE), TestScene.class, OptionalInt.of(1)); | ||
task.await(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
sample-pc/src/test/java/com/b3dgs/sample/pc/TestScene.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2013-2023 Byron 3D Games Studio (www.b3dgs.com) Pierre-Alexandre (contact@b3dgs.com) | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.b3dgs.sample.pc; | ||
|
||
import java.util.OptionalInt; | ||
|
||
import com.b3dgs.lionengine.Context; | ||
import com.b3dgs.lionengine.LionEngineException; | ||
import com.b3dgs.lionengine.Tick; | ||
import com.b3dgs.sample.Scene; | ||
|
||
/** | ||
* Test scene implementation. | ||
*/ | ||
public final class TestScene extends Scene | ||
{ | ||
private final Tick tick = new Tick(); | ||
|
||
/** | ||
* Create the scene. | ||
* | ||
* @param context The context reference (must not be <code>null</code>). | ||
* @param delay The exit delay. | ||
* @throws LionEngineException If invalid argument. | ||
*/ | ||
public TestScene(Context context, OptionalInt delay) | ||
{ | ||
super(context); | ||
|
||
delay.ifPresent(d -> tick.addAction(() -> end(null), d)); | ||
tick.start(); | ||
} | ||
|
||
@Override | ||
public void update(double extrp) | ||
{ | ||
tick.update(extrp); | ||
|
||
super.update(extrp); | ||
} | ||
} |