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