sw floattable: fix current page number when editing document with a split fly
UITest_writer_tests6's tdf124675.tdf124675.test_tdf124675_crash_moving_SwTextFrame_previous_page failed in the SW_FORCE_FLY_SPLIT=1 case, since the current page after typing was 3, not 2. It seems this change is wanted, since the total page count increases by 2, so it's consistent that the current page increases similarly with typing. Also, repeating the UITest in Word (after positioning the cursor at the top paragraph in the document) also produces page 3 as the current page. Fix the problem by locally enabling split flys for this test and then we can assert that we match Word. This requires a new context manager, but that set_config() is really similar to other context managers in the class that return no value. The original purpose of the test was to make sure we don't crash, anyway. Change-Id: Id0dfde23a8726c8799950a6e4fdd1d85f135eafc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149315 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
b1851d1afe
commit
015da04a8f
2 changed files with 27 additions and 13 deletions
|
@ -14,23 +14,24 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
|
|||
|
||||
class tdf124675(UITestCase):
|
||||
def test_tdf124675_crash_moving_SwTextFrame_previous_page(self):
|
||||
with self.ui_test.load_file(get_url_for_data_file("tdf124675.docx")) as writer_doc:
|
||||
xWriterDoc = self.xUITest.getTopFocusWindow()
|
||||
xWriterEdit = xWriterDoc.getChild("writer_edit")
|
||||
with self.ui_test.set_config('/org.openoffice.Office.Writer/Filter/Import/DOCX/ImportFloatingTableAsSplitFly', True):
|
||||
with self.ui_test.load_file(get_url_for_data_file("tdf124675.docx")) as writer_doc:
|
||||
xWriterDoc = self.xUITest.getTopFocusWindow()
|
||||
xWriterEdit = xWriterDoc.getChild("writer_edit")
|
||||
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 2)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1")
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 2)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1")
|
||||
|
||||
for i in range(52):
|
||||
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
||||
for i in range(52):
|
||||
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
||||
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 4)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2")
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 4)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3")
|
||||
|
||||
for i in range(52):
|
||||
self.xUITest.executeCommand(".uno:Undo")
|
||||
for i in range(52):
|
||||
self.xUITest.executeCommand(".uno:Undo")
|
||||
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 2)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1")
|
||||
self.assertEqual(writer_doc.CurrentController.PageCount, 2)
|
||||
self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1")
|
||||
|
||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||
|
|
|
@ -100,6 +100,19 @@ class UITest(object):
|
|||
finally:
|
||||
self.close_doc()
|
||||
|
||||
# Resets the setting to the old value at exit
|
||||
@contextmanager
|
||||
def set_config(self, path, new_value):
|
||||
xChanges = self._xContext.ServiceManager.createInstanceWithArgumentsAndContext('com.sun.star.configuration.ReadWriteAccess', ("",), self._xContext)
|
||||
try:
|
||||
old_value = xChanges.getByHierarchicalName(path)
|
||||
xChanges.replaceByHierarchicalName(path, new_value)
|
||||
xChanges.commitChanges()
|
||||
yield
|
||||
finally:
|
||||
xChanges.replaceByHierarchicalName(path, old_value)
|
||||
xChanges.commitChanges()
|
||||
|
||||
# Calls UITest.close_doc at exit
|
||||
@contextmanager
|
||||
def load_empty_file(self, app):
|
||||
|
|
Loading…
Reference in a new issue