| 1 |
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 5 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
# |
| 9 |
|
| 10 |
from uitest.framework import UITestCase |
| 11 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 12 |
|
| 13 |
class tdf129346(UITestCase): |
| 14 |
|
| 15 |
def test_run(self): |
| 16 |
with self.ui_test.create_doc_in_start_center("impress") as document: |
| 17 |
xTemplateDlg = self.xUITest.getTopFocusWindow() |
| 18 |
xCancelBtn = xTemplateDlg.getChild("close") |
| 19 |
self.ui_test.close_dialog_through_button(xCancelBtn) |
| 20 |
|
| 21 |
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') |
| 22 |
|
| 23 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) |
| 24 |
self.xUITest.executeCommand(".uno:DuplicatePage") |
| 25 |
xToolkit.processEventsToIdle() |
| 26 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) |
| 27 |
|
| 28 |
xDoc = self.xUITest.getTopFocusWindow() |
| 29 |
xEdit = xDoc.getChild("impress_win") |
| 30 |
# Type "test" into the text box |
| 31 |
xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) |
| 32 |
# Go to Page 1, which also forces to end edit box |
| 33 |
xEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"})) |
| 34 |
xToolkit.processEventsToIdle() |
| 35 |
|
| 36 |
# We should be at Page 1 |
| 37 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) |
| 38 |
|
| 39 |
# Undo sends us to Page 2 and undo-es the text edit |
| 40 |
self.xUITest.executeCommand(".uno:Undo") |
| 41 |
xToolkit.processEventsToIdle() |
| 42 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) |
| 43 |
|
| 44 |
# Undo sends us to page 1 and undo-es command ".uno:DuplicatePage" |
| 45 |
self.xUITest.executeCommand(".uno:Undo") |
| 46 |
xToolkit.processEventsToIdle() |
| 47 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) |
| 48 |
|
| 49 |
# Redo ".uno:DuplicatePage" - we go to Page 2 |
| 50 |
self.xUITest.executeCommand(".uno:Redo") |
| 51 |
xToolkit.processEventsToIdle() |
| 52 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) |
| 53 |
|
| 54 |
# Redo text edit |
| 55 |
self.xUITest.executeCommand(".uno:Redo") |
| 56 |
|
| 57 |
xDoc = self.xUITest.getTopFocusWindow() |
| 58 |
xEdit = xDoc.getChild("impress_win") |
| 59 |
xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) |
| 60 |
|
| 61 |
xToolkit.processEventsToIdle() |
| 62 |
#Without the accompanying fix in place, it would fail with AssertionError: 2 != 1 |
| 63 |
self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) |
| 64 |
|
| 65 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |