2016-04-07 15:59:27 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2016-10-20 16:09:00 -05:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Exceptions.hpp"
|
2016-11-06 11:52:31 -06:00
|
|
|
#include "Log.hpp"
|
2016-04-07 15:59:27 -05:00
|
|
|
#include "Unit.hpp"
|
|
|
|
#include "UnitHTTP.hpp"
|
2016-10-20 16:09:00 -05:00
|
|
|
#include "helpers.hpp"
|
|
|
|
|
|
|
|
using namespace helpers;
|
2016-04-07 15:59:27 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
class UnitStorage : public UnitWSD
|
2016-04-07 15:59:27 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
enum class Phase {
|
|
|
|
Load, // load the document
|
|
|
|
Filter, // throw filter exception
|
|
|
|
Reload, // re-load the document
|
2016-10-20 16:09:00 -05:00
|
|
|
} _phase;
|
|
|
|
std::unique_ptr<UnitWebSocket> _ws;
|
2016-04-07 15:59:27 -05:00
|
|
|
public:
|
2016-10-20 16:09:00 -05:00
|
|
|
UnitStorage() :
|
2016-12-22 03:27:30 -06:00
|
|
|
_phase(Phase::Load)
|
2016-10-20 16:09:00 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool filterLoad(const std::string &/* sessionId */,
|
|
|
|
const std::string &/* jailId */,
|
|
|
|
bool &/* result */)
|
2016-04-07 15:59:27 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
if (_phase == Phase::Filter)
|
2016-10-20 16:09:00 -05:00
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
_phase = Phase::Reload;
|
2016-11-06 11:52:31 -06:00
|
|
|
LOG_INF("Throwing low disk space exception.");
|
2016-10-20 16:09:00 -05:00
|
|
|
throw StorageSpaceLowException("test: low disk space");
|
|
|
|
}
|
|
|
|
return false;
|
2016-04-07 15:59:27 -05:00
|
|
|
}
|
2016-10-20 16:09:00 -05:00
|
|
|
|
|
|
|
void loadDocument()
|
|
|
|
{
|
|
|
|
std::string docPath;
|
|
|
|
std::string docURL;
|
|
|
|
getDocumentPathAndURL("empty.odt", docPath, docURL);
|
|
|
|
_ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(docURL));
|
|
|
|
assert(_ws.get());
|
|
|
|
}
|
|
|
|
|
2016-04-07 15:59:27 -05:00
|
|
|
virtual void invokeTest()
|
|
|
|
{
|
2016-10-20 16:09:00 -05:00
|
|
|
switch (_phase)
|
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
case Phase::Load:
|
|
|
|
_phase = Phase::Filter;
|
2016-10-20 16:09:00 -05:00
|
|
|
loadDocument();
|
|
|
|
break;
|
2016-12-22 03:27:30 -06:00
|
|
|
case Phase::Filter:
|
2016-10-20 16:09:00 -05:00
|
|
|
break;
|
2016-12-22 03:27:30 -06:00
|
|
|
case Phase::Reload:
|
2016-10-20 16:09:00 -05:00
|
|
|
loadDocument();
|
|
|
|
_ws.reset();
|
2016-12-22 03:27:30 -06:00
|
|
|
exitTest(TestResult::Ok);
|
2016-10-20 16:09:00 -05:00
|
|
|
break;
|
|
|
|
}
|
2016-04-07 15:59:27 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
UnitBase *unit_create_wsd(void)
|
2016-04-07 15:59:27 -05:00
|
|
|
{
|
|
|
|
return new UnitStorage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|