[Libreoffice-commits] online.git: common/Unit.cpp common/Unit.hpp kit/ForKit.cpp kit/Kit.cpp test/TileCacheTests.cpp test/UnitAdmin.cpp test/UnitFonts.cpp test/UnitMinSocketBufferSize.cpp test/UnitOOB.cpp test/UnitPrefork.cpp test/UnitStorage.cpp test/UnitTileCache.cpp test/UnitTimeout.cpp wsd/LOOLWSD.cpp wsd/Storage.hpp

Noel Grandin noel.grandin at collabora.co.uk
Thu Dec 22 09:52:14 UTC 2016


 common/Unit.cpp                  |   16 ++++-----
 common/Unit.hpp                  |   24 +++++++-------
 kit/ForKit.cpp                   |    2 -
 kit/Kit.cpp                      |   12 +++----
 test/TileCacheTests.cpp          |    2 -
 test/UnitAdmin.cpp               |   66 +++++++++++++++++++--------------------
 test/UnitFonts.cpp               |    6 +--
 test/UnitMinSocketBufferSize.cpp |   22 ++++++-------
 test/UnitOOB.cpp                 |    4 +-
 test/UnitPrefork.cpp             |    6 +--
 test/UnitStorage.cpp             |   24 +++++++-------
 test/UnitTileCache.cpp           |   20 +++++------
 test/UnitTimeout.cpp             |    4 +-
 wsd/LOOLWSD.cpp                  |   10 ++---
 wsd/Storage.hpp                  |    2 -
 15 files changed, 110 insertions(+), 110 deletions(-)

New commits:
commit 4199efc91cd5c556b3373b2a548517fdc6cacecd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Dec 22 11:27:30 2016 +0200

    convert enums to scoped
    
    Change-Id: Ic3d4c09dbcec28b4638bb8888f812f970f40a1c5
    Reviewed-on: https://gerrit.libreoffice.org/32331
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/common/Unit.cpp b/common/Unit.cpp
index 53e44ca..80ae442 100644
--- a/common/Unit.cpp
+++ b/common/Unit.cpp
@@ -40,10 +40,10 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP
     const char *symbol = NULL;
     switch (type)
     {
-        case TYPE_WSD:
+        case UnitType::Wsd:
             symbol = "unit_create_wsd";
             break;
-        case TYPE_KIT:
+        case UnitType::Kit:
             symbol = "unit_create_kit";
             break;
     }
@@ -84,10 +84,10 @@ bool UnitBase::init(UnitType type, const std::string &unitLibPath)
     {
         switch (type)
         {
-        case TYPE_WSD:
+        case UnitType::Wsd:
             Global = new UnitWSD();
             break;
-        case TYPE_KIT:
+        case UnitType::Kit:
             Global = new UnitKit();
             break;
         default:
@@ -119,7 +119,7 @@ UnitBase::UnitBase()
       _retValue(0),
       _timeoutMilliSeconds(30 * 1000),
       _timeoutShutdown(false),
-      _type(TYPE_WSD)
+      _type(UnitType::Wsd)
 {
 }
 
@@ -177,9 +177,9 @@ UnitKit::~UnitKit()
 
 void UnitBase::exitTest(TestResult result)
 {
-    LOG_INF("exitTest: " << result << ". Flagging for termination.");
+    LOG_INF("exitTest: " << (int)result << ". Flagging for termination.");
     _setRetValue = true;
-    _retValue = result == TestResult::TEST_OK ?
+    _retValue = result == TestResult::Ok ?
         Poco::Util::Application::EXIT_OK :
         Poco::Util::Application::EXIT_SOFTWARE;
     TerminationFlag = true;
@@ -188,7 +188,7 @@ void UnitBase::exitTest(TestResult result)
 void UnitBase::timeout()
 {
     LOG_ERR("Timed out waiting for unit test to complete");
-    exitTest(TestResult::TEST_TIMED_OUT);
+    exitTest(TestResult::TimedOut);
 }
 
 void UnitBase::returnValue(int &retValue)
diff --git a/common/Unit.hpp b/common/Unit.hpp
index 9bcb86b..daa3387 100644
--- a/common/Unit.hpp
+++ b/common/Unit.hpp
@@ -61,11 +61,11 @@ protected:
     /// If the test times out this gets invoked, the default just exits.
     virtual void timeout();
 
-    enum TestResult
+    enum class TestResult
     {
-        TEST_FAILED,
-        TEST_OK,
-        TEST_TIMED_OUT
+        Failed,
+        Ok,
+        TimedOut
     };
 
     /// Encourages the process to exit with this value (unless hooked)
@@ -75,10 +75,10 @@ protected:
     virtual ~UnitBase();
 
 public:
-    enum UnitType
+    enum class UnitType
     {
-        TYPE_WSD,
-        TYPE_KIT
+        Wsd,
+        Kit
     };
     /// Load unit test hook shared library from this path
     static bool init(UnitType type, const std::string& unitLibPath);
@@ -127,14 +127,14 @@ public:
 
     static UnitWSD& get()
     {
-        assert(Global && Global->_type == UnitType::TYPE_WSD);
+        assert(Global && Global->_type == UnitType::Wsd);
         return *static_cast<UnitWSD *>(Global);
     }
 
-    enum TestRequest
+    enum class TestRequest
     {
-        TEST_REQ_CLIENT,
-        TEST_REQ_PRISONER
+        Client,
+        Prisoner
     };
     /// Simulate an incoming request
     void testHandleRequest(TestRequest type,
@@ -218,7 +218,7 @@ public:
     virtual ~UnitKit();
     static UnitKit& get()
     {
-        assert(Global && Global->_type == UnitType::TYPE_KIT);
+        assert(Global && Global->_type == UnitType::Kit);
         return *static_cast<UnitKit *>(Global);
     }
 
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index a40ad8b..7b04e09 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -372,7 +372,7 @@ int main(int argc, char** argv)
         return Application::EXIT_USAGE;
     }
 
-    if (!UnitBase::init(UnitBase::UnitType::TYPE_KIT,
+    if (!UnitBase::init(UnitBase::UnitType::Kit,
                         UnitTestLibrary))
     {
         LOG_ERR("Failed to load kit unit test library");
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 6f40370..fe23e53 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -102,7 +102,7 @@ static std::shared_ptr<Document> document;
 namespace
 {
 #ifndef BUILDING_TESTS
-    typedef enum { COPY_ALL, COPY_LO, COPY_NO_USR } LinkOrCopyType;
+    enum class LinkOrCopyType { All, LO, NoUsr };
     LinkOrCopyType linkOrCopyType;
     std::string sourceForLinkOrCopy;
     Path destinationForLinkOrCopy;
@@ -111,10 +111,10 @@ namespace
     {
         switch (linkOrCopyType)
         {
-        case COPY_NO_USR:
+        case LinkOrCopyType::NoUsr:
             // bind mounted.
             return strcmp(path,"usr") != 0;
-        case COPY_LO:
+        case LinkOrCopyType::LO:
             return
                 strcmp(path, "program/wizards") != 0 &&
                 strcmp(path, "sdk") != 0 &&
@@ -124,7 +124,7 @@ namespace
                 strcmp(path, "share/template") != 0 &&
                 strcmp(path, "share/config/wizard") != 0 &&
                 strcmp(path, "share/config/wizard") != 0;
-        default: // COPY_ALL
+        default: // LinkOrCopyType::All
             return true;
         }
     }
@@ -1534,8 +1534,8 @@ void lokit_main(const std::string& childRoot,
                 LOG_DBG("Initialized jail bind mount.");
             }
             linkOrCopy(sysTemplate, jailPath,
-                       bLoopMounted ? COPY_NO_USR : COPY_ALL);
-            linkOrCopy(loTemplate, jailLOInstallation, COPY_LO);
+                       bLoopMounted ? LinkOrCopyType::NoUsr : LinkOrCopyType::All);
+            linkOrCopy(loTemplate, jailLOInstallation, LinkOrCopyType::LO);
 
             // We need this because sometimes the hostname is not resolved
             const auto networkFiles = {"/etc/host.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/resolv.conf"};
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index edc22d5..7872193 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -136,7 +136,7 @@ public:
 
 void TileCacheTests::testSimple()
 {
-    if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD, ""))
+    if (!UnitWSD::init(UnitWSD::UnitType::Wsd, ""))
     {
         throw std::runtime_error("Failed to load wsd unit test library.");
     }
diff --git a/test/UnitAdmin.cpp b/test/UnitAdmin.cpp
index 96ccee8..799eb12 100644
--- a/test/UnitAdmin.cpp
+++ b/test/UnitAdmin.cpp
@@ -75,11 +75,11 @@ private:
 
         session->sendRequest(request);
         session->receiveResponse(response);
-        TestResult res = TestResult::TEST_FAILED;
+        TestResult res = TestResult::Failed;
         if (response.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED)
-            res = TestResult::TEST_OK;
+            res = TestResult::Ok;
 
-        Log::info(std::string("testIncorrectPassword: ") + (res == TestResult::TEST_OK ? "OK" : "FAIL"));
+        Log::info(std::string("testIncorrectPassword: ") + (res == TestResult::Ok ? "OK" : "FAIL"));
         return res;
     }
 
@@ -106,21 +106,21 @@ private:
         std::string cookiePath = cookies[0].getPath();
         bool secure = cookies[0].getSecure();
         std::string value = cookies[0].getValue();
-        TestResult res = TestResult::TEST_FAILED;
+        TestResult res = TestResult::Failed;
         if (cookiePath.find_first_of("/loleaflet/dist/admin/") == 0 &&
             value != "" &&
             secure)
         {
             // Set JWT cookie to be used for subsequent tests
             _jwtCookie = value;
-            res = TestResult::TEST_OK;
+            res = TestResult::Ok;
         }
         else
         {
             Log::info("testCorrectPassword: Invalid cookie properties");
         }
 
-        Log::info(std::string("testCorrectPassword: ") + (res == TestResult::TEST_OK ? "OK" : "FAIL"));
+        Log::info(std::string("testCorrectPassword: ") + (res == TestResult::Ok ? "OK" : "FAIL"));
         return res;
     }
 
@@ -139,7 +139,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testWebSocketWithoutAuth: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -148,11 +148,11 @@ private:
             tokens[0] != "NotAuthenticated")
         {
             Log::info("testWebSocketWithoutAuth: Unrecognized message format");
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
 
         Log::info(std::string("testWebSocketWithoutAuth: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
     TestResult testWebSocketWithIncorrectAuthToken()
@@ -170,7 +170,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testWebSocketWithIncorrectAuthToken: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -179,11 +179,11 @@ private:
             tokens[0] != "InvalidAuthToken")
         {
             Log::info("testWebSocketWithIncorrectAuthToken: Unrecognized message format");
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
 
         Log::info(std::string("testWebSocketWithIncorrectAuthToken: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
     TestResult testAddDocNotify()
@@ -221,7 +221,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testAddDocNotify: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -232,7 +232,7 @@ private:
                 tokens[2] != documentPath1.substr(documentPath1.find_last_of("/") + 1) )
             {
                 Log::info("testAddDocNotify: Unrecognized message format");
-                return TestResult::TEST_FAILED;
+                return TestResult::Failed;
             }
 
             // store document pid
@@ -249,7 +249,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testAddDocNotify: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -260,7 +260,7 @@ private:
                 tokens[2] != documentPath1.substr(documentPath1.find_last_of("/") + 1) )
             {
                 Log::info("testAddDocNotify: Unrecognized message format");
-                return TestResult::TEST_FAILED;
+                return TestResult::Failed;
             }
 
             // store document pid
@@ -284,7 +284,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testAddDocNotify: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -295,7 +295,7 @@ private:
                 tokens[2] != documentPath2.substr(documentPath2.find_last_of("/") + 1) )
             {
                 Log::info("testAddDocNotify: Unrecognized message format");
-                return TestResult::TEST_FAILED;
+                return TestResult::Failed;
             }
 
             // store document pid
@@ -305,7 +305,7 @@ private:
         _docsCount++;
 
         Log::info(std::string("testAddDocNotify: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
     TestResult testUsersCount()
@@ -318,7 +318,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testUsersCount: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -327,18 +327,18 @@ private:
             tokens[0] != "active_users_count")
         {
             Log::info("testUsersCount: Unrecognized message format");
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
         else if (std::stoi(tokens[1]) != _usersCount)
         {
             Log::info("testUsersCount: Incorrect users count "
                       ", expected: " + std::to_string(_usersCount) +
                       ", actual: " + tokens[1]);
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
 
         Log::info(std::string("testUsersCount: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
     TestResult testDocCount()
@@ -351,7 +351,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testDocCount: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -361,18 +361,18 @@ private:
             std::stoi(tokens[1]) != _docsCount)
         {
             Log::info("testDocCount: Unrecognized message format");
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
         else if (std::stoi(tokens[1]) != _docsCount)
         {
             Log::info("testDocCount: Incorrect doc count "
                       ", expected: " + std::to_string(_docsCount) +
                       ", actual: " + tokens[1]);
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
 
         Log::info(std::string("testDocCount: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
     TestResult testRmDocNotify()
@@ -387,7 +387,7 @@ private:
         if (_messageReceivedCV.wait_for(lock, std::chrono::milliseconds(_messageTimeoutMilliSeconds)) == std::cv_status::timeout)
         {
             Log::info("testRmDocNotify: Timed out waiting for admin console message");
-            return TestResult::TEST_TIMED_OUT;
+            return TestResult::TimedOut;
         }
         lock.unlock();
 
@@ -397,12 +397,12 @@ private:
             stoi(tokens[1]) != _docPid1)
         {
             Log::info("testRmDocNotify: Invalid message format");
-            return TestResult::TEST_FAILED;
+            return TestResult::Failed;
         }
         _usersCount--;
 
         Log::info(std::string("testRmDocNotify: OK"));
-        return TestResult::TEST_OK;
+        return TestResult::Ok;
     }
 
 public:
@@ -438,9 +438,9 @@ public:
             Log::info("UnitAdmin:: Starting test #" + std::to_string(_testCounter));
             TestResult res = ((*this).*(test))();
             Log::info("UnitAdmin:: Finished test #" + std::to_string(_testCounter));
-            if (res != TestResult::TEST_OK)
+            if (res != TestResult::Ok)
             {
-                Log::info("Exiting with " + (res == TestResult::TEST_FAILED ? "FAIL" : (res == TestResult::TEST_TIMED_OUT) ? "TIMEOUT" : "??? (" + std::to_string(res) + ")"));
+                Log::info("Exiting with " + (res == TestResult::Failed ? "FAIL" : (res == TestResult::TimedOut) ? "TIMEOUT" : "??? (" + std::to_string((int)res) + ")"));
                 exitTest(res);
                 assert(false);
                 return;
@@ -450,7 +450,7 @@ public:
             if (_tests.size() == _testCounter)
             {
                 Log::info("Exiting with OK");
-                exitTest(TestResult::TEST_OK);
+                exitTest(TestResult::Ok);
             }
 
             _isTestRunning = false;
diff --git a/test/UnitFonts.cpp b/test/UnitFonts.cpp
index 265d5b2..871c74b 100644
--- a/test/UnitFonts.cpp
+++ b/test/UnitFonts.cpp
@@ -77,7 +77,7 @@ public:
         {
             std::cerr << "Error - font list mismatch" << std::endl;
             std::cerr << "Kit : '" << _fontsKit << "' vs. Broker : '" << _fontsBroker << "'" << std::endl;
-            exitTest(TestResult::TEST_FAILED);
+            exitTest(TestResult::Failed);
         }
         else
         {
@@ -85,7 +85,7 @@ public:
             if (tokens.count() > 0)
                 std::cerr << "  " << tokens[0] << std::endl;
 
-            exitTest(TestResult::TEST_OK);
+            exitTest(TestResult::Ok);
         }
     }
 
@@ -103,7 +103,7 @@ public:
                      Poco::Net::HTTPServerRequest& request,
                      Poco::Net::HTTPServerResponse& response) override
     {
-        if (type == UnitWSD::TestRequest::TEST_REQ_PRISONER &&
+        if (type == UnitWSD::TestRequest::Prisoner &&
             request.getURI().find(UNIT_URI) == 0)
         {
             auto ws = std::make_shared<LOOLWebSocket>(request, response);
diff --git a/test/UnitMinSocketBufferSize.cpp b/test/UnitMinSocketBufferSize.cpp
index 00e1dba..7134a62 100644
--- a/test/UnitMinSocketBufferSize.cpp
+++ b/test/UnitMinSocketBufferSize.cpp
@@ -17,16 +17,16 @@ using namespace helpers;
 
 class UnitMinSocketBufferSize: public UnitWSD
 {
-    enum {
-        PHASE_LOAD,             // load the document
-        PHASE_REQUEST,          // Request tiles etc.
-        PHASE_CHECK_RESPONSE    // Check if we got correct response
+    enum class Phase {
+        Load,             // load the document
+        Request,          // Request tiles etc.
+        CheckResponse     // Check if we got correct response
     } _phase;
     std::string _docURL, _docPath;
     std::unique_ptr<UnitWebSocket> _ws;
 public:
     UnitMinSocketBufferSize() :
-        _phase(PHASE_LOAD)
+        _phase(Phase::Load)
     {
     }
 
@@ -34,17 +34,17 @@ public:
     {
         switch (_phase)
         {
-        case PHASE_LOAD:
+        case Phase::Load:
         {
             getDocumentPathAndURL("Example.odt", _docPath, _docURL);
             _ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(_docURL));
             assert(_ws.get());
 
-            _phase = PHASE_REQUEST;
+            _phase = Phase::Request;
             LOG_DBG("Document loaded successfully.");
             break;
         }
-        case PHASE_REQUEST:
+        case Phase::Request:
         {
             const std::string loadMsg = "load url=" + _docURL;
             const std::string tilecombineMsg = "tilecombine part=0 width=256 height=256 tileposx=0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520 tileposy=0,0,0,0,3840,3840,3840,3840,7680,7680,7680,7680,11520,11520,11520,11520,15360,15360,15360,15360 tilewidth=3840 tileheight=3840";
@@ -52,10 +52,10 @@ public:
             _ws->getLOOLWebSocket()->sendFrame(tilecombineMsg.data(), tilecombineMsg.size());
 
             LOG_DBG("Tilecombine request sent");
-            _phase = PHASE_CHECK_RESPONSE;
+            _phase = Phase::CheckResponse;
             break;
         }
-        case PHASE_CHECK_RESPONSE:
+        case Phase::CheckResponse:
             LOG_DBG("Checking if get back all the tiles");
             int nTiles = 20;
             bool success = true;
@@ -70,7 +70,7 @@ public:
                 }
             }
 
-            exitTest(success ? TestResult::TEST_OK : TestResult::TEST_FAILED);
+            exitTest(success ? TestResult::Ok : TestResult::Failed);
             break;
         }
     }
diff --git a/test/UnitOOB.cpp b/test/UnitOOB.cpp
index f879808..2ee524c 100644
--- a/test/UnitOOB.cpp
+++ b/test/UnitOOB.cpp
@@ -38,8 +38,8 @@ public:
         UnitHTTPServerRequest request(response, "nonsense URI");
 
         // ensure we handle invalid URIs without asserting.
-        testHandleRequest(TestRequest::TEST_REQ_PRISONER, request, response);
-        exitTest(TestResult::TEST_OK);
+        testHandleRequest(TestRequest::Prisoner, request, response);
+        exitTest(TestResult::Ok);
     }
 };
 
diff --git a/test/UnitPrefork.cpp b/test/UnitPrefork.cpp
index 137ac97..6f4427d 100644
--- a/test/UnitPrefork.cpp
+++ b/test/UnitPrefork.cpp
@@ -105,7 +105,7 @@ public:
                 {
                     _failure = "Timed out waiting for child to respond to unit-memdump.";
                     std::cerr << _failure << std::endl;
-                    exitTest(TestResult::TEST_FAILED);
+                    exitTest(TestResult::Failed);
                     return;
                 }
 
@@ -131,12 +131,12 @@ public:
             if (!_failure.empty())
             {
                 std::cerr << "UnitPrefork failed due to: " << _failure << std::endl;
-                exitTest(TestResult::TEST_FAILED);
+                exitTest(TestResult::Failed);
             }
             else
             {
                 std::cerr << "UnitPrefork success." << std::endl;
-                exitTest(TestResult::TEST_OK);
+                exitTest(TestResult::Ok);
             }
         }
     }
diff --git a/test/UnitStorage.cpp b/test/UnitStorage.cpp
index 521786e..be5e8ee 100644
--- a/test/UnitStorage.cpp
+++ b/test/UnitStorage.cpp
@@ -19,15 +19,15 @@ using namespace helpers;
 
 class UnitStorage : public UnitWSD
 {
-    enum {
-        PHASE_LOAD,             // load the document
-        PHASE_FILTER,           // throw filter exception
-        PHASE_RE_LOAD,          // re-load the document
+    enum class Phase {
+        Load,             // load the document
+        Filter,           // throw filter exception
+        Reload,           // re-load the document
     } _phase;
     std::unique_ptr<UnitWebSocket> _ws;
 public:
     UnitStorage() :
-        _phase(PHASE_LOAD)
+        _phase(Phase::Load)
     {
     }
 
@@ -35,9 +35,9 @@ public:
                             const std::string &/* jailId */,
                             bool &/* result */)
     {
-        if (_phase == PHASE_FILTER)
+        if (_phase == Phase::Filter)
         {
-            _phase = PHASE_RE_LOAD;
+            _phase = Phase::Reload;
             LOG_INF("Throwing low disk space exception.");
             throw StorageSpaceLowException("test: low disk space");
         }
@@ -57,16 +57,16 @@ public:
     {
         switch (_phase)
         {
-        case PHASE_LOAD:
-            _phase = PHASE_FILTER;
+        case Phase::Load:
+            _phase = Phase::Filter;
             loadDocument();
             break;
-        case PHASE_FILTER:
+        case Phase::Filter:
             break;
-        case PHASE_RE_LOAD:
+        case Phase::Reload:
             loadDocument();
             _ws.reset();
-            exitTest(TEST_OK);
+            exitTest(TestResult::Ok);
             break;
         }
     }
diff --git a/test/UnitTileCache.cpp b/test/UnitTileCache.cpp
index d6d52b2..262996e 100644
--- a/test/UnitTileCache.cpp
+++ b/test/UnitTileCache.cpp
@@ -20,14 +20,14 @@ using namespace helpers;
 
 class UnitTileCache: public UnitWSD
 {
-    enum {
-        PHASE_LOAD,             // load the document
-        PHASE_TILE,             // lookup tile method
+    enum class Phase {
+        Load,             // load the document
+        Tile,             // lookup tile method
     } _phase;
     std::unique_ptr<UnitWebSocket> _ws;
 public:
     UnitTileCache() :
-        _phase(PHASE_LOAD)
+        _phase(Phase::Load)
     {
     }
 
@@ -41,16 +41,16 @@ public:
         cacheFile.reset();
 
         // FIXME: push through to the right place to exercise this.
-        exitTest(TestResult::TEST_OK);
+        exitTest(TestResult::Ok);
     }
 
     virtual void invokeTest()
     {
         switch (_phase)
         {
-        case PHASE_LOAD:
+        case Phase::Load:
         {
-            _phase = PHASE_TILE;
+            _phase = Phase::Tile;
             std::string docPath;
             std::string docURL;
             getDocumentPathAndURL("empty.odt", docPath, docURL);
@@ -58,10 +58,10 @@ public:
             assert(_ws.get());
 
             // FIXME: need to invoke the tile lookup ...
-            exitTest(TestResult::TEST_OK);
+            exitTest(TestResult::Ok);
             break;
         }
-        case PHASE_TILE:
+        case Phase::Tile:
             break;
         }
     }
@@ -76,7 +76,7 @@ private:
                 }
                 catch (const Poco::Exception& exc)
                 {
-                    exitTest(TestResult::TEST_FAILED);
+                    exitTest(TestResult::Failed);
                 }
             });
     }
diff --git a/test/UnitTimeout.cpp b/test/UnitTimeout.cpp
index ad0df80..4cf3ed9 100644
--- a/test/UnitTimeout.cpp
+++ b/test/UnitTimeout.cpp
@@ -50,11 +50,11 @@ public:
     // sanity check the non-unit-test paths
     static void testDefaultKits()
     {
-        bool madeWSD = init(UnitType::TYPE_WSD, std::string());
+        bool madeWSD = init(UnitType::Wsd, std::string());
         assert(madeWSD);
         delete UnitBase::Global;
         UnitBase::Global = NULL;
-        bool madeKit = init(UnitType::TYPE_KIT, std::string());
+        bool madeKit = init(UnitType::Kit, std::string());
         assert(madeKit);
         delete UnitBase::Global;
         UnitBase::Global = NULL;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ac073f..8dc40eb 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1110,7 +1110,7 @@ public:
     void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override
     {
         if (UnitWSD::get().filterHandleRequest(
-                UnitWSD::TestRequest::TEST_REQ_CLIENT,
+                UnitWSD::TestRequest::Client,
                 request, response))
             return;
 
@@ -1271,7 +1271,7 @@ public:
     void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override
     {
         if (UnitWSD::get().filterHandleRequest(
-                UnitWSD::TestRequest::TEST_REQ_PRISONER,
+                UnitWSD::TestRequest::Prisoner,
                 request, response))
             return;
 
@@ -1552,7 +1552,7 @@ void LOOLWSD::initialize(Application& self)
         throw std::runtime_error("Do not run as root. Please run as lool user.");
     }
 
-    if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD, UnitTestLibrary))
+    if (!UnitWSD::init(UnitWSD::UnitType::Wsd, UnitTestLibrary))
     {
         throw std::runtime_error("Failed to load wsd unit test library.");
     }
@@ -2290,10 +2290,10 @@ void UnitWSD::testHandleRequest(TestRequest type, UnitHTTPServerRequest& request
 {
     switch (type)
     {
-    case TestRequest::TEST_REQ_CLIENT:
+    case TestRequest::Client:
         ClientRequestHandler::handleClientRequest(request, response);
         break;
-    case TestRequest::TEST_REQ_PRISONER:
+    case TestRequest::Prisoner:
         PrisonerRequestHandler::handlePrisonerRequest(request, response);
         break;
     default:
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index d44f2fe..31aa34c 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -52,7 +52,7 @@ public:
         size_t _size;
     };
 
-    enum SaveResult
+    enum class SaveResult
     {
         OK,
         DISKFULL,


More information about the Libreoffice-commits mailing list