tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sw / qa / uitest / writer_tests2 / bookmark.py
blob87f19ceea3530463aab60297855b25d632c45299
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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, type_text
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 #test bookmark dialog
14 class bookmarkDialog(UITestCase):
16 def test_bookmark_dialog(self):
18 with self.ui_test.create_doc_in_start_center("writer"):
20 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
21 pass
23 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert") as xBookDlg:
24 xBmk = xBookDlg.getChild("bookmarks")
25 self.assertEqual(get_state_as_dict(xBmk)["VisibleCount"], "1") #check for 1st bookmark exist
27 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close"):
28 pass
30 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
31 xBmk = xBookDlg.getChild("bookmarks")
32 self.assertEqual(get_state_as_dict(xBmk)["VisibleCount"], "2") #check for 2 bookmarks
34 #now delete one bookmark
35 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
36 xBmk = xBookDlg.getChild("bookmarks")
37 xSecondListEntry = xBmk.getChild("1") # select second bookmark
38 xSecondListEntry.executeAction("SELECT", tuple())
39 xDelBtn = xBookDlg.getChild("delete")
40 xDelBtn.executeAction("CLICK", tuple()) # delete one bookmark
42 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
43 xBmk2 = xBookDlg.getChild("bookmarks")
44 self.assertEqual(get_state_as_dict(xBmk2)["VisibleCount"], "1") #check for 1 bookmark
47 def test_bookmark_dialog_rename(self):
48 with self.ui_test.create_doc_in_start_center("writer"):
50 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
51 pass
53 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
54 xBmk = xBookDlg.getChild("bookmarks")
55 xFirstListEntry = xBmk.getChild("0") # select first bookmark
56 xFirstListEntry.executeAction("SELECT", tuple())
57 xRenameBtn = xBookDlg.getChild("rename")
59 with self.ui_test.execute_blocking_action(xRenameBtn.executeAction, args=('CLICK', ())) as dialog:
60 xNewNameTxt=dialog.getChild("entry")
61 xNewNameTxt.executeAction("TYPE", mkPropertyValues({"TEXT":"newname"}))
63 x1stListEntry = xBmk.getChild("O") # select first bookmark - name "newname"
64 x1stListEntry.executeAction("SELECT", tuple())
66 self.assertEqual(get_state_as_dict(x1stListEntry)["Text"], "1\tnewname\t\tNo\t") #check the new name "newname"
70 def test_bookmark_dialog_goto(self):
71 with self.ui_test.create_doc_in_start_center("writer"):
72 xWriterDoc = self.xUITest.getTopFocusWindow()
73 xWriterEdit = xWriterDoc.getChild("writer_edit")
75 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
76 pass
78 type_text(xWriterEdit, "Test for bookmark")
79 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
80 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
81 type_text(xWriterEdit, "Test2 for bookmark")
83 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
84 pass
86 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
87 xBmk = xBookDlg.getChild("bookmarks")
88 xFirstListEntry = xBmk.getChild("0") # select first bookmark
89 xFirstListEntry.executeAction("SELECT", tuple())
90 xGoToBtn = xBookDlg.getChild("goto")
91 xGoToBtn.executeAction("CLICK", tuple()) # goto 1st bookmark
93 def test_bookmark_dialog_edittext(self):
94 with self.ui_test.create_doc_in_start_center("writer") as xDoc:
96 xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False)
97 self.xUITest.executeCommand(".uno:SelectAll")
99 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
100 pass
102 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
103 xBmk = xBookDlg.getChild("bookmarks")
104 xFirstListEntry = xBmk.getChild("0") # select first bookmark
105 xFirstListEntry.executeAction("SELECT", tuple())
106 xEditBtn = xBookDlg.getChild("edittext")
108 xEditBtn.executeAction('CLICK', ())
110 # this does not work - the Edit widget has the focus but it's not forwarded
111 # xBookDlg.executeAction("TYPE", mkPropertyValues({"TEXT":"fubar"}))
112 # xBookDlg.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
113 # this did not work previously but now works due to explicit
114 # forwarding in TreeListUIObject::execute()
115 xBmk.executeAction("TYPE", mkPropertyValues({"TEXT":"fubar"}))
116 xBmk.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
118 x1stListEntry = xBmk.getChild("O") # select first bookmark
119 x1stListEntry.executeAction("SELECT", tuple())
121 self.assertEqual(xDoc.Text.String, "fubar")
122 self.assertEqual(get_state_as_dict(x1stListEntry)["Text"], "1\tBookmark 1\tfubar\tNo\t")
124 def test_bookmark_dialog_hidden_from_DOCX_import(self):
125 with self.ui_test.load_file(get_url_for_data_file("tdf95495.docx")):
127 # check Hidden field of the imported hidden bookmarks
128 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
129 xBmk = xBookDlg.getChild("bookmarks")
130 xFirstListEntry = xBmk.getChild("0") # select first bookmark
132 # _Toc bookmark had Hidden == "No"
133 self.assertEqual(get_state_as_dict(xFirstListEntry)["Text"], "1\t_Toc448303248\t A. Comment-Based Help A.1 Introduction…\tYes\t")
135 xSecondListEntry = xBmk.getChild("1") # select second bookmark
137 # _Rec bookmark had Hidden == "No"
138 self.assertEqual(get_state_as_dict(xSecondListEntry)["Text"], "1\t_Ref463365573\t A. Comment-Based Help A.1 Introduction…\tYes\t")
140 # insert a new bookmark with the default name
141 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
142 pass
144 # check Hidden field of the newly inserted bookmark
145 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg:
146 xBmk = xBookDlg.getChild("bookmarks")
147 xFirstListEntry = xBmk.getChild("0") # select first bookmark
148 xFirstListEntry.executeAction("SELECT", tuple())
150 # Newly inserted bookmarks get Hidden = "No"
151 self.assertEqual(get_state_as_dict(xFirstListEntry)["Text"], "1\tBookmark 1\t\tNo\t")
153 # vim: set shiftwidth=4 softtabstop=4 expandtab: