Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / python / check_flies.py
blob6353ccda150db4bdd2f81bc87290c661d923cccb
1 '''
2 This is file is part of the LibreOffice project.
4 This Source Code Form is subject to the terms of the Mozilla Public
5 License, v. 2.0. If a copy of the MPL was not distributed with this
6 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 This file incorporates work covered by the following license notice:
10 Licensed to the Apache Software Foundation (ASF) under one or more
11 contributor license agreements. See the NOTICE file distributed
12 with this work for additional information regarding copyright
13 ownership. The ASF licenses this file to you under the Apache
14 License, Version 2.0 (the "License"); you may not use this file
15 except in compliance with the License. You may obtain a copy of
16 the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 '''
19 from org.libreoffice.unotest import UnoInProcess
20 import unittest
23 class CheckFlies(unittest.TestCase):
25 @classmethod
26 def setUpClass(cls):
27 cls._uno = UnoInProcess()
28 cls._uno.setUp()
29 cls.document = cls._uno.openDocFromTDOC("CheckFlies.odt")
31 @classmethod
32 def tearDownClass(cls):
33 cls._uno.tearDown()
35 def test_checkFlies(self):
36 xTFS = self.__class__.document
37 self.checkTextFrames(xTFS)
38 xTGOS = self.__class__.document
39 self.checkGraphicFrames(xTGOS)
40 xTEOS = self.__class__.document
41 self.checkEmbeddedFrames(xTEOS)
43 def checkEmbeddedFrames(self, xTGOS):
44 vExpectedEmbeddedFrames = ["Object1"]
45 nEmbeddedFrames = len(vExpectedEmbeddedFrames)
46 xEmbeddedFrames = xTGOS.getEmbeddedObjects()
47 nCurrentFrameIdx = 0
49 print (xEmbeddedFrames)
50 for sFrameName in xEmbeddedFrames.getElementNames():
51 vExpectedEmbeddedFrames.remove(sFrameName)
52 # raises ValueError if not found
53 print (sFrameName)
54 xEmbeddedFrames[sFrameName]
55 self.assertTrue(xEmbeddedFrames.hasByName(sFrameName),
56 "Could not find embedded frame by name.")
58 self.assertTrue(not(vExpectedEmbeddedFrames),
59 "Missing expected embedded frames.")
61 xEmbeddedFramesIdx = xEmbeddedFrames
63 self.assertEqual(nEmbeddedFrames, len(xEmbeddedFramesIdx),
64 "Unexpected number of embedded frames reported")
66 for nCurrentFrameIdx in range(len(xEmbeddedFramesIdx)):
67 xEmbeddedFramesIdx[nCurrentFrameIdx]
69 def checkGraphicFrames(self, xTGOS):
70 vExpectedGraphicFrames = ["graphics1"]
71 nGraphicFrames = len(vExpectedGraphicFrames)
72 xGraphicFrames = xTGOS.getGraphicObjects()
73 nCurrentFrameIdx = 0
74 for sFrameName in xGraphicFrames.getElementNames():
75 vExpectedGraphicFrames.remove(sFrameName)
76 # raises ValueError if not found
77 xGraphicFrames[sFrameName]
78 self.assertTrue(
79 sFrameName in xGraphicFrames,
80 "Could not find graphics frame by name.")
81 self.assertTrue(
82 not(vExpectedGraphicFrames),
83 "Missing expected graphics frames.")
85 xGraphicFramesIdx = xGraphicFrames
86 self.assertEqual(nGraphicFrames, len(xGraphicFramesIdx),
87 "Unexpected number of graphics frames reported")
89 for nCurrentFrameIdx in range(len(xGraphicFramesIdx)):
90 xGraphicFramesIdx[nCurrentFrameIdx]
92 def checkTextFrames(self, xTFS):
93 vExpectedTextFrames = ["Frame1", "Frame2"]
94 nTextFrames = len(vExpectedTextFrames)
95 xTextFrames = xTFS.getTextFrames()
96 nCurrentFrameIdx = 0
98 for sFrameName in xTextFrames.getElementNames():
99 vExpectedTextFrames.remove(sFrameName)
100 # raises ValueError if not found
101 xTextFrames[sFrameName]
102 self.assertTrue(
103 sFrameName in xTextFrames,
104 "Could not find text frame by name.")
106 self.assertTrue(
107 not(vExpectedTextFrames), "Missing expected text frames.")
109 xTextFramesIdx = xTextFrames
111 self.assertEqual(nTextFrames, len(xTextFrames),
112 "Unexpected number of text frames reported")
114 for nCurrentFrameIdx in range(len(xTextFramesIdx)):
115 xTextFramesIdx[nCurrentFrameIdx]
118 if __name__ == "__main__":
119 unittest.main()