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 import org
.libreoffice
.unotest
11 from uitest
.framework
import UITestCase
12 from uitest
.uihelper
.common
import get_url_for_data_file
14 class tdf106899(UITestCase
):
16 def test_tdf106899_alphabetical_index_utf8(self
):
17 # Copy concordance file containing an utf8 index entry
18 org
.libreoffice
.unotest
.makeCopyFromTDOC("tdf106899.sdi")
19 with self
.ui_test
.load_file(get_url_for_data_file("tdf106899.odt")) as document
:
21 # Update the alphabetical index and check if it contains the utf8 index entry
22 xDocumentIndexes
= document
.DocumentIndexes
23 self
.assertEqual(len(xDocumentIndexes
), 1)
24 self
.assertEqual(xDocumentIndexes
.hasByName("Alphabetical Index1"), True)
25 xDocumentIndex
= xDocumentIndexes
.getByName("Alphabetical Index1")
26 xIndexAnchor
= xDocumentIndex
.getAnchor()
27 self
.assertEqual("Nguyễn Khánh" in xIndexAnchor
.getString(), False)
29 # TODO Bug Report - Refresh of the index does only work using .uno:UpdateAllIndexes
30 # It does not work with xDocumentIndex.refresh() nor with xDocumentIndex.update()
31 self
.xUITest
.executeCommand(".uno:UpdateAllIndexes")
33 # TODO Bug Report - Retrieving the text of the updated index only works using the cursor
34 # It does not work with xIndexAnchor.getString()
35 xCursor
= document
.getText().createTextCursor()
36 xCursor
.gotoRange(xDocumentIndex
.getAnchor().getEnd(), False)
37 xCursor
.gotoStartOfParagraph(True)
39 # Without the fix in place the index does not contain the utf8 index entry
40 self
.assertEqual("Nguyễn Khánh" in xCursor
.getString(), True)
42 # vim: set shiftwidth=4 softtabstop=4 expandtab: