2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 from org
.libreoffice
.unotest
import UnoInProcess
13 from com
.sun
.star
.util
import XRefreshListener
19 class XRefreshListenerExtended(unohelper
.Base
, XRefreshListener
):
21 def refreshed(self
, Event
):
26 def disposing(self
, event
):
30 class XRefreshable(unittest
.TestCase
):
34 cls
._uno
= UnoInProcess()
38 def tearDownClass(cls
):
44 xDoc
= self
._uno
.openEmptyWriterDoc()
46 # attempt to add/remove none
47 xDoc
.addRefreshListener(None)
48 xDoc
.removeRefreshListener(None)
50 # refresh without listeners
54 def test_refresh(self
):
58 xDoc
= self
._uno
.openEmptyWriterDoc()
59 xListener
= XRefreshListenerExtended()
60 xDoc
.addRefreshListener(xListener
)
62 xDoc
.removeRefreshListener(xListener
)
63 self
.assertEqual(1, refreshed
)
65 self
.assertEqual(1, refreshed
)
68 def test_refreshTwice(self
):
72 xDoc
= self
._uno
.openEmptyWriterDoc()
73 xListener
= XRefreshListenerExtended()
74 xDoc
.addRefreshListener(xListener
)
77 xDoc
.removeRefreshListener(xListener
)
78 self
.assertEqual(2, refreshed
)
80 self
.assertEqual(2, refreshed
)
83 def test_DoubleInstances(self
):
87 xDoc
= self
._uno
.openEmptyWriterDoc()
88 xListener
= XRefreshListenerExtended()
90 xDoc
.addRefreshListener(xListener
)
91 xDoc
.addRefreshListener(xListener
)
92 xDoc
.addRefreshListener(xListener
)
96 self
.assertEqual(3*2, refreshed
)
99 xDoc
.removeRefreshListener(xListener
)
101 # two instances should remain in the list
102 self
.assertEqual(2, refreshed
)
107 if __name__
== '__main__':
110 # vim: set shiftwidth=4 softtabstop=4 expandtab: