Changeset View
Changeset View
Standalone View
Standalone View
source/gui/tests/test_GuiManager.h
Show All 19 Lines | |||||
#include "gui/GUIManager.h" | #include "gui/GUIManager.h" | ||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/GameSetup/GameSetup.h" | #include "ps/GameSetup/GameSetup.h" | ||||
#include "ps/Hotkey.h" | #include "ps/Hotkey.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "scriptinterface/StructuredClone.h" | |||||
#include <memory> | #include <memory> | ||||
class TestGuiManager : public CxxTest::TestSuite | class TestGuiManager : public CxxTest::TestSuite | ||||
{ | { | ||||
std::unique_ptr<CConfigDB> configDB; | std::unique_ptr<CConfigDB> configDB; | ||||
public: | public: | ||||
Show All 22 Lines | public: | ||||
void test_EventObject() | void test_EventObject() | ||||
{ | { | ||||
// Load up a test page. | // Load up a test page. | ||||
const ScriptInterface& scriptInterface = *(g_GUI->GetScriptInterface()); | const ScriptInterface& scriptInterface = *(g_GUI->GetScriptInterface()); | ||||
ScriptRequest rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
JS::RootedValue val(rq.cx); | JS::RootedValue val(rq.cx); | ||||
scriptInterface.CreateObject(rq, &val); | scriptInterface.CreateObject(rq, &val); | ||||
ScriptInterface::StructuredClone data = scriptInterface.WriteStructuredClone(JS::NullHandleValue); | Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue); | ||||
g_GUI->PushPage(L"event/page_event.xml", data, JS::UndefinedHandleValue); | g_GUI->PushPage(L"event/page_event.xml", data, JS::UndefinedHandleValue); | ||||
const ScriptInterface& pageScriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface()); | const ScriptInterface& pageScriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface()); | ||||
ScriptRequest prq(pageScriptInterface); | ScriptRequest prq(pageScriptInterface); | ||||
JS::RootedValue global(prq.cx, prq.globalValue()); | JS::RootedValue global(prq.cx, prq.globalValue()); | ||||
int called_value = 0; | int called_value = 0; | ||||
JS::RootedValue js_called_value(prq.cx); | JS::RootedValue js_called_value(prq.cx); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | void test_hotkeysState() | ||||
LoadHotkeys(*configDB); | LoadHotkeys(*configDB); | ||||
// Load up a test page. | // Load up a test page. | ||||
const ScriptInterface& scriptInterface = *(g_GUI->GetScriptInterface()); | const ScriptInterface& scriptInterface = *(g_GUI->GetScriptInterface()); | ||||
ScriptRequest rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
JS::RootedValue val(rq.cx); | JS::RootedValue val(rq.cx); | ||||
scriptInterface.CreateObject(rq, &val); | scriptInterface.CreateObject(rq, &val); | ||||
ScriptInterface::StructuredClone data = scriptInterface.WriteStructuredClone(JS::NullHandleValue); | Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue); | ||||
g_GUI->PushPage(L"hotkey/page_hotkey.xml", data, JS::UndefinedHandleValue); | g_GUI->PushPage(L"hotkey/page_hotkey.xml", data, JS::UndefinedHandleValue); | ||||
// Press 'a'. | // Press 'a'. | ||||
SDL_Event_ hotkeyNotification; | SDL_Event_ hotkeyNotification; | ||||
hotkeyNotification.ev.type = SDL_KEYDOWN; | hotkeyNotification.ev.type = SDL_KEYDOWN; | ||||
hotkeyNotification.ev.key.keysym.scancode = SDL_SCANCODE_A; | hotkeyNotification.ev.key.keysym.scancode = SDL_SCANCODE_A; | ||||
hotkeyNotification.ev.key.repeat = 0; | hotkeyNotification.ev.key.repeat = 0; | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator