From debcc2428eddbec9503f2004a57e831eefe3a2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E9=A3=8E=E9=80=8D=E9=81=A5=E6=B8=B8?= Date: Sun, 3 Oct 2021 00:23:57 -0700 Subject: [PATCH] add test cases and impl window --- .gitignore | 1 + src/engine/common/Module.h | 10 +- .../cppfs/FileSystem.cpp => entity/Entity.h} | 0 src/modules/entity/EntityModule.h | 20 ++ src/modules/filesystem/Filesystem.cpp | 34 +++- src/modules/filesystem/Filesystem.h | 4 +- src/modules/filesystem/cppfs/FileSystem.h | 0 src/modules/filesystem/physfs/File.cpp | 6 +- src/modules/filesystem/physfs/Filesystem.cpp | 2 - src/modules/filesystem/physfs/Filesystem.h | 3 - src/modules/window/Window.cpp | 6 +- src/modules/window/Window.h | 46 ++--- src/modules/window/sdl/Window.cpp | 182 +++++++++++++++++- src/modules/window/sdl/Window.h | 33 +++- test/CMakeLists.txt | 4 +- test/ScriptTest.h | 4 +- test/filesystem.cpp | 6 + test/filesystem.nut | 16 ++ test/simplesquirrel.cpp | 68 ++++++- test/simplesquirrel.nut | 31 +++ test/template.cpp.in | 5 +- test/window.cpp | 6 + test/window.nut | 4 + 23 files changed, 446 insertions(+), 45 deletions(-) rename src/modules/{filesystem/cppfs/FileSystem.cpp => entity/Entity.h} (100%) create mode 100644 src/modules/entity/EntityModule.h delete mode 100644 src/modules/filesystem/cppfs/FileSystem.h create mode 100644 test/filesystem.cpp create mode 100644 test/filesystem.nut create mode 100644 test/window.cpp create mode 100644 test/window.nut diff --git a/.gitignore b/.gitignore index 844cdaf8..2c3adc4c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ third-party/ third-party-binary/ .vscode/ +.history/ \ No newline at end of file diff --git a/src/engine/common/Module.h b/src/engine/common/Module.h index f08e6940..a10d90a3 100644 --- a/src/engine/common/Module.h +++ b/src/engine/common/Module.h @@ -13,6 +13,14 @@ class Class; static void expose(ssq::Table& table); \ static void expose(ssq::Class& vm); +#define Module_REG \ + SSQ_REG \ + static const char* name; \ + virtual std::string getName() const { return name; } \ + +#define Module_IMPL(ModuleName) \ + const char* ModuleName::name = #ModuleName; + namespace eve { class Module { @@ -21,7 +29,7 @@ public: virtual std::string getName() const = 0; template - T* getInstance() { + static T* getInstance() { return static_cast(registered_modules[T::name]); } diff --git a/src/modules/filesystem/cppfs/FileSystem.cpp b/src/modules/entity/Entity.h similarity index 100% rename from src/modules/filesystem/cppfs/FileSystem.cpp rename to src/modules/entity/Entity.h diff --git a/src/modules/entity/EntityModule.h b/src/modules/entity/EntityModule.h new file mode 100644 index 00000000..84e29f57 --- /dev/null +++ b/src/modules/entity/EntityModule.h @@ -0,0 +1,20 @@ +#pragma once + +namespace eve { + +namespace entity +{ + + +class EntityModule : public Module { +public: + + + + +}; + + +} // namespace entity + +} \ No newline at end of file diff --git a/src/modules/filesystem/Filesystem.cpp b/src/modules/filesystem/Filesystem.cpp index f853855f..a1ccd83f 100644 --- a/src/modules/filesystem/Filesystem.cpp +++ b/src/modules/filesystem/Filesystem.cpp @@ -1,10 +1,13 @@ -#include "Filesystem.h" +#include "filesystem/Filesystem.h" #include #include -#include +#include +#include + +#include "filesystem/physfs/Filesystem.h" #if defined(EVENGINE_MACOSX) #include "macosx/macosx.h" @@ -12,6 +15,7 @@ #include "ios/ios.h" #elif defined(EVENGINE_WINDOWS) #include + #include "common/utf8.h" #elif defined(EVENGINE_LINUX) #include @@ -20,6 +24,31 @@ namespace eve { namespace filesystem { +Module_IMPL(Filesystem) + +Filesystem *Filesystem::create() { + auto p = registered_modules.find(name); + if (p != registered_modules.end()) return (Filesystem *)(p->second); + auto n = new physfs::Filesystem(); + registered_modules[name] = n; + return n; +} + +void Filesystem::expose(ssq::Table &table) { + auto cls = table.addClass(name, Filesystem::create); + expose(cls); +} + +void Filesystem::expose(ssq::Class &cls) { + cls.addFunc("getName", &Filesystem::getName); + cls.addFunc("init", &Filesystem::init); + cls.addFunc("setFused", &Filesystem::setFused); + cls.addFunc("isFused", &Filesystem::isFused); + cls.addFunc("setupWriteDirectory", &Filesystem::setupWriteDirectory); + cls.addFunc("setAndroidSaveExternal", &Filesystem::setAndroidSaveExternal); + cls.addFunc("isAndroidSaveExternal", &Filesystem::isAndroidSaveExternal); +} + FileData *Filesystem::newFileData(const void *data, std::string filename, size_t size) const { FileData *fd = new FileData(std::string(filename), size); memcpy(fd->getData(), data, size); @@ -61,5 +90,6 @@ std::string Filesystem::getExecutablePath() const { #endif } + } // namespace filesystem } // namespace eve diff --git a/src/modules/filesystem/Filesystem.h b/src/modules/filesystem/Filesystem.h index 200924cc..7c6b9702 100644 --- a/src/modules/filesystem/Filesystem.h +++ b/src/modules/filesystem/Filesystem.h @@ -31,6 +31,8 @@ namespace filesystem { class Filesystem : public Module { public: + Module_REG + struct Info { // Numbers will be -1 if they cannot be determined. int64_t size; @@ -41,7 +43,7 @@ public: Filesystem() {} virtual ~Filesystem() {} - virtual std::string getName() const { return "filesystem"; } + static Filesystem* create(); virtual void init(std::string arg0) = 0; diff --git a/src/modules/filesystem/cppfs/FileSystem.h b/src/modules/filesystem/cppfs/FileSystem.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/modules/filesystem/physfs/File.cpp b/src/modules/filesystem/physfs/File.cpp index 7d02453d..a5768e77 100644 --- a/src/modules/filesystem/physfs/File.cpp +++ b/src/modules/filesystem/physfs/File.cpp @@ -10,7 +10,11 @@ namespace eve { namespace filesystem { -extern bool hack_setupWriteDirectory(); +static bool hack_setupWriteDirectory() { + if (Module::getInstance() != 0) + return Module::getInstance()->setupWriteDirectory(); + return false; +} namespace physfs { diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index ede3a219..a8fd509f 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -98,8 +98,6 @@ Filesystem::~Filesystem() { if (PHYSFS_isInit()) PHYSFS_deinit(); } -std::string Filesystem::getName() const { return "filesystem"; } - void Filesystem::init(std::string arg0) { if (!PHYSFS_init(arg0.c_str())) throw Exception("Failed to initialize filesystem: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); diff --git a/src/modules/filesystem/physfs/Filesystem.h b/src/modules/filesystem/physfs/Filesystem.h index 7c408a0e..5808d452 100644 --- a/src/modules/filesystem/physfs/Filesystem.h +++ b/src/modules/filesystem/physfs/Filesystem.h @@ -15,9 +15,6 @@ public: Filesystem(); virtual ~Filesystem(); - // Implements Module. - std::string getName() const override; - void init(std::string arg0) override; void setFused(bool fused) override; diff --git a/src/modules/window/Window.cpp b/src/modules/window/Window.cpp index 1233b6a9..97a6f2a8 100644 --- a/src/modules/window/Window.cpp +++ b/src/modules/window/Window.cpp @@ -8,7 +8,7 @@ namespace eve { namespace window { -const char* Window::name = "Window"; +Module_IMPL(Window) Window* Window::create() { auto p = registered_modules.find(name); @@ -23,7 +23,9 @@ void Window::expose(ssq::Table& table) { expose(cls); } -void Window::expose(ssq::Class& cls) { cls.addFunc("getName", &Window::getName); } +void Window::expose(ssq::Class& cls) { + cls.addFunc("getName", &Window::getName); +} } // namespace window } // namespace eve \ No newline at end of file diff --git a/src/modules/window/Window.h b/src/modules/window/Window.h index e860d07c..e7485de5 100644 --- a/src/modules/window/Window.h +++ b/src/modules/window/Window.h @@ -15,24 +15,24 @@ class Graphics; namespace window { struct WindowSettings { - std::string fullscreen_type = "desktop"; - double refreshrate = 0.0; - int x = 0; - int y = 0; - int vsync = 1; - int msaa = 0; - int depth = 0; - int minwidth = 1; - int minheight = 1; - int display = 0; - bool borderless = false; - bool centered = true; - bool high_dpi = false; - bool use_dpi_scale = true; - bool use_position = false; - bool fullscreen = false; - bool stencil = true; - bool resizable = false; + double refreshrate = 0.0; + int x = 0; + int y = 0; + int vsync = 1; + int msaa = 0; + int depth = 0; + int minwidth = 1; + int minheight = 1; + int display = 0; + bool borderless = false; + bool centered = true; + bool high_dpi = false; + bool use_dpi_scale = true; + bool use_position = false; + bool fullscreen = false; + bool desktop_mode = true; + bool stencil = true; + bool resizable = false; }; class Window : public Module { @@ -69,13 +69,13 @@ public: virtual void setGraphics(graphics::Graphics* graphics) = 0; - // virtual bool setWindowSettings(int width = 800, int height = 600, const WindowSettings *settings = nullptr) = 0; - // virtual void getWindowSettings(int &width, int &height, WindowSettings &settings) = 0; + virtual bool setWindowSettings(int width = 800, int height = 600, const WindowSettings* settings = nullptr) = 0; + virtual void getWindowSettings(int& width, int& height, WindowSettings& settings) = 0; - // virtual void close() = 0; + virtual void close() = 0; - // virtual bool setFullscreen(bool fullscreen, FullscreenType fstype) = 0; - // virtual bool setFullscreen(bool fullscreen) = 0; + virtual bool setFullscreen(bool fullscreen, bool desktop_mode) = 0; + virtual bool setFullscreen(bool fullscreen) = 0; // virtual bool onSizeChanged(int width, int height) = 0; diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 2dba07c2..9d5f9524 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -37,7 +37,187 @@ Window::Window() { Window::~Window() { SDL_QuitSubSystem(SDL_INIT_VIDEO); } -void Window::setGraphics(graphics::Graphics* graphics) { this->graphics = graphics; } +void Window::setGraphics(graphics::Graphics *graphics) { this->graphics = graphics; } + +bool Window::setWindowSettings(int width, int height, const WindowSettings *settings) { + WindowSettings f; + + if (settings) f = *settings; + f.minwidth = std::max(f.minwidth, 1); + f.minheight = std::max(f.minheight, 1); + + // f.display = std::min(std::max(f.display, 0), getDisplayCount() - 1); + if (width == 0 || height == 0) { + SDL_DisplayMode mode = {}; + SDL_GetDesktopDisplayMode(f.display, &mode); + width = mode.w; + height = mode.h; + } + + Uint32 sdlflags = SDL_WINDOW_VULKAN; + + // On Android, disable fullscreen first on window creation so it's + // possible to change the orientation by specifying portait width and + // height, otherwise SDL will pick the current orientation dimensions when + // fullscreen flag is set. Don't worry, we'll set it back later when user + // also requested fullscreen after the window is created. + // See https://github.com/love2d/love-android/issues/196 +#ifdef EVENGINE_ANDROID + bool fullscreen = f.fullscreen; + + f.fullscreen = false; + f.fstype = FULLSCREEN_DESKTOP; +#endif + + if (f.fullscreen) { + if (f.desktop_mode) + sdlflags |= SDL_WINDOW_FULLSCREEN_DESKTOP; + else { + sdlflags |= SDL_WINDOW_FULLSCREEN; + SDL_DisplayMode mode = {0, width, height, 0, nullptr}; + + // Fullscreen window creation will bug out if no mode can be used. + if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == nullptr) { + // GetClosestDisplayMode will fail if we request a size larger + // than the largest available display mode, so we'll try to use + // the largest (first) mode in that case. + if (SDL_GetDisplayMode(f.display, 0, &mode) < 0) return false; + } + + width = mode.w; + height = mode.h; + } + } + + if (f.resizable) sdlflags |= SDL_WINDOW_RESIZABLE; + + if (f.borderless) sdlflags |= SDL_WINDOW_BORDERLESS; + + if (f.high_dpi) sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI; + + int x = f.x; + int y = f.y; + + if (f.use_position) { + // The position needs to be in the global coordinate space. + SDL_Rect displaybounds = {}; + SDL_GetDisplayBounds(f.display, &displaybounds); + x += displaybounds.x; + y += displaybounds.y; + } else { + if (f.centered) + x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.display); + else + x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.display); + } + + close(); + + if (!createWindowAndContext(x, y, width, height, sdlflags, f.msaa, f.stencil, f.depth)) return false; + + // Make sure the window keeps any previously set icon. + // setIcon(icon.get()); + + // Make sure the mouse keeps its previous grab setting. + // setMouseGrab(mouseGrabbed); + + // Enforce minimum window dimensions. + SDL_SetWindowMinimumSize(window, f.minwidth, f.minheight); + + if (f.use_position || f.centered) SDL_SetWindowPosition(window, x, y); + + SDL_RaiseWindow(window); + + // setVSync(f.vsync); + + updateSettings(f, false); + + if (graphics) { + double scaledw, scaledh; + // fromPixels((double) pixelWidth, (double) pixelHeight, scaledw, scaledh); + // graphics->setMode((int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil); + } +} + +void Window::getWindowSettings(int &width, int &height, WindowSettings &settings) { + width = this->width; + height = this->height; + settings = this->settings; +} + +bool Window::setFullscreen(bool fullscreen, bool desktop_mode) { + if (!window) return false; + + // if (graphics && graphics->isCanvasActive()) + // throw Exception("love.window.setFullscreen cannot be called while a Canvas is active in love.graphics."); + + WindowSettings newsettings = settings; + newsettings.fullscreen = fullscreen; + newsettings.desktop_mode = desktop_mode; + + Uint32 sdlflags = 0; + + if (fullscreen) { + if (desktop_mode) + sdlflags = SDL_WINDOW_FULLSCREEN_DESKTOP; + else { + sdlflags = SDL_WINDOW_FULLSCREEN; + + SDL_DisplayMode mode = {}; + mode.w = windowWidth; + mode.h = windowHeight; + + SDL_GetClosestDisplayMode(SDL_GetWindowDisplayIndex(window), &mode, &mode); + SDL_SetWindowDisplayMode(window, &mode); + } + } + +#ifdef EVENGINE_ANDROID + android::setImmersive(fullscreen); +#endif + + if (SDL_SetWindowFullscreen(window, sdlflags) == 0) { + // SDL_GL_MakeCurrent(window, context); + updateSettings(newsettings, true); + + // Apparently this gets un-set when we exit fullscreen (at least in OS X). + if (!fullscreen) SDL_SetWindowMinimumSize(window, settings.minwidth, settings.minheight); + + return true; + } + + return false; +} + +bool Window::setFullscreen(bool fullscreen) { return setFullscreen(fullscreen, settings.desktop_mode); } + +bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa, bool stencil, int depth) { + return true; +} + +void Window::close() { close(true); } + +void Window::close(bool allowExceptions) { + if (graphics) { + // if (allowExceptions && graphics->isCanvasActive()) + // throw Exception("close cannot be called while a Canvas is active in love.graphics."); + + // graphics->unSetMode(); + } + + if (window) { + SDL_DestroyWindow(window); + window = nullptr; + + // The old window may have generated pending events which are no longer + // relevant. Destroy them all! + SDL_FlushEvent(SDL_WINDOWEVENT); + } + + open = false; +} + +void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport) {} } // namespace sdl } // namespace window diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index c1f8dc93..e52880be 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -15,10 +15,39 @@ public: Window(); ~Window(); - void setGraphics(graphics::Graphics* graphics) override; + void setGraphics(graphics::Graphics *graphics) override; + + bool setWindowSettings(int width = 800, int height = 600, const WindowSettings *settings = nullptr) override; + void getWindowSettings(int &width, int &height, WindowSettings &settings) override; + + void close() override; + + bool setFullscreen(bool fullscreen, bool desktop_mode) override; + bool setFullscreen(bool fullscreen) override; private: - graphics::Graphics* graphics; + graphics::Graphics *graphics = nullptr; + + int width, height; + + WindowSettings settings; + + std::string title; + + int windowWidth = 800; + int windowHeight = 600; + int pixelWidth = 800; + int pixelHeight = 600; + + bool open; + bool mouseGrabbed; + bool displayedWindowError; + + SDL_Window *window; + + bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa, bool stencil, int depth); + void updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport); + void close(bool allowExceptions); }; // Window diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7faf283e..a7188c70 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,8 +16,8 @@ add_executable( ) -set(ThirdParty ${ThirdParty} simplesquirrel_static sqstdlib_static squirrel_static libSDL2.a dl X11 pthread) -set(EVELIBS EVCmdLine EVScripts EVWindow EVDevTools EVCommon) +set(ThirdParty ${ThirdParty} simplesquirrel_static sqstdlib_static squirrel_static physfs libSDL2.a dl X11 pthread) +set(EVELIBS EVCmdLine EVScripts EVWindow EVFileSystem EVDevTools EVCommon) target_link_libraries(unit_test gtest_main gtest ${EVELIBS} ${ThirdParty} diff --git a/test/ScriptTest.h b/test/ScriptTest.h index 5c347698..fcabc11c 100644 --- a/test/ScriptTest.h +++ b/test/ScriptTest.h @@ -1,8 +1,9 @@ #include #include +#include #include "window/Window.h" -#include +#include "filesystem/Filesystem.h" #define UnitSciptTest(name, content) \ class name : public ScriptTest { \ @@ -28,6 +29,7 @@ protected: static void expose(ssq::VM& vm) { auto table = vm.addTable("eve"); window::Window::expose(table); + filesystem::Filesystem::expose(table); } const char* script; diff --git a/test/filesystem.cpp b/test/filesystem.cpp new file mode 100644 index 00000000..ea400329 --- /dev/null +++ b/test/filesystem.cpp @@ -0,0 +1,6 @@ +#include "ScriptTest.h" + +extern const char* filesystem_content; +UnitSciptTest(FilesystemTest, filesystem_content); + +TEST_F(FilesystemTest, basic) { EXPECT_TRUE(vm.callFunc(vm.findFunc("basic"), vm).toBool()); } \ No newline at end of file diff --git a/test/filesystem.nut b/test/filesystem.nut new file mode 100644 index 00000000..6afbaf94 --- /dev/null +++ b/test/filesystem.nut @@ -0,0 +1,16 @@ + + +function basic() { + if (eve.Filesystem == null) { + print("can not find filesystem"); + return false; + } + + local p = eve.Filesystem(); + if (p.getName() != "Filesystem") { + print("filesystem name is not right: "); + print(p.getName()); + return false; + } + return true; +} \ No newline at end of file diff --git a/test/simplesquirrel.cpp b/test/simplesquirrel.cpp index 5ad84353..adfe734d 100644 --- a/test/simplesquirrel.cpp +++ b/test/simplesquirrel.cpp @@ -1,6 +1,10 @@ #include #include "ScriptTest.h" +#include "sqpcheader.h" +#include "sqvm.h" +#include "sqtable.h" +#include "sqclass.h" extern const char* simplesquirrel_content; UnitSciptTest(SimpleSquirrelTest, simplesquirrel_content); @@ -65,4 +69,66 @@ TEST_F(SimpleSquirrelTest, RefTest) { A::expose(vm); B::expose(vm); EXPECT_TRUE(vm.callFunc(vm.findFunc("refTest"), vm).toBool()); -} \ No newline at end of file +} + +TEST_F(SimpleSquirrelTest, TestDefClass) { + auto root = vm.getRaw(); + EXPECT_EQ(sq_type(root), OT_TABLE); + auto rt = _table(root); + for (SQInteger i = 0; i < rt->_numofnodes; i++) { + if (sq_type(rt->_nodes[i].key) != OT_NULL) { + auto p = rt->_nodes[i].val; + if (sq_type(p) == OT_CLASS) { + printf("%s ", _string(rt->_nodes[i].key)->_val); + } + } + } + printf("\n"); + + ssq::Class cls = vm.findClass("Test1"); + auto o = cls.getRaw(); + EXPECT_EQ(o._type, OT_CLASS); + auto pclass = o._unVal.pClass; + + auto t = pclass->_members; + for (SQInteger i = 0; i < t->_numofnodes; i++) { + if (sq_type(t->_nodes[i].key) != OT_NULL) { + printf("%s ", _string(t->_nodes[i].key)->_val); + auto p = t->_nodes[i].val; + if (sq_type(p) == OT_INTEGER) { + if(_isfield(p)) { printf("field %d\n", _member_idx(p));} + if(_ismethod(p)) {printf("method %d\n", _member_idx(p));} + } + } + } + + ssq::Object obj = cls.find("attr1"); + ssq::Class attr = obj.toClass(); + + EXPECT_TRUE(vm.callFunc(vm.findFunc("testDefClass"), vm).toBool()); +} + + +TEST_F(SimpleSquirrelTest, PerformInteration) { + ssq::Class cls = vm.findClass("Test1"); + auto& v = vm.getHandle(); + sq_pushobject(v, cls.getRaw()); + sq_pushnull(v); //null iterator + while(SQ_SUCCEEDED(sq_next(v,-2))) + { + //here -1 is the value and -2 is the key + const char* name; + sq_getstring(v, -2, &name); + printf("%s\n", name); + sq_pop(v,2); //pops key and val before the nex iteration + } + + sq_pop(v,1); //pops the null iterator +} + + +TEST_F(SimpleSquirrelTest, GetterTest) { + + + EXPECT_TRUE(vm.callFunc(vm.findFunc("getterTest"), vm).toBool()); +} diff --git a/test/simplesquirrel.nut b/test/simplesquirrel.nut index b0faef0c..02828039 100644 --- a/test/simplesquirrel.nut +++ b/test/simplesquirrel.nut @@ -16,4 +16,35 @@ function refTest() { local a = get(); a.print(); return true; +} + +class Attr { + name = null; + type = "int"; +} + +class Test1 { + attr1 = Attr; + attr2 = null; + + constructor(a, b) { + attr1 = a; + attr2 = b; + } + + function test() { + ::print(attr1); + ::print(attr2); + } +} + + +function testDefClass() { + local a = Test1(1, 2); + a.test(); + return true; +} + +function getterTest() { + return true; } \ No newline at end of file diff --git a/test/template.cpp.in b/test/template.cpp.in index c16aef29..0e71d255 100644 --- a/test/template.cpp.in +++ b/test/template.cpp.in @@ -1,4 +1,3 @@ - - const char* simplesquirrel_content = R"(@simplesquirrel_content@)"; - +const char* filesystem_content = R"(@filesystem_content@)"; +const char* window_content = R"(@window_content@)"; diff --git a/test/window.cpp b/test/window.cpp new file mode 100644 index 00000000..8a4f8be6 --- /dev/null +++ b/test/window.cpp @@ -0,0 +1,6 @@ +#include "ScriptTest.h" + +extern const char* window_content; +UnitSciptTest(WindowTest, window_content); + +TEST_F(WindowTest, basicWindow) { EXPECT_TRUE(vm.callFunc(vm.findFunc("basicWindow"), vm).toBool()); } diff --git a/test/window.nut b/test/window.nut new file mode 100644 index 00000000..11269764 --- /dev/null +++ b/test/window.nut @@ -0,0 +1,4 @@ + +function basicWindow() { + return true; +} \ No newline at end of file