Skip to content

Commit 42b67fd

Browse files
committed
Fix cpp-tests compile failed when ImGui disabled
1 parent 7b93444 commit 42b67fd

File tree

8 files changed

+27
-10
lines changed

8 files changed

+27
-10
lines changed

tests/cpp-tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ list(APPEND GAME_SOURCE
386386
Source/Box2DTest/Box2dTest.cpp
387387
)
388388

389-
if((WINDOWS OR MACOSX OR LINUX OR WASM) AND (NOT WINRT))
389+
if((WINDOWS OR MACOSX OR LINUX OR WASM) AND (NOT WINRT) AND AX_ENABLE_EXT_IMGUI)
390390
list(APPEND GAME_HEADER
391391
Source/Box2DTestBed/tests/test.h
392392
Source/Box2DTestBed/tests/settings.h

tests/cpp-tests/Source/BaseTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "testResource.h"
2929
#include "controller.h"
3030

31-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
31+
#if AX_ENABLE_EXT_IMGUI
3232
#include "Inspector/Inspector.h"
3333
#endif
3434

@@ -488,14 +488,14 @@ void TestCase::onEnter()
488488
_restartTestItem->setVisible(false);
489489
}
490490

491-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
491+
#if AX_ENABLE_EXT_IMGUI
492492
extension::Inspector::getInstance()->openForScene(this);
493493
#endif
494494
}
495495

496496
void TestCase::onExit()
497497
{
498-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
498+
#if AX_ENABLE_EXT_IMGUI
499499
extension::Inspector::getInstance()->close();
500500
#endif
501501
Scene::onExit();

tests/cpp-tests/Source/BaseTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "GUI/ScrollView/ScrollView.h"
3333
#include "GUI/ScrollView/TableView.h"
3434
#include "VisibleRect.h"
35+
#include "feature-detect.h"
3536

3637
class TestSuite;
3738

tests/cpp-tests/Source/ImGuiTest/ImGuiTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "platform/PlatformConfig.h"
22
#include "ImGuiTest.h"
33

4-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
4+
#if AX_ENABLE_EXT_IMGUI
55

66
#include "ImGui/ImGuiPresenter.h"
77
#if !defined(__ANDROID__)

tests/cpp-tests/Source/ImGuiTest/ImGuiTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "axmol.h"
3030
#include "../BaseTest.h"
3131

32-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
32+
#if AX_ENABLE_EXT_IMGUI
3333

3434
DEFINE_TEST_SUITE(ImGuiTests);
3535

tests/cpp-tests/Source/controller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class RootTests : public TestList
4747
addTest("Effekseer", []() { return new EffekseerTests(); });
4848
#endif
4949
addTest("Scene3D", [](){return new Scene3DTests(); });
50-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
50+
#if AX_ENABLE_EXT_IMGUI
5151
addTest("ImGui", []() { return new ImGuiTests(); });
5252
#endif
5353
addTest("Texture2D", []() { return new Texture2DTests(); });
@@ -58,11 +58,11 @@ class RootTests : public TestList
5858
addTest("AudioEngine", []() { return new AudioEngineTests(); });
5959

6060
addTest("Box2D - Basic", []() { return new Box2DTests(); });
61-
#if defined(AX_PLATFORM_PC) || defined(__EMSCRIPTEN__)
61+
#if AX_ENABLE_EXT_IMGUI
6262
addTest("Box2D - TestBed", []() { return new Box2DTestBedTests(); });
6363
#endif
6464
addTest("Chipmunk2D - Basic", []() { return new ChipmunkTests(); });
65-
#if defined(AX_PLATFORM_PC) || defined(__EMSCRIPTEN__)
65+
#if AX_ENABLE_EXT_IMGUI
6666
addTest("Chipmunk2D - TestBed", []() { return new ChipmunkTestBedTests(); });
6767
#endif
6868
addTest("Bugs", []() { return new BugsTests(); });
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
4+
# if __has_include("ImGui/ImGuiPresenter.h")
5+
# define AX_ENABLE_EXT_IMGUI 1
6+
# endif
7+
#endif
8+
9+
#ifndef AX_ENABLE_EXT_IMGUI
10+
# define AX_ENABLE_EXT_IMGUI 0
11+
#endif

tests/cpp-tests/Source/tests.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
#ifndef _TESTS_H_
2727
#define _TESTS_H_
2828

29+
#include "feature-detect.h"
30+
2931
#include "Box2DTest/Box2dTest.h"
32+
33+
# if AX_ENABLE_EXT_IMGUI
3034
#include "Box2DTestBed/Box2DTestBed.h"
35+
# endif
3136

3237
#include "ChipmunkTest/ChipmunkTest.h"
3338
#if defined(AX_PLATFORM_PC) || defined(__EMSCRIPTEN__)
@@ -121,7 +126,7 @@
121126
#include "VibrateTest/VibrateTest.h"
122127
#include "SpriteFrameCacheTest/SpriteFrameCacheTest.h"
123128
#include "ZipTest/ZipTests.h"
124-
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
129+
#if AX_ENABLE_EXT_IMGUI
125130
# include "ImGuiTest/ImGuiTest.h"
126131
#endif
127132
#endif

0 commit comments

Comments
 (0)