wsd: test: use LOK_ASSERT_STATE for more informative report

Change-Id: Ibd8589e3d6a2ca226578258c3cc1b9d85cad2d2c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
pull/8441/head
Ashod Nakashian 2024-03-03 09:37:32 -05:00 committed by Andras Timar
parent 1896baa539
commit 25784d8677
6 changed files with 17 additions and 27 deletions

View File

@ -173,8 +173,7 @@ public:
// because only in that case there is no user input.
LOK_ASSERT_MESSAGE("Expected reason to be 'Data-loss detected'",
reason.starts_with("Data-loss detected"));
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitDocClose but was " + toString(_phase),
_phase == Phase::WaitDocClose);
LOK_ASSERT_STATE(_phase, Phase::WaitDocClose);
_unloadingModifiedDocDetected = true;
return failed();

View File

@ -168,8 +168,7 @@ public:
// because only in that case there is no user input.
LOK_ASSERT_MESSAGE("Expected reason to be 'Data-loss detected'",
reason.starts_with("Data-loss detected"));
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitDocClose but was " + toString(_phase),
_phase == Phase::WaitDocClose);
LOK_ASSERT_STATE(_phase, Phase::WaitDocClose);
_unloadingModifiedDocDetected = true;
return failed();
@ -253,8 +252,7 @@ public:
// only have one session.
LOK_ASSERT_MESSAGE("Expected reason to be 'Data-loss detected'",
reason.starts_with("Data-loss detected"));
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitDocClose but was " + toString(_phase),
_phase == Phase::Done);
LOK_ASSERT_STATE(_phase, Phase::Done);
passTest("Data-loss detected as expected");
return failed();

View File

@ -150,8 +150,7 @@ public:
{
LOG_TST("FakeWOPIHost: Handling PutFile: " << uriReq.getPath());
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitPutFile",
_phase == Phase::WaitPutFile);
LOK_ASSERT_STATE(_phase, Phase::WaitPutFile);
LOK_ASSERT_MESSAGE("Always the default URI must be used for PutFile",
regContent.match(uriReq.getPath()));
@ -197,8 +196,7 @@ public:
bool onDocumentLoaded(const std::string& message) override
{
LOG_TST("onDocumentLoaded: [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitLoadStatus",
_phase == Phase::WaitLoadStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
LOG_TST(
"onDocumentLoaded: Modifying the document and switching to Phase::WaitModifiedStatus");
@ -213,8 +211,7 @@ public:
bool onDocumentModified(const std::string& message) override
{
LOG_TST("onDocumentModified: [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitModified",
_phase == Phase::WaitModifiedStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitModifiedStatus);
LOG_TST("onDocumentModified: Saving document and switching to Phase::WaitPutFile");
TRANSITION_STATE(_phase, Phase::WaitPutFile);

View File

@ -56,7 +56,7 @@ public:
assertCheckFileInfoRequest(request);
LOK_ASSERT_MESSAGE("Expected to be in Phase::Load", _phase == Phase::Load);
LOK_ASSERT_STATE(_phase, Phase::Load);
TRANSITION_STATE(_phase, Phase::Redirected);
http::Response httpResponse(http::StatusCode::Found);
@ -99,7 +99,7 @@ public:
assertGetFileRequest(request);
LOK_ASSERT_MESSAGE("Expected to be in Phase::GetFile", _phase == Phase::GetFile);
LOK_ASSERT_STATE(_phase, Phase::GetFile);
TRANSITION_STATE(_phase, Phase::Redirected2);
http::Response httpResponse(http::StatusCode::Found);
@ -115,7 +115,7 @@ public:
assertGetFileRequest(request);
LOK_ASSERT_MESSAGE("Expected to be in Phase::Redirected2", _phase == Phase::Redirected2);
LOK_ASSERT_STATE(_phase, Phase::Redirected2);
TRANSITION_STATE(_phase, Phase::Done);
http::Response httpResponse(http::StatusCode::OK);

View File

@ -63,7 +63,7 @@ public:
assertPutFileRequest(const Poco::Net::HTTPRequest& request) override
{
LOG_TST("PutFile");
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitPutFile", _phase == Phase::WaitPutFile);
LOK_ASSERT_STATE(_phase, Phase::WaitPutFile);
// Triggered while closing.
LOK_ASSERT_EQUAL(std::string("false"), request.get("X-COOL-WOPI-IsAutosave"));
@ -83,8 +83,7 @@ public:
bool onDocumentLoaded(const std::string& message) override
{
LOG_TST("Doc (" << toString(_phase) << "): [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitLoadStatus",
_phase == Phase::WaitLoadStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
// Modify and wait for the notification.
TRANSITION_STATE(_phase, Phase::WaitModifiedStatus);
@ -104,8 +103,7 @@ public:
if (_phase == Phase::WaitModifiedStatus)
{
LOG_TST("Doc (" << toString(_phase) << "): [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitModifiedStatus",
_phase == Phase::WaitModifiedStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitModifiedStatus);
// Save and immediately modify, then close the connection.
WSD_CMD("save dontTerminateEdit=0 dontSaveIfUnmodified=0 "
@ -189,7 +187,7 @@ public:
else
{
LOK_ASSERT_EQUAL(std::string("false"), request.get("X-COOL-WOPI-IsModifiedByUser"));
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitPutFile", _phase == Phase::Done);
LOK_ASSERT_STATE(_phase, Phase::Done);
// LOK_ASSERT_EQUAL_MESSAGE("Expected to be in Phase::WaitPutFile", 2, _uploadCount);
}
@ -200,8 +198,7 @@ public:
bool onDocumentLoaded(const std::string& message) override
{
LOG_TST("Doc (" << toString(_phase) << "): [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitLoadStatus",
_phase == Phase::WaitLoadStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
// Modify and wait for the notification.
TRANSITION_STATE(_phase, Phase::WaitModifiedStatus);
@ -216,8 +213,7 @@ public:
bool onDocumentModified(const std::string& message) override
{
LOG_TST("Doc (" << toString(_phase) << "): [" << message << ']');
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitModifiedStatus",
_phase == Phase::WaitModifiedStatus);
LOK_ASSERT_STATE(_phase, Phase::WaitModifiedStatus);
_stopwatch.restart();

View File

@ -272,8 +272,8 @@ public:
// because only in that case there is no user input.
LOK_ASSERT_MESSAGE("Expected reason to be 'Data-loss detected'",
reason.starts_with("Data-loss detected"));
LOK_ASSERT_MESSAGE("Expected to be in Phase::WaitDocClose but was " + toString(_phase),
_phase == Phase::WaitDocClose);
LOK_ASSERT_STATE(_phase, Phase::WaitDocClose);
// In SaveOverwrite, we should not be in modified state, because we do save
// and upload. But because we don't wait for the modified=false, we can end-up
// here. Since we will verify after reloading that we have no data-loss, it's OK.