2019-10-25 01:54:46 -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
|
|
|
|
*
|
2019-10-25 01:54:46 -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/.
|
|
|
|
*/
|
|
|
|
|
2021-03-25 08:47:10 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
2019-10-25 01:54:46 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <Poco/URI.h>
|
2020-01-20 10:45:53 -06:00
|
|
|
#include <test/lokassert.hpp>
|
2019-10-25 01:54:46 -05:00
|
|
|
|
|
|
|
#include <Unit.hpp>
|
|
|
|
#include <Util.hpp>
|
|
|
|
#include <helpers.hpp>
|
|
|
|
|
|
|
|
/// Rendering options testcase.
|
|
|
|
class UnitRenderingOptions : public UnitWSD
|
|
|
|
{
|
|
|
|
public:
|
2022-02-16 16:22:18 -06:00
|
|
|
UnitRenderingOptions()
|
|
|
|
: UnitWSD("UnitRenderRenderingOptions")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-12-24 11:15:37 -06:00
|
|
|
void invokeWSDTest() override;
|
2019-10-25 01:54:46 -05:00
|
|
|
};
|
|
|
|
|
2020-12-24 11:15:37 -06:00
|
|
|
void UnitRenderingOptions::invokeWSDTest()
|
2019-10-25 01:54:46 -05:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Load a document and make it empty, then paste some text into it.
|
|
|
|
std::string documentPath;
|
|
|
|
std::string documentURL;
|
|
|
|
helpers::getDocumentPathAndURL("hide-whitespace.odt", documentPath, documentURL, testname);
|
|
|
|
|
|
|
|
const std::string options
|
|
|
|
= "{\"rendering\":{\".uno:HideWhitespace\":{\"type\":\"boolean\",\"value\":\"true\"}}}";
|
|
|
|
|
2022-07-12 06:37:34 -05:00
|
|
|
std::shared_ptr<SocketPoll> socketPoll = std::make_shared<SocketPoll>("WithoutPasswordPoll");
|
|
|
|
socketPoll->startThread();
|
|
|
|
|
|
|
|
std::shared_ptr<http::WebSocketSession> socket = helpers::connectLOKit(
|
|
|
|
socketPoll, Poco::URI(helpers::getTestServerURI()), documentURL, testname);
|
2019-10-25 01:54:46 -05:00
|
|
|
|
2022-07-08 07:07:30 -05:00
|
|
|
helpers::sendTextFrame(socket, "load url=" + documentURL + " options=" + options, testname);
|
|
|
|
helpers::sendTextFrame(socket, "status", testname);
|
2019-10-25 01:54:46 -05:00
|
|
|
const auto status = helpers::assertResponseString(socket, "status:", testname);
|
|
|
|
|
|
|
|
// Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'.
|
2020-01-20 10:45:53 -06:00
|
|
|
|
2022-03-29 20:37:57 -05:00
|
|
|
StringVector tokens(StringVector::tokenize(status, ' '));
|
2021-07-25 03:16:11 -05:00
|
|
|
LOK_ASSERT_EQUAL(static_cast<size_t>(8), tokens.size());
|
2019-10-25 01:54:46 -05:00
|
|
|
|
|
|
|
const std::string token = tokens[5];
|
|
|
|
const std::string prefix = "height=";
|
2020-01-20 10:45:53 -06:00
|
|
|
LOK_ASSERT_EQUAL(static_cast<size_t>(0), token.find(prefix));
|
2019-10-25 01:54:46 -05:00
|
|
|
const int height = std::stoi(token.substr(prefix.size()));
|
|
|
|
// HideWhitespace was ignored, this was 32532, should be around 16706.
|
2020-01-20 10:45:53 -06:00
|
|
|
LOK_ASSERT(height < 20000);
|
2019-10-25 01:54:46 -05:00
|
|
|
}
|
|
|
|
catch (const Poco::Exception& exc)
|
|
|
|
{
|
2020-01-20 10:45:53 -06:00
|
|
|
LOK_ASSERT_FAIL(exc.displayText());
|
2019-10-25 01:54:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
exitTest(TestResult::Ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
UnitBase* unit_create_wsd(void) { return new UnitRenderingOptions(); }
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|