[Libreoffice-commits] online.git: 2 commits - loolwsd/Storage.cpp loolwsd/test

Pranav Kant pranavk at collabora.co.uk
Sun Nov 20 17:18:52 UTC 2016


 loolwsd/Storage.cpp           |    4 --
 loolwsd/test/UnitRequests.cpp |   76 ++++++++++++++++++++++--------------------
 2 files changed, 41 insertions(+), 39 deletions(-)

New commits:
commit 4f5813b88ef8392ce71ae35ba52621edf1b82b40
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Nov 20 21:21:50 2016 +0530

    Refactor this unit test, indentation + fix some silliness
    
    Change-Id: I382a187fa863ecb8d8ed81ed5b21acb08b14b9b1

diff --git a/loolwsd/test/UnitRequests.cpp b/loolwsd/test/UnitRequests.cpp
index 8cc9eb5..2bb7b6f 100644
--- a/loolwsd/test/UnitRequests.cpp
+++ b/loolwsd/test/UnitRequests.cpp
@@ -25,15 +25,16 @@ using namespace helpers;
 class UnitRequests : public UnitWSD
 {
     enum {
-	PHASE_LOAD,
-	PHASE_FILTER
+        PHASE_LOAD,
+        PHASE_FILTER,
+        PHASE_FILTERED
     } _phase;
 
     TestResult _testResult;
     std::unique_ptr<UnitWebSocket> _ws;
 public:
     UnitRequests() :
-	_phase(PHASE_LOAD)
+        _phase(PHASE_LOAD)
     {
         std::cerr << "UnitRequests startup\n";
     }
@@ -43,49 +44,52 @@ public:
 	    Poco::Net::HTTPServerRequest& request,
 	    Poco::Net::HTTPServerResponse& /*response*/) override
     {
-	if (type == UnitWSD::TestRequest::TEST_REQ_CLIENT)
-	{
-	    std::string uri = request.getURI();
-	    // Get the embedded document URL: '/lool/docUrl/ws/'
-	    uri = uri.substr(uri.find("lool/") + std::string("lool/").size());
-	    uri = uri.substr(0, uri.find("/ws"));
+        if (_phase == PHASE_FILTER && type == UnitWSD::TestRequest::TEST_REQ_CLIENT)
+        {
+            std::string uri = request.getURI();
+            // Get the embedded document URL: '/lool/docUrl/ws/'
+            uri = uri.substr(uri.find("lool/") + std::string("lool/").size());
+            uri = uri.substr(0, uri.find("/ws"));
+            Poco::URI requestUri(uri);
+            _testResult = TestResult::TEST_OK;
+            // If this is a simple encoded string, it would be treated as
+            // relative, otherwise non-relative.
+            // We require this embedded url to be encoded as otherwise it would
+            // be treated as a resource on the server due to the presence of
+            // un-encoded '/'
+            if (!requestUri.isRelative())
+            {
+                _testResult = TestResult::TEST_FAILED;
+            }
 
-	    Poco::URI requestUri(uri);
-	    _testResult = TestResult::TEST_OK;
-	    // If this is a simple encoded string, it would be treated as
-	    // relative, otherwise non-relative.
-	    // We require this embedded url to be encoded as otherwise it would
-	    // be treated as a resource on the server due to the presence of
-	    // un-encoded '/'
-	    if (!requestUri.isRelative())
-	    {
-		_testResult = TestResult::TEST_FAILED;
-	    }
-	}
+            _phase = PHASE_FILTERED;
+        }
         return false;
     }
 
     void loadDocument()
     {
-	std::string docPath;
-	std::string docURL;
-	getDocumentPathAndURL("empty.odt", docPath, docURL);
-	_ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(docURL));
-	assert(_ws.get());
+        std::string docPath;
+        std::string docURL;
+        getDocumentPathAndURL("empty.odt", docPath, docURL);
+        _ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(docURL));
+        assert(_ws.get());
     }
 
     virtual void invokeTest() override
     {
-	switch(_phase)
-	{
-	case PHASE_LOAD:
-	    _phase = PHASE_FILTER;
-	    loadDocument();
-	    break;
-	case PHASE_FILTER:
-	    exitTest(_testResult);
-	    break;
-	}
+        switch(_phase)
+        {
+            case PHASE_LOAD:
+                _phase = PHASE_FILTER;
+                loadDocument();
+                break;
+            case PHASE_FILTER:
+                break;
+            case PHASE_FILTERED:
+                exitTest(_testResult);
+                break;
+        }
     }
 };
 
commit 93a5c95285fb11b1510a86d9f2757833209e43b9
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Nov 20 16:37:22 2016 +0530

    loolwsd: Incorrect URL in logs
    
    Change-Id: I45a385d9f2866e6220869674ab131cbe7edc3c4e

diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index bc65efe..51abe69 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -429,8 +429,6 @@ WopiStorage::WOPIFileInfo WopiStorage::getWOPIFileInfo(const Poco::URI& uriPubli
 /// uri format: http://server/<...>/wopi*/files/<id>/content
 std::string WopiStorage::loadStorageFileToLocal()
 {
-    LOG_INF("Downloading URI [" << _uri.toString() << "].");
-
     // WOPI URI to download files ends in '/contents'.
     // Add it here to get the payload instead of file info.
     Poco::URI uriObject(_uri);
@@ -448,7 +446,7 @@ std::string WopiStorage::loadStorageFileToLocal()
     std::istream& rs = psession->receiveResponse(response);
 
     auto logger = Log::trace();
-    logger << "WOPI::GetFile header for URI [" << _uri.toString() << "]:\n";
+    logger << "WOPI::GetFile header for URI [" << uriObject.toString() << "]:\n";
     for (auto& pair : response)
     {
         logger << '\t' + pair.first + ": " + pair.second << " / ";


More information about the Libreoffice-commits mailing list