Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/tests/test_scripts.h
Show All 13 Lines | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "simulation2/system/ComponentTest.h" | #include "simulation2/system/ComponentTest.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | |||||
class TestComponentScripts : public CxxTest::TestSuite | class TestComponentScripts : public CxxTest::TestSuite | ||||
{ | { | ||||
public: | public: | ||||
void setUp() | void setUp() | ||||
{ | { | ||||
g_VFS = CreateVfs(); | g_VFS = CreateVfs(); | ||||
g_VFS->Mount(L"", DataDir()/"mods"/"mod", VFS_MOUNT_MUST_EXIST); | g_VFS->Mount(L"", DataDir()/"mods"/"mod", VFS_MOUNT_MUST_EXIST); | ||||
g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST, 1); // ignore directory-not-found errors | g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST, 1); // ignore directory-not-found errors | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | void test_scripts() | ||||
paths.push_back(VfsPath(L"simulation/components/tests/setup_test.js")); | paths.push_back(VfsPath(L"simulation/components/tests/setup_test.js")); | ||||
for (const VfsPath& path : paths) | for (const VfsPath& path : paths) | ||||
{ | { | ||||
CSimContext context; | CSimContext context; | ||||
CComponentManager componentManager(context, g_ScriptRuntime, true); | CComponentManager componentManager(context, g_ScriptRuntime, true); | ||||
ScriptTestSetup(componentManager.GetScriptInterface()); | ScriptTestSetup(componentManager.GetScriptInterface()); | ||||
componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadComponentScript> ("LoadComponentScript"); | ScriptWrapper::WrapAndRegister<decltype(&Script_LoadComponentScript), &Script_LoadComponentScript>(componentManager.GetScriptInterface(), "LoadComponentScript"); | ||||
componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadHelperScript> ("LoadHelperScript"); | ScriptWrapper::WrapAndRegister<decltype(&Script_LoadHelperScript), &Script_LoadHelperScript>(componentManager.GetScriptInterface(), "LoadHelperScript"); | ||||
componentManager.LoadComponentTypes(); | componentManager.LoadComponentTypes(); | ||||
load_script(componentManager.GetScriptInterface(), L"simulation/components/tests/setup.js"); | load_script(componentManager.GetScriptInterface(), L"simulation/components/tests/setup.js"); | ||||
load_script(componentManager.GetScriptInterface(), path); | load_script(componentManager.GetScriptInterface(), path); | ||||
} | } | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator