2016-04-05 11:41:10 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
2020-04-18 03:39:50 -05:00
|
|
|
|
|
|
|
#pragma once
|
2016-04-05 11:41:10 -05:00
|
|
|
|
2020-12-24 11:15:37 -06:00
|
|
|
#include <test/testlog.hpp>
|
|
|
|
|
2016-04-08 11:36:08 -05:00
|
|
|
#include <atomic>
|
2016-08-30 02:06:39 -05:00
|
|
|
#include <cassert>
|
2020-12-14 13:00:55 -06:00
|
|
|
#include <chrono>
|
2016-10-29 20:15:00 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2016-04-05 11:41:10 -05:00
|
|
|
|
2016-11-10 02:47:25 -06:00
|
|
|
#include <LOOLWebSocket.hpp>
|
2017-10-26 03:38:57 -05:00
|
|
|
#include "net/Socket.hpp"
|
2016-04-18 08:29:17 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
class UnitBase;
|
|
|
|
class UnitWSD;
|
|
|
|
class UnitKit;
|
2016-04-08 11:36:08 -05:00
|
|
|
class UnitTimeout;
|
2016-04-07 15:59:27 -05:00
|
|
|
class UnitHTTPServerRequest;
|
|
|
|
class UnitHTTPServerResponse;
|
|
|
|
|
2017-10-26 03:38:57 -05:00
|
|
|
class WebSocketHandler;
|
|
|
|
|
2016-04-16 13:37:38 -05:00
|
|
|
// Forward declaration to avoid pulling the world here.
|
2016-10-29 20:15:00 -05:00
|
|
|
namespace Poco
|
|
|
|
{
|
2018-02-08 12:51:54 -06:00
|
|
|
class MemoryInputStream;
|
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
namespace Net
|
|
|
|
{
|
2016-04-12 15:30:06 -05:00
|
|
|
class HTTPServerRequest;
|
|
|
|
class HTTPServerResponse;
|
2016-04-16 13:37:38 -05:00
|
|
|
}
|
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
namespace Util
|
|
|
|
{
|
2016-04-16 13:37:38 -05:00
|
|
|
class LayeredConfiguration;
|
|
|
|
}
|
|
|
|
}
|
2016-04-12 15:30:06 -05:00
|
|
|
|
2016-12-12 18:53:58 -06:00
|
|
|
class Session;
|
2016-04-07 15:59:27 -05:00
|
|
|
class StorageBase;
|
2016-04-05 11:41:10 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
typedef UnitBase *(CreateUnitHooksFunction)();
|
|
|
|
extern "C" { UnitBase *unit_create_wsd(void); }
|
|
|
|
extern "C" { UnitBase *unit_create_kit(void); }
|
2016-05-01 03:04:19 -05:00
|
|
|
extern "C" { typedef struct _LibreOfficeKit LibreOfficeKit; }
|
2016-04-05 11:41:10 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
/// Derive your WSD unit test / hooks from me.
|
|
|
|
class UnitBase
|
2016-04-05 11:41:10 -05:00
|
|
|
{
|
2016-04-08 11:36:08 -05:00
|
|
|
friend UnitTimeout;
|
2016-04-09 11:30:48 -05:00
|
|
|
friend UnitWSD;
|
|
|
|
friend UnitKit;
|
2016-04-08 11:36:08 -05:00
|
|
|
|
2016-04-06 13:50:55 -05:00
|
|
|
protected:
|
2016-04-07 15:59:27 -05:00
|
|
|
// ---------------- Helper API ----------------
|
2016-04-08 11:36:08 -05:00
|
|
|
/// After this time we invoke 'timeout' default 30 seconds
|
2020-12-14 13:00:55 -06:00
|
|
|
void setTimeout(std::chrono::milliseconds timeoutMilliSeconds);
|
2016-04-08 11:36:08 -05:00
|
|
|
|
2016-12-22 03:27:30 -06:00
|
|
|
enum class TestResult
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
Failed,
|
|
|
|
Ok,
|
|
|
|
TimedOut
|
2016-10-29 20:15:00 -05:00
|
|
|
};
|
2016-04-09 11:30:48 -05:00
|
|
|
|
2020-06-22 07:24:11 -05:00
|
|
|
static const std::string testResultAsString(TestResult res)
|
|
|
|
{
|
|
|
|
switch (res)
|
|
|
|
{
|
|
|
|
case TestResult::Failed:
|
|
|
|
return "Failed";
|
|
|
|
case TestResult::Ok:
|
|
|
|
return "Ok";
|
|
|
|
case TestResult::TimedOut:
|
|
|
|
return "TimedOut";
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!"Unknown TestResult entry.");
|
|
|
|
return std::to_string(static_cast<int>(res));
|
|
|
|
}
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
/// Encourages the process to exit with this value (unless hooked)
|
2016-04-06 13:50:55 -05:00
|
|
|
void exitTest(TestResult result);
|
2016-04-07 15:59:27 -05:00
|
|
|
|
2021-01-10 15:44:24 -06:00
|
|
|
/// Fail the test with the given reason.
|
|
|
|
void failTest(const std::string& reason)
|
|
|
|
{
|
|
|
|
LOG_TST("FAILURE: " << getTestname() << " finished: " << reason);
|
|
|
|
exitTest(TestResult::Failed);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Pass the test with the given optional reason.
|
|
|
|
void passTest(const std::string& reason = std::string())
|
|
|
|
{
|
|
|
|
LOG_TST("SUCCESS: " << getTestname() << " finished: " << reason);
|
|
|
|
exitTest(TestResult::Ok);
|
|
|
|
}
|
|
|
|
|
2021-04-12 14:14:49 -05:00
|
|
|
/// Construct a UnitBase instance with a default name.
|
2021-04-22 20:58:49 -05:00
|
|
|
explicit UnitBase(std::string name)
|
2021-04-12 14:14:49 -05:00
|
|
|
: _dlHandle(nullptr)
|
|
|
|
, _setRetValue(false)
|
|
|
|
, _retValue(0)
|
|
|
|
, _timeoutMilliSeconds(std::chrono::seconds(30))
|
|
|
|
, _type(UnitType::Wsd)
|
|
|
|
, _testname(std::move(name))
|
2021-04-12 23:48:47 -05:00
|
|
|
, _socketPoll(std::make_shared<SocketPoll>(_testname))
|
2020-12-20 21:11:33 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
virtual ~UnitBase();
|
|
|
|
|
|
|
|
public:
|
2016-12-22 03:27:30 -06:00
|
|
|
enum class UnitType
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
Wsd,
|
2021-08-10 22:41:02 -05:00
|
|
|
Kit,
|
|
|
|
Tool
|
2016-10-29 20:15:00 -05:00
|
|
|
};
|
2016-04-09 11:30:48 -05:00
|
|
|
/// Load unit test hook shared library from this path
|
2016-10-29 20:15:00 -05:00
|
|
|
static bool init(UnitType type, const std::string& unitLibPath);
|
2016-04-09 11:30:48 -05:00
|
|
|
|
2016-10-22 10:35:30 -05:00
|
|
|
/// Do we have a unit test library hooking things & loaded
|
|
|
|
static bool isUnitTesting();
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
/// Tweak the return value from the process.
|
2016-10-29 20:15:00 -05:00
|
|
|
virtual void returnValue(int& /* retValue */);
|
2016-04-09 11:30:48 -05:00
|
|
|
|
2016-12-07 15:32:08 -06:00
|
|
|
/// Input message either for WSD or Kit
|
2016-12-12 18:53:58 -06:00
|
|
|
virtual bool filterSessionInput(Session *, const char */* buffer */,
|
2016-12-07 15:32:08 -06:00
|
|
|
int /* length */,
|
|
|
|
std::unique_ptr< std::vector<char> > & /* replace */)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-26 03:38:57 -05:00
|
|
|
|
|
|
|
/// Message that is about to be sent via the websocket.
|
2021-01-04 17:35:43 -06:00
|
|
|
/// To override, handle onFilterSendMessage or any of the onDocument...() handlers.
|
|
|
|
bool filterSendMessage(const char* data, const std::size_t len, const WSOpCode code,
|
|
|
|
const bool flush, int& unitReturn)
|
2017-10-26 03:38:57 -05:00
|
|
|
{
|
2021-01-04 17:35:43 -06:00
|
|
|
const std::string message(data, len);
|
|
|
|
|
|
|
|
if (Util::startsWith(message, "status:"))
|
|
|
|
{
|
|
|
|
if (onDocumentLoaded(message))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (message == "statechanged: .uno:ModifiedStatus=true")
|
|
|
|
{
|
|
|
|
if (onDocumentModified(message))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (Util::startsWith(message, "statechanged:"))
|
|
|
|
{
|
|
|
|
if (onDocumentStateChanged(message))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (Util::startsWith(message, "error:"))
|
|
|
|
{
|
|
|
|
if (onDocumentError(message))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return onFilterSendMessage(data, len, code, flush, unitReturn);
|
2017-10-26 03:38:57 -05:00
|
|
|
}
|
2016-12-07 15:32:08 -06:00
|
|
|
|
2017-03-31 11:18:41 -05:00
|
|
|
/// Hook the disk space check
|
|
|
|
virtual bool filterCheckDiskSpace(const std::string & /* path */,
|
|
|
|
bool & /* newResult */)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-16 11:55:23 -05:00
|
|
|
/// Trap and filter alerting all users
|
|
|
|
virtual bool filterAlertAllusers(const std::string & /* msg */)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-09 15:02:29 -05:00
|
|
|
/// Custom response to a http request.
|
2021-01-04 17:35:43 -06:00
|
|
|
virtual bool handleHttpRequest(const Poco::Net::HTTPRequest& /*request*/,
|
|
|
|
Poco::MemoryInputStream& /*message*/,
|
|
|
|
std::shared_ptr<StreamSocket>& /*socket*/)
|
2017-08-09 15:02:29 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-04 17:35:43 -06:00
|
|
|
/// Called when the document has been loaded,
|
|
|
|
/// based on the "status:" message, in the context of filterSendMessage.
|
|
|
|
/// Return true to stop further handling of messages.
|
|
|
|
virtual bool onDocumentLoaded(const std::string&) { return false; }
|
|
|
|
|
|
|
|
/// Called when the document's 'modified' status
|
|
|
|
/// changes to true.
|
|
|
|
/// Return true to stop further handling of messages.
|
|
|
|
virtual bool onDocumentModified(const std::string&) { return false; }
|
|
|
|
|
|
|
|
/// Called when the document has been saved.
|
|
|
|
/// Return true to stop further handling of messages.
|
|
|
|
virtual bool onDocumentSaved(const std::string&) { return false; }
|
|
|
|
|
|
|
|
/// Called when the document issues a 'statechanged:' message.
|
|
|
|
/// Return true to stop further handling of messages.
|
|
|
|
virtual bool onDocumentStateChanged(const std::string&) { return false; }
|
|
|
|
|
|
|
|
/// Called when the document issues an 'error:' message.
|
|
|
|
/// Return true to stop further handling of messages.
|
|
|
|
virtual bool onDocumentError(const std::string&) { return false; }
|
|
|
|
|
2017-03-16 13:52:49 -05:00
|
|
|
/// If the test times out this gets invoked, the default just exits.
|
|
|
|
virtual void timeout();
|
|
|
|
|
2020-12-14 13:00:55 -06:00
|
|
|
std::chrono::milliseconds getTimeoutMilliSeconds() const
|
2017-03-16 13:52:49 -05:00
|
|
|
{
|
|
|
|
return _timeoutMilliSeconds;
|
|
|
|
}
|
|
|
|
|
2016-12-07 15:32:08 -06:00
|
|
|
static UnitBase& get()
|
|
|
|
{
|
|
|
|
assert(Global);
|
2016-12-23 01:02:19 -06:00
|
|
|
return *Global;
|
2016-12-07 15:32:08 -06:00
|
|
|
}
|
|
|
|
|
2020-01-17 14:49:38 -06:00
|
|
|
static std::string getUnitLibPath() { return std::string(UnitLibPath); }
|
|
|
|
|
2020-12-20 21:11:33 -06:00
|
|
|
const std::string& getTestname() const { return _testname; }
|
|
|
|
void setTestname(const std::string& testname) { _testname = testname; }
|
|
|
|
|
2021-04-12 23:48:47 -05:00
|
|
|
std::shared_ptr<SocketPoll> socketPoll() { return _socketPoll; }
|
2021-04-12 16:22:08 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
private:
|
2020-01-17 14:49:38 -06:00
|
|
|
void setHandle(void *dlHandle)
|
|
|
|
{
|
2021-05-04 21:03:58 -05:00
|
|
|
assert(_dlHandle == nullptr && "setHandle must only be called once");
|
|
|
|
assert(dlHandle != nullptr && "Invalid handle to set");
|
2020-01-17 14:49:38 -06:00
|
|
|
_dlHandle = dlHandle;
|
2021-05-04 21:03:58 -05:00
|
|
|
_socketPoll->startThread();
|
2020-01-17 14:49:38 -06:00
|
|
|
}
|
2016-10-29 20:15:00 -05:00
|
|
|
static UnitBase *linkAndCreateUnit(UnitType type, const std::string& unitLibPath);
|
2016-04-09 11:30:48 -05:00
|
|
|
|
2021-01-04 17:35:43 -06:00
|
|
|
/// Handles messages sent via WebSocket.
|
|
|
|
virtual bool onFilterSendMessage(const char* /*data*/, const std::size_t /*len*/,
|
|
|
|
const WSOpCode /* code */, const bool /* flush */,
|
|
|
|
int& /*unitReturn*/)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
void *_dlHandle;
|
2020-01-17 14:49:38 -06:00
|
|
|
static char *UnitLibPath;
|
2016-04-09 11:30:48 -05:00
|
|
|
bool _setRetValue;
|
2016-10-29 20:15:00 -05:00
|
|
|
int _retValue;
|
2020-12-14 13:00:55 -06:00
|
|
|
std::chrono::milliseconds _timeoutMilliSeconds;
|
2016-06-07 02:18:49 -05:00
|
|
|
static UnitBase *Global;
|
2016-04-09 11:30:48 -05:00
|
|
|
UnitType _type;
|
2020-12-20 21:11:33 -06:00
|
|
|
|
|
|
|
/// The name of the current test.
|
|
|
|
std::string _testname;
|
2021-04-12 16:22:08 -05:00
|
|
|
|
2021-04-12 23:48:47 -05:00
|
|
|
std::shared_ptr<SocketPoll> _socketPoll; //< Poll thread for async http comm.
|
2016-04-09 11:30:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Derive your WSD unit test / hooks from me.
|
|
|
|
class UnitWSD : public UnitBase
|
|
|
|
{
|
|
|
|
bool _hasKitHooks;
|
2016-10-29 20:15:00 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
public:
|
2020-12-20 21:11:33 -06:00
|
|
|
UnitWSD(std::string testname = std::string());
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
virtual ~UnitWSD();
|
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
static UnitWSD& get()
|
2016-04-09 11:30:48 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
assert(Global && Global->_type == UnitType::Wsd);
|
2016-06-07 02:18:49 -05:00
|
|
|
return *static_cast<UnitWSD *>(Global);
|
2016-04-09 11:30:48 -05:00
|
|
|
}
|
|
|
|
|
2016-12-22 03:27:30 -06:00
|
|
|
enum class TestRequest
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
Client,
|
|
|
|
Prisoner
|
2016-10-29 20:15:00 -05:00
|
|
|
};
|
2016-04-07 15:59:27 -05:00
|
|
|
/// Simulate an incoming request
|
2016-12-23 00:42:35 -06:00
|
|
|
static void testHandleRequest(TestRequest type,
|
2016-12-27 04:35:07 -06:00
|
|
|
UnitHTTPServerRequest& request,
|
|
|
|
UnitHTTPServerResponse& response);
|
2016-04-09 11:30:48 -05:00
|
|
|
/// Do we have hooks for the Kit too
|
|
|
|
bool hasKitHooks() { return _hasKitHooks; }
|
|
|
|
/// set in your unit if you want to be injected into the kit too.
|
2017-01-16 04:59:03 -06:00
|
|
|
void setHasKitHooks() { _hasKitHooks = true; }
|
2016-04-05 11:41:10 -05:00
|
|
|
|
2016-04-09 12:26:33 -05:00
|
|
|
// ---------------- WSD hooks ----------------
|
2016-04-07 15:59:27 -05:00
|
|
|
|
2016-04-16 13:37:38 -05:00
|
|
|
/// Manipulate and modify the configuration before any usage.
|
2016-10-29 20:15:00 -05:00
|
|
|
virtual void configure(Poco::Util::LayeredConfiguration& /* config */);
|
2020-12-24 11:15:37 -06:00
|
|
|
|
|
|
|
/// Main-loop reached, time for testing.
|
|
|
|
/// Invoked from loolwsd's main thread.
|
|
|
|
void invokeTest()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Invoke the test, expect no exceptions.
|
|
|
|
invokeWSDTest();
|
|
|
|
}
|
2021-05-01 15:33:09 -05:00
|
|
|
catch (const Poco::Exception& ex)
|
|
|
|
{
|
|
|
|
LOG_ERR("ERROR: unexpected exception while invoking WSD Test: : "
|
|
|
|
<< ex.displayText()
|
|
|
|
<< (ex.nested() ? "( " + ex.nested()->displayText() + ')' : ""));
|
|
|
|
exitTest(TestResult::Failed);
|
|
|
|
}
|
2020-12-24 11:15:37 -06:00
|
|
|
catch (const std::exception& ex)
|
|
|
|
{
|
|
|
|
LOG_TST("ERROR: unexpected exception while invoking WSD Test: " << ex.what());
|
|
|
|
exitTest(TestResult::Failed);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
LOG_TST("ERROR: unexpected unknown exception while invoking WSD Test");
|
|
|
|
exitTest(TestResult::Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-06 13:50:55 -05:00
|
|
|
/// When a new child kit process reports
|
2017-03-16 13:32:12 -05:00
|
|
|
virtual void newChild(WebSocketHandler &/* socket */) {}
|
2016-04-07 15:59:27 -05:00
|
|
|
/// Intercept createStorage
|
2016-10-14 05:09:43 -05:00
|
|
|
virtual bool createStorage(const Poco::URI& /* uri */,
|
|
|
|
const std::string& /* jailRoot */,
|
2016-04-07 15:59:27 -05:00
|
|
|
const std::string& /* jailPath */,
|
2017-01-13 06:52:08 -06:00
|
|
|
std::unique_ptr<StorageBase>& /* storage */)
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-20 21:31:53 -05:00
|
|
|
/// Child sent a message
|
|
|
|
virtual bool filterChildMessage(const std::vector<char>& /* payload */)
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-20 21:31:53 -05:00
|
|
|
|
2016-05-01 09:24:31 -05:00
|
|
|
// ---------------- TileCache hooks ----------------
|
|
|
|
/// Called before the lookupTile call returns. Should always be called to fire events.
|
|
|
|
virtual void lookupTile(int part, int width, int height, int tilePosX, int tilePosY,
|
2019-02-14 13:01:43 -06:00
|
|
|
int tileWidth, int tileHeight,
|
|
|
|
std::shared_ptr<std::vector<char>> &tile);
|
2016-05-01 09:24:31 -05:00
|
|
|
|
2016-10-20 16:09:00 -05:00
|
|
|
// ---------------- DocumentBroker hooks ----------------
|
2016-10-29 20:15:00 -05:00
|
|
|
virtual bool filterLoad(const std::string& /* sessionId */,
|
|
|
|
const std::string& /* jailId */,
|
|
|
|
bool& /* result */)
|
2016-10-20 16:09:00 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-03 04:59:39 -05:00
|
|
|
/// To force the save operation being handled as auto-save from a unit test.
|
|
|
|
virtual bool isAutosave()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-06-21 05:47:07 -05:00
|
|
|
/// hook and allow through clipboard authentication
|
|
|
|
virtual bool filterClipboardAuth(const std::string & /* serverId */, const std::string &/* tag */)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-17 08:54:05 -05:00
|
|
|
// ---------------- WSD events ----------------
|
|
|
|
virtual void onChildConnected(const int /* pid */, const std::string& /* sessionId */) {}
|
2016-04-18 08:29:17 -05:00
|
|
|
/// When admin notify message is sent
|
|
|
|
virtual void onAdminNotifyMessage(const std::string& /* message */) {}
|
|
|
|
/// When admin message is sent in response to a query
|
|
|
|
virtual void onAdminQueryMessage(const std::string& /* message */) {}
|
2016-05-01 09:24:31 -05:00
|
|
|
|
|
|
|
// ---------------- TileCache events ----------------
|
|
|
|
virtual void onTileCacheHit(int /*part*/, int /*width*/, int /*height*/,
|
|
|
|
int /*tilePosX*/, int /*tilePosY*/,
|
|
|
|
int /*tileWidth*/, int /*tileHeight*/) {}
|
|
|
|
virtual void onTileCacheMiss(int /*part*/, int /*width*/, int /*height*/,
|
|
|
|
int /*tilePosX*/, int /*tilePosY*/,
|
|
|
|
int /*tileWidth*/, int /*tileHeight*/) {}
|
|
|
|
virtual void onTileCacheSubscribe(int /*part*/, int /*width*/, int /*height*/,
|
|
|
|
int /*tilePosX*/, int /*tilePosY*/,
|
|
|
|
int /*tileWidth*/, int /*tileHeight*/) {}
|
2020-12-24 11:15:37 -06:00
|
|
|
private:
|
|
|
|
/// The actual test implementation.
|
|
|
|
virtual void invokeWSDTest() {}
|
2016-04-09 11:30:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Derive your Kit unit test / hooks from me.
|
|
|
|
class UnitKit : public UnitBase
|
|
|
|
{
|
|
|
|
public:
|
2021-04-22 20:58:49 -05:00
|
|
|
explicit UnitKit(std::string testname = std::string());
|
2016-04-09 11:30:48 -05:00
|
|
|
virtual ~UnitKit();
|
2016-10-29 20:15:00 -05:00
|
|
|
static UnitKit& get()
|
2016-04-09 11:30:48 -05:00
|
|
|
{
|
2019-08-12 03:31:02 -05:00
|
|
|
assert(Global);
|
2020-02-20 08:31:19 -06:00
|
|
|
#if !MOBILEAPP && !defined(KIT_IN_PROCESS)
|
2019-08-12 03:31:02 -05:00
|
|
|
assert(Global->_type == UnitType::Kit);
|
|
|
|
#endif
|
2016-06-07 02:18:49 -05:00
|
|
|
return *static_cast<UnitKit *>(Global);
|
2016-04-09 11:30:48 -05:00
|
|
|
}
|
2016-04-09 12:26:33 -05:00
|
|
|
|
|
|
|
// ---------------- ForKit hooks ----------------
|
|
|
|
|
|
|
|
/// main-loop reached, time for testing
|
|
|
|
virtual void invokeForKitTest() {}
|
|
|
|
|
2016-04-12 15:30:06 -05:00
|
|
|
/// Post fork hook - just after we fork to init the child kit
|
|
|
|
virtual void launchedKit(int /* pid */) {}
|
|
|
|
|
2016-04-09 12:26:33 -05:00
|
|
|
// ---------------- Kit hooks ----------------
|
|
|
|
|
|
|
|
/// Post fork hook - just before we init the child kit
|
|
|
|
virtual void postFork() {}
|
|
|
|
|
|
|
|
/// Kit got a message
|
2018-11-07 17:00:32 -06:00
|
|
|
virtual bool filterKitMessage(WebSocketHandler *, std::string &/* message */ )
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-01 03:04:19 -05:00
|
|
|
|
2019-06-21 05:47:07 -05:00
|
|
|
/// LOKit (and some synthetic internal) callbacks
|
|
|
|
virtual bool filterLoKitCallback(const int /* type */, const std::string& /* payload */)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-01 03:04:19 -05:00
|
|
|
/// Allow a custom LibreOfficeKit wrapper
|
|
|
|
virtual LibreOfficeKit *lok_init(const char * /* instdir */,
|
|
|
|
const char * /* userdir */)
|
2016-10-29 20:15:00 -05:00
|
|
|
{
|
2016-12-22 08:04:07 -06:00
|
|
|
return nullptr;
|
2016-10-29 20:15:00 -05:00
|
|
|
}
|
2016-04-05 11:41:10 -05:00
|
|
|
};
|
|
|
|
|
2021-08-10 22:41:02 -05:00
|
|
|
/// Derive your Tool unit test / hooks from me.
|
|
|
|
class UnitTool : public UnitBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit UnitTool(std::string testname = std::string())
|
|
|
|
: UnitBase(testname) {}
|
|
|
|
virtual ~UnitTool() {}
|
|
|
|
};
|
|
|
|
|
2016-04-05 11:41:10 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|