summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2020-05-07 12:25:51 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2020-05-09 09:36:16 +0200
commiteae46152b4a59dc995d165dbcd79169f72e47494 (patch)
tree0bac0ed1d1725113c6edb0253afdb71d08c8da60 /sw/qa/extras
parent5beba4976f09c3b5f6e9adf6ba03c6db41639518 (diff)
lok: MSForms: add a test case about editing drop down form field.
Change-Id: I926b322d3af3047fc72c6ee9b923bc4435111328
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/tiledrendering/data/drop_down_form_field2.odtbin0 -> 8596 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx63
2 files changed, 62 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/data/drop_down_form_field2.odt b/sw/qa/extras/tiledrendering/data/drop_down_form_field2.odt
new file mode 100644
index 000000000000..7793aff4e91b
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/drop_down_form_field2.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 8ef00b63908f..884f52674213 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -46,6 +46,7 @@
#include <svx/svxids.hrc>
#include <flddat.hxx>
#include <basesh.hxx>
+#include <vcl/ITiledRenderable.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/";
@@ -124,6 +125,7 @@ public:
void testRedlineNotificationDuringSave();
void testFieldmark();
void testDropDownFormFieldButton();
+ void testDropDownFormFieldButtonEditing();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -189,6 +191,7 @@ public:
CPPUNIT_TEST(testRedlineNotificationDuringSave);
CPPUNIT_TEST(testFieldmark);
CPPUNIT_TEST(testDropDownFormFieldButton);
+ CPPUNIT_TEST(testDropDownFormFieldButtonEditing);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2536,7 +2539,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButton()
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
CPPUNIT_ASSERT(m_aFormFieldButton.isEmpty());
- // Do a tile rendering to trigger the button message with a valide text area
+ // Do a tile rendering to trigger the button message with a valid text area
size_t nCanvasWidth = 1024;
size_t nCanvasHeight = 512;
std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
@@ -2594,6 +2597,64 @@ void SwTiledRenderingTest::testDropDownFormFieldButton()
}
}
+void SwTiledRenderingTest::testDropDownFormFieldButtonEditing()
+{
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("drop_down_form_field2.odt");
+ pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
+
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+
+ // Move the cursor to trigger displaying of the field button.
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ CPPUNIT_ASSERT(m_aFormFieldButton.isEmpty());
+
+ // Do a tile rendering to trigger the button message with a valid text area
+ size_t nCanvasWidth = 1024;
+ size_t nCanvasHeight = 512;
+ std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
+ ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
+ pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight),
+ Fraction(1.0), Point(), aPixmap.data());
+ pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+ /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
+
+ // The item with the index '1' is selected by default
+ CPPUNIT_ASSERT(!m_aFormFieldButton.isEmpty());
+ {
+ std::stringstream aStream(m_aFormFieldButton.getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ OString sSelected = aTree.get_child("params").get_child("selected").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("1"), sSelected);
+ }
+ m_aFormFieldButton = "";
+
+ // Trigger a form field event to select a different item.
+ vcl::ITiledRenderable::StringMap aArguments;
+ aArguments["type"] = "drop-down";
+ aArguments["cmd"] = "selected";
+ aArguments["data"] = "3";
+ pXTextDocument->executeFromFieldEvent(aArguments);
+
+ // Do a tile rendering to trigger the button message.
+ pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+ /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
+
+ CPPUNIT_ASSERT(!m_aFormFieldButton.isEmpty());
+ {
+ std::stringstream aStream(m_aFormFieldButton.getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ OString sSelected = aTree.get_child("params").get_child("selected").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("3"), sSelected);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();