2016-05-01 16:24:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
2023-11-09 19:23:00 +01:00
|
|
|
* Copyright the Collabora Online contributors.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-05-01 16:24:31 +02:00
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2017-12-20 14:06:26 +01:00
|
|
|
#include <config.h>
|
2017-03-08 17:38:22 +01:00
|
|
|
|
2016-05-01 16:24:31 +02:00
|
|
|
#include <fstream>
|
2016-05-01 17:20:41 +02:00
|
|
|
#include <thread>
|
2016-05-01 16:24:31 +02:00
|
|
|
|
2017-12-20 14:06:26 +01:00
|
|
|
#include <Log.hpp>
|
|
|
|
#include <Unit.hpp>
|
|
|
|
#include <UnitHTTP.hpp>
|
|
|
|
#include <Util.hpp>
|
|
|
|
#include <helpers.hpp>
|
2022-07-21 14:34:14 +02:00
|
|
|
#include <WopiTestServer.hpp>
|
2016-05-01 16:24:31 +02:00
|
|
|
|
2016-10-20 23:09:00 +02:00
|
|
|
using namespace helpers;
|
|
|
|
|
2022-07-21 14:34:14 +02:00
|
|
|
class UnitTileCache: public WopiTestServer
|
2016-05-01 16:24:31 +02:00
|
|
|
{
|
2022-07-21 14:34:14 +02:00
|
|
|
STATE_ENUM(Phase,
|
|
|
|
Load, // load the document
|
|
|
|
Tile, // lookup tile method
|
|
|
|
)
|
|
|
|
_phase;
|
2016-05-01 16:24:31 +02:00
|
|
|
public:
|
2022-04-22 01:14:16 +02:00
|
|
|
UnitTileCache()
|
2022-07-21 14:34:14 +02:00
|
|
|
: WopiTestServer("UnitTileCache")
|
2022-04-22 01:14:16 +02:00
|
|
|
, _phase(Phase::Load)
|
2016-05-01 17:20:41 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-30 07:27:44 +02:00
|
|
|
virtual void lookupTile(int part, int mode, int width, int height, int tilePosX, int tilePosY,
|
2019-02-14 20:01:43 +01:00
|
|
|
int tileWidth, int tileHeight,
|
2021-11-13 12:49:35 +01:00
|
|
|
std::shared_ptr<TileData> &tile)
|
2016-05-01 16:24:31 +02:00
|
|
|
{
|
|
|
|
// Call base to fire events.
|
2022-08-30 07:27:44 +02:00
|
|
|
UnitWSD::lookupTile(part, mode, width, height, tilePosX, tilePosY, tileWidth, tileHeight, tile);
|
2016-05-01 16:24:31 +02:00
|
|
|
|
|
|
|
// Fail the lookup to force subscription and rendering.
|
2019-02-14 20:01:43 +01:00
|
|
|
tile.reset();
|
2016-10-20 23:09:00 +02:00
|
|
|
|
|
|
|
// FIXME: push through to the right place to exercise this.
|
2016-12-22 10:27:30 +01:00
|
|
|
exitTest(TestResult::Ok);
|
2016-05-01 16:24:31 +02:00
|
|
|
}
|
|
|
|
|
2020-12-24 18:15:37 +01:00
|
|
|
virtual void invokeWSDTest()
|
2016-05-01 16:24:31 +02:00
|
|
|
{
|
2016-10-20 23:09:00 +02:00
|
|
|
switch (_phase)
|
|
|
|
{
|
2016-12-22 10:27:30 +01:00
|
|
|
case Phase::Load:
|
2016-10-20 23:09:00 +02:00
|
|
|
{
|
2022-07-21 14:34:14 +02:00
|
|
|
TRANSITION_STATE(_phase, Phase::Tile);
|
|
|
|
|
|
|
|
LOG_TST("Load: initWebsocket");
|
|
|
|
initWebsocket("/wopi/files/0?access_token=anything");
|
|
|
|
|
|
|
|
WSD_CMD("load url=" + getWopiSrc());
|
2016-10-20 23:09:00 +02:00
|
|
|
|
|
|
|
// FIXME: need to invoke the tile lookup ...
|
2016-12-22 10:27:30 +01:00
|
|
|
exitTest(TestResult::Ok);
|
2016-10-20 23:09:00 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-12-22 10:27:30 +01:00
|
|
|
case Phase::Tile:
|
2016-10-20 23:09:00 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-05-01 16:24:31 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
UnitBase *unit_create_wsd(void)
|
|
|
|
{
|
|
|
|
return new UnitTileCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|