Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / uitest / calc_tests / calcSheetDelete.py
blob3e9da3f516d476ea5a1d5f68b008498b4a72b488
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"):
27 pass
29 self.assertEqual(document.Sheets.getCount(), nrSheets + 1)
31 with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"):
32 pass
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"):
50 pass
52 with self.ui_test.execute_dialog_through_command(".uno:Insert"):
53 pass
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"):
63 pass
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
76 i = 0
77 while i < 6:
78 with self.ui_test.execute_dialog_through_command(".uno:Insert"):
79 pass
80 i = i + 1
81 self.assertEqual(document.Sheets.getCount(), nrSheets + 6)
83 i = 0
84 while i < 5:
85 self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet
86 i = i + 1
88 with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"):
89 pass
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
104 i = 0
105 while i < 100:
106 with self.ui_test.execute_dialog_through_command(".uno:Insert"):
107 pass
108 i = i + 1
109 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
110 xToolkit.processEventsToIdle()
111 self.assertEqual(document.Sheets.getCount(), nrSheets + 100)
113 i = 0
114 while i < 99:
115 self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet
116 i = i + 1
118 with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"):
119 pass
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: