2016-05-01 09:24:31 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* 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>
|
2016-05-01 09:24:31 -05:00
|
|
|
|
2016-10-20 16:09:00 -05:00
|
|
|
using namespace helpers;
|
|
|
|
|
2016-05-01 09:24:31 -05:00
|
|
|
class UnitTileCache: public UnitWSD
|
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
enum class Phase {
|
|
|
|
Load, // load the document
|
|
|
|
Tile, // lookup tile method
|
2016-10-20 16:09:00 -05:00
|
|
|
} _phase;
|
|
|
|
std::unique_ptr<UnitWebSocket> _ws;
|
2016-05-01 09:24:31 -05:00
|
|
|
public:
|
2016-10-20 16:09:00 -05:00
|
|
|
UnitTileCache() :
|
2016-12-22 03:27:30 -06:00
|
|
|
_phase(Phase::Load)
|
2016-05-01 10:20:41 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-01 09:24:31 -05:00
|
|
|
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
|
|
|
{
|
|
|
|
// Call base to fire events.
|
2019-02-14 13:01:43 -06:00
|
|
|
UnitWSD::lookupTile(part, 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
|
|
|
}
|
|
|
|
|
|
|
|
virtual void invokeTest()
|
|
|
|
{
|
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
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
_phase = Phase::Tile;
|
2016-10-20 16:09:00 -05:00
|
|
|
std::string docPath;
|
|
|
|
std::string docURL;
|
2017-02-28 15:49:24 -06:00
|
|
|
getDocumentPathAndURL("empty.odt", docPath, docURL, "unitTileCache ");
|
2016-10-20 16:09:00 -05:00
|
|
|
_ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(docURL));
|
|
|
|
assert(_ws.get());
|
|
|
|
|
|
|
|
// 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: */
|