summaryrefslogtreecommitdiff
path: root/test/UnitStorage.cpp
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-11-24 14:52:34 +0000
committerMichael Meeks <michael.meeks@collabora.com>2016-11-25 09:58:48 +0000
commitcca657c8f2031ec88366c52f5e8e10c2e04129f9 (patch)
treea2273ed56080856d8494ba759b8ed0e435ebba99 /test/UnitStorage.cpp
parent4432aba25b6ee68356e0ddfc724afb8373651945 (diff)
Apply the pre-branch rename script to re-organize the source.
Diffstat (limited to 'test/UnitStorage.cpp')
-rw-r--r--test/UnitStorage.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/UnitStorage.cpp b/test/UnitStorage.cpp
new file mode 100644
index 000000000..521786e92
--- /dev/null
+++ b/test/UnitStorage.cpp
@@ -0,0 +1,80 @@
+/* -*- 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/.
+ */
+
+#include <iostream>
+
+#include "Exceptions.hpp"
+#include "Log.hpp"
+#include "Unit.hpp"
+#include "UnitHTTP.hpp"
+#include "helpers.hpp"
+
+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
+ } _phase;
+ std::unique_ptr<UnitWebSocket> _ws;
+public:
+ UnitStorage() :
+ _phase(PHASE_LOAD)
+ {
+ }
+
+ virtual bool filterLoad(const std::string &/* sessionId */,
+ const std::string &/* jailId */,
+ bool &/* result */)
+ {
+ if (_phase == PHASE_FILTER)
+ {
+ _phase = PHASE_RE_LOAD;
+ LOG_INF("Throwing low disk space exception.");
+ throw StorageSpaceLowException("test: low disk space");
+ }
+ 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());
+ }
+
+ virtual void invokeTest()
+ {
+ switch (_phase)
+ {
+ case PHASE_LOAD:
+ _phase = PHASE_FILTER;
+ loadDocument();
+ break;
+ case PHASE_FILTER:
+ break;
+ case PHASE_RE_LOAD:
+ loadDocument();
+ _ws.reset();
+ exitTest(TEST_OK);
+ break;
+ }
+ }
+};
+
+UnitBase *unit_create_wsd(void)
+{
+ return new UnitStorage();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */