summaryrefslogtreecommitdiff
path: root/sd/qa/unit
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-06-27 13:23:56 +0900
committerMiklos Vajna <vmiklos@collabora.com>2024-09-11 13:55:24 +0200
commit43c8ec415a25637231ffa4ae0825fec58431e300 (patch)
tree9efa250eb5f292410b9802fedd43aa20a444410f /sd/qa/unit
parent482c7c585160681b263c6245a745c21df70e7507 (diff)
lok: test for getPresentationInfo LOK API function
Also fix getting the slides, so we don't rely that a WeakReference is set, as it is not set (yet) when running the test. Change-Id: Icd338e31fbd0bb7c45a06357b955b85081ed38c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172868 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd/qa/unit')
-rw-r--r--sd/qa/unit/tiledrendering/data/PresentationInfoTest.odpbin0 -> 13151 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx86
2 files changed, 86 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp b/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp
new file mode 100644
index 000000000000..77aa85a25356
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 87371647db85..12cbefb28328 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3001,6 +3001,92 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testStartPresentation)
CPPUNIT_ASSERT_EQUAL(std::string("true"), value.get_child("state").get_value<std::string>());
}
+namespace
+{
+
+boost::property_tree::ptree const& child_at(boost::property_tree::ptree const& rTree, std::string_view aName, size_t nIndex)
+{
+ return std::next(rTree.get_child(std::string(aName)).find(""), nIndex)->second;
+}
+
+bool has_child(boost::property_tree::ptree const& rTree, std::string_view aName)
+{
+ return rTree.count(std::string(aName)) > 0;
+}
+
+} // end anonymous ns
+
+CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo)
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("PresentationInfoTest.odp");
+ pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+
+ Scheduler::ProcessEventsToIdle();
+
+ SdPage* pPage = pViewShell->GetActualPage();
+ CPPUNIT_ASSERT(pPage);
+
+ OString aString = pXImpressDocument->getPresentationInfo();
+
+ boost::property_tree::ptree aTree;
+ std::stringstream aStream((std::string(aString)));
+ boost::property_tree::read_json(aStream, aTree);
+
+ CPPUNIT_ASSERT_EQUAL(15875, aTree.get_child("docWidth").get_value<int>());
+ CPPUNIT_ASSERT_EQUAL(8930, aTree.get_child("docHeight").get_value<int>());
+
+ CPPUNIT_ASSERT_EQUAL(size_t(4), aTree.get_child("slides").size());
+
+ // Slide Index 0
+ {
+ const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 0);
+ CPPUNIT_ASSERT_EQUAL(0, rChild.get_child("index").get_value<int>());
+ CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>());
+
+ CPPUNIT_ASSERT(has_child(rChild, "hash"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPage"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible"));
+ }
+
+ // Slide Index 1
+ {
+ const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 1);
+ CPPUNIT_ASSERT_EQUAL(1, rChild.get_child("index").get_value<int>());
+ CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>());
+
+ CPPUNIT_ASSERT(has_child(rChild, "hash"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPage"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible"));
+ }
+
+ // Slide Index 2
+ {
+ const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 2);
+ CPPUNIT_ASSERT_EQUAL(2, rChild.get_child("index").get_value<int>());
+ CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>());
+
+ CPPUNIT_ASSERT(has_child(rChild, "hash"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPage"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible"));
+ }
+
+ // Slide Index 3 - Hidden
+
+ // Slide Index 4
+ {
+ const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 3);
+ CPPUNIT_ASSERT_EQUAL(4, rChild.get_child("index").get_value<int>());
+ CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>());
+
+ CPPUNIT_ASSERT(has_child(rChild, "hash"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPage"));
+ CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible"));
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */