wsd: test: use STATE_ENUM in tests

Change-Id: Ie37bfdb7aba986dc17c1ebaac80d9b1b662a5df6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
pull/8441/head
Ashod Nakashian 2024-03-03 09:07:36 -05:00 committed by Andras Timar
parent 6725005db9
commit 1896baa539
4 changed files with 13 additions and 26 deletions

View File

@ -42,14 +42,7 @@ class UnitWOPIFileUrl : public WopiTestServer
/// then save. Validations are done during
/// GetFile and PutFile to check that FileUrl
/// is used, or not, as expected.
enum class Phase
{
Load,
WaitLoadStatus,
WaitModifiedStatus,
WaitPutFile,
Polling
} _phase;
STATE_ENUM(Phase, Load, WaitLoadStatus, WaitModifiedStatus, WaitPutFile, Polling) _phase;
/// We have three tests, one for each
/// of the following cases of FileUrl:
@ -180,18 +173,18 @@ public:
{
LOG_TST("Valid FileUrl test successful. Now testing Invalid FileUrl.");
_fileUrlState = FileUrlState::Invalid;
_phase = Phase::Load;
TRANSITION_STATE(_phase, Phase::Load);
}
else if (_fileUrlState == FileUrlState::Invalid)
{
LOG_TST("Invalid FileUrl test successful. Now testing without FileUrl.");
_fileUrlState = FileUrlState::Absent;
_phase = Phase::Load;
TRANSITION_STATE(_phase, Phase::Load);
}
else if (_fileUrlState == FileUrlState::Absent)
{
LOG_TST("Testing of FileUrl completed successfully.");
_phase = Phase::Polling;
TRANSITION_STATE(_phase, Phase::Polling);
exitTest(TestResult::Ok);
}
@ -209,7 +202,7 @@ public:
LOG_TST(
"onDocumentLoaded: Modifying the document and switching to Phase::WaitModifiedStatus");
_phase = Phase::WaitModifiedStatus;
TRANSITION_STATE(_phase, Phase::WaitModifiedStatus);
WSD_CMD("key type=input char=97 key=0");
WSD_CMD("key type=up char=0 key=512");
@ -224,7 +217,7 @@ public:
_phase == Phase::WaitModifiedStatus);
LOG_TST("onDocumentModified: Saving document and switching to Phase::WaitPutFile");
_phase = Phase::WaitPutFile;
TRANSITION_STATE(_phase, Phase::WaitPutFile);
WSD_CMD("save dontTerminateEdit=0 dontSaveIfUnmodified=0 "
"extendedData=CustomFlag%3DCustom%20Value%3BAnotherFlag%3DAnotherValue");
@ -239,7 +232,7 @@ public:
case Phase::Load:
{
LOG_TST("Phase::Load");
_phase = Phase::WaitLoadStatus;
TRANSITION_STATE(_phase, Phase::WaitLoadStatus);
initWebsocket("/wopi/files/" + std::to_string(_docId) + "?access_token=anything");

View File

@ -57,7 +57,7 @@ public:
assertCheckFileInfoRequest(request);
LOK_ASSERT_MESSAGE("Expected to be in Phase::Load", _phase == Phase::Load);
_phase = Phase::Redirected;
TRANSITION_STATE(_phase, Phase::Redirected);
http::Response httpResponse(http::StatusCode::Found);
httpResponse.set("Location", helpers::getTestServerURI() + redirectUri + '?' + params);

View File

@ -22,13 +22,7 @@
class UnitWOPITemplate : public WopiTestServer
{
enum class Phase
{
LoadTemplate,
SaveDoc,
CloseDoc,
Polling
} _phase;
STATE_ENUM(Phase, LoadTemplate, SaveDoc, CloseDoc, Polling) _phase;
bool _savedTemplate;
@ -99,7 +93,7 @@ public:
LOK_ASSERT_EQUAL(static_cast<int>(Phase::SaveDoc), static_cast<int>(_phase));
_savedTemplate = true;
LOG_TST("SaveDoc => CloseDoc");
_phase = Phase::CloseDoc;
TRANSITION_STATE(_phase, Phase::CloseDoc);
}
else
{
@ -133,7 +127,7 @@ public:
case Phase::LoadTemplate:
{
LOG_TST("LoadTemplate => SaveDoc");
_phase = Phase::SaveDoc;
TRANSITION_STATE(_phase, Phase::SaveDoc);
initWebsocket("/wopi/files/10?access_token=anything");
WSD_CMD("load url=" + getWopiSrc());
@ -143,7 +137,7 @@ public:
case Phase::CloseDoc:
{
LOG_TST("CloseDoc => Polling");
_phase = Phase::Polling;
TRANSITION_STATE(_phase, Phase::Polling);
WSD_CMD("closedocument");
break;
}

View File

@ -4283,7 +4283,7 @@ int COOLWSD::innerMain()
// It is not at all obvious that this is the ideal place to do the HULLO thing and call onopen
// on TheFakeWebSocket. But it seems to work.
handle_cool_message("HULLO");
MAIN_THREAD_EM_ASM(window.TheFakeWebSocket.onopen(););
MAIN_THREAD_EM_ASM(window.TheFakeWebSocket.onopen());
#endif
/// The main-poll does next to nothing: