Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / uitest / writer_tests / bookmark.py
blob33f88d594c7a1d27d18a9f6253740e6c73b0191b
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 import time
12 from uitest.uihelper.common import get_state_as_dict, type_text
13 from libreoffice.uno.propertyvalue import mkPropertyValues
14 from uitest.debug import sleep
15 #test bookmark dialog
16 class bookmarkDialog(UITestCase):
18 def test_bookmark_dialog(self):
20 self.ui_test.create_doc_in_start_center("writer")
22 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
23 xBookDlg = self.xUITest.getTopFocusWindow()
24 xInsertBtn = xBookDlg.getChild("insert")
25 xInsertBtn.executeAction("CLICK", tuple()) # first bookmark
27 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
28 xBookDlg = self.xUITest.getTopFocusWindow()
29 xInsertBtn = xBookDlg.getChild("insert")
30 xBmk = xBookDlg.getChild("bookmarks")
31 self.assertEqual(get_state_as_dict(xBmk)["VisibleCount"], "1") #check for 1st bookmark exist
32 xInsertBtn.executeAction("CLICK", tuple()) # add 2nd bookmark
34 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
35 xBookDlg = self.xUITest.getTopFocusWindow()
36 xCloseBtn = xBookDlg.getChild("close")
37 xCloseBtn.executeAction("CLICK", tuple()) # close
39 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
40 xBookDlg = self.xUITest.getTopFocusWindow()
41 xBmk = xBookDlg.getChild("bookmarks")
42 self.assertEqual(get_state_as_dict(xBmk)["VisibleCount"], "2") #check for 2 bookmarks
43 xCloseBtn = xBookDlg.getChild("close")
44 xCloseBtn.executeAction("CLICK", tuple()) # close dialog
46 #now delete one bookmark
47 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
48 xBookDlg = self.xUITest.getTopFocusWindow()
49 xBmk = xBookDlg.getChild("bookmarks")
50 xSecondListEntry = xBmk.getChild("1") # select second bookmark
51 xSecondListEntry.executeAction("SELECT", tuple())
52 xDelBtn = xBookDlg.getChild("delete")
53 xDelBtn.executeAction("CLICK", tuple()) # delete one bookmark
54 xCloseBtn = xBookDlg.getChild("close")
55 xCloseBtn.executeAction("CLICK", tuple()) # close dialog
57 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
58 xBookDlg = self.xUITest.getTopFocusWindow()
59 xCloseBtn = xBookDlg.getChild("close")
60 xBmk2 = xBookDlg.getChild("bookmarks")
61 self.assertEqual(get_state_as_dict(xBmk2)["VisibleCount"], "1") #check for 1 bookmark
62 xCloseBtn.executeAction("CLICK", tuple()) # now we have only 1 bookmark
64 self.ui_test.close_doc()
68 def test_bookmark_dialog_rename(self):
69 self.ui_test.create_doc_in_start_center("writer")
71 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
72 xBookDlg = self.xUITest.getTopFocusWindow()
73 xInsertBtn = xBookDlg.getChild("insert")
74 xInsertBtn.executeAction("CLICK", tuple()) # first bookmark
76 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
77 xBookDlg = self.xUITest.getTopFocusWindow()
78 xBmk = xBookDlg.getChild("bookmarks")
79 xFirstListEntry = xBmk.getChild("0") # select first bookmark
80 xFirstListEntry.executeAction("SELECT", tuple())
81 xRenameBtn = xBookDlg.getChild("rename")
83 def handle_rename_dlg(dialog): #handle rename dialog - need special handling
85 xNewNameTxt=dialog.getChild("entry")
86 xNewNameTxt.executeAction("TYPE", mkPropertyValues({"TEXT":"newname"}))
87 xOKBtn = dialog.getChild("ok")
88 self.ui_test.close_dialog_through_button(xOKBtn)
90 self.ui_test.execute_blocking_action(xRenameBtn.executeAction, args=('CLICK', ()),
91 dialog_handler=handle_rename_dlg) #close rename dialog with OK button
93 xBookDlg = self.xUITest.getTopFocusWindow()
94 x1stListEntry = xBmk.getChild("O") # select first bookmark - name "newname"
95 x1stListEntry.executeAction("SELECT", tuple())
97 self.assertEqual(get_state_as_dict(x1stListEntry)["Text"], "1\tnewname\t") #check the new name "newname"
99 xCloseBtn = xBookDlg.getChild("close")
100 self.ui_test.close_dialog_through_button(xCloseBtn)
102 self.ui_test.close_doc()
104 def test_bookmark_dialog_goto(self):
105 self.ui_test.create_doc_in_start_center("writer")
106 xWriterDoc = self.xUITest.getTopFocusWindow()
107 xWriterEdit = xWriterDoc.getChild("writer_edit")
109 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
110 xBookDlg = self.xUITest.getTopFocusWindow()
111 xInsertBtn = xBookDlg.getChild("insert")
112 xInsertBtn.executeAction("CLICK", tuple()) # first bookmark
115 type_text(xWriterEdit, "Test for bookmark")
116 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
117 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
118 type_text(xWriterEdit, "Test2 for bookmark")
121 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
122 xBookDlg = self.xUITest.getTopFocusWindow()
123 xInsertBtn = xBookDlg.getChild("insert")
124 xInsertBtn.executeAction("CLICK", tuple()) # second bookmark
126 self.ui_test.execute_dialog_through_command(".uno:InsertBookmark")
127 xBookDlg = self.xUITest.getTopFocusWindow()
128 xBmk = xBookDlg.getChild("bookmarks")
129 xFirstListEntry = xBmk.getChild("0") # select first bookmark
130 xFirstListEntry.executeAction("SELECT", tuple())
131 xGoToBtn = xBookDlg.getChild("goto")
132 xGoToBtn.executeAction("CLICK", tuple()) # goto 1st bookmark
133 xCloseBtn = xBookDlg.getChild("close")
134 self.ui_test.close_dialog_through_button(xCloseBtn)
137 self.ui_test.close_doc()
139 # vim: set shiftwidth=4 softtabstop=4 expandtab: