1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
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/.
10 from uitest
.framework
import UITestCase
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.calc
import enter_text_to_cell
14 class calcSheetDelete(UITestCase
):
16 def test_tdf114228_insert_and_delete_sheet(self
):
18 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
20 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
21 xGridWindow
= xCalcDoc
.getChild("grid_window")
23 xGridWindow
.executeAction("SELECT", mkPropertyValues({"CELL": "L12"}))
24 nrSheets
= document
.Sheets
.getCount() #default number
26 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
29 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 1)
31 with self
.ui_test
.execute_dialog_through_command(".uno:Remove", close_button
="yes"):
33 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
34 xToolkit
.processEventsToIdle()
36 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
37 self
.xUITest
.executeCommand(".uno:Undo")
38 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 1)
39 self
.xUITest
.executeCommand(".uno:Redo")
40 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
43 def test_tdf43078_insert_and_delete_sheet_insert_text(self
):
45 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
47 nrSheets
= document
.Sheets
.getCount() #default number of sheets
49 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
52 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
54 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
55 xToolkit
.processEventsToIdle()
57 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 2)
58 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
59 xGridWindow
= xCalcDoc
.getChild("grid_window")
60 enter_text_to_cell(xGridWindow
, "B2", "abcd")
62 with self
.ui_test
.execute_dialog_through_command(".uno:Remove", close_button
="yes"):
65 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 1)
66 self
.xUITest
.executeCommand(".uno:Undo")
67 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 2)
68 self
.xUITest
.executeCommand(".uno:Redo")
69 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 1)
72 def test_delete_more_sheets_at_once(self
):
74 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
75 nrSheets
= document
.Sheets
.getCount() #default number
78 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
81 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 6)
85 self
.xUITest
.executeCommand(".uno:JumpToNextTableSel") #select next sheet
88 with self
.ui_test
.execute_dialog_through_command(".uno:Remove", close_button
="yes"):
91 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
92 xToolkit
.processEventsToIdle()
93 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
94 self
.xUITest
.executeCommand(".uno:Undo")
95 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 6)
96 self
.xUITest
.executeCommand(".uno:Redo")
97 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
100 def test_tdf105105_delete_lots_of_sheets_at_once(self
):
102 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
103 nrSheets
= document
.Sheets
.getCount() #default number
106 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
109 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
110 xToolkit
.processEventsToIdle()
111 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 100)
115 self
.xUITest
.executeCommand(".uno:JumpToNextTableSel") #select next sheet
118 with self
.ui_test
.execute_dialog_through_command(".uno:Remove", close_button
="yes"):
121 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
122 self
.xUITest
.executeCommand(".uno:Undo")
123 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
+ 100)
124 self
.xUITest
.executeCommand(".uno:Redo")
125 self
.assertEqual(document
.Sheets
.getCount(), nrSheets
)
127 # vim: set shiftwidth=4 softtabstop=4 expandtab: