1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
9 from libreoffice
.uno
.eventlistener
import EventListener
11 from uitest
.framework
import UITestCase
13 from uitest
.debug
import sleep
16 import org
.libreoffice
.unotest
20 def get_url_for_data_file(file_name
):
21 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
23 class HandleFiles(UITestCase
):
25 def test_load_file(self
):
27 calc_file
= self
.ui_test
.load_file(get_url_for_data_file("test.ods"))
29 calc_file2
= self
.ui_test
.load_file(get_url_for_data_file("test2.ods"))
31 frames
= self
.ui_test
.get_frames()
32 self
.assertEqual(len(frames
), 2)
34 self
.ui_test
.close_doc()
36 frames
= self
.ui_test
.get_frames()
37 self
.assertEqual(len(frames
), 1)
39 # this is currently still necessary as otherwise
40 # the command is not forwarded to the correct frame
41 # TODO: provide an additional event that we can use
42 # and get rid of the sleep
45 self
.ui_test
.close_doc()
47 def test_select_frame(self
):
48 calc_file
= self
.ui_test
.load_file(get_url_for_data_file("test.ods"))
50 calc_file2
= self
.ui_test
.load_file(get_url_for_data_file("test2.ods"))
51 frames
= self
.ui_test
.get_frames()
52 self
.assertEqual(len(frames
), 2)
55 self
.ui_test
.close_doc()
57 frames
= self
.ui_test
.get_frames()
58 self
.assertEqual(len(frames
), 1)
60 self
.assertTrue(frames
[0].getTitle().startswith("test2.ods"))
62 # vim: set shiftwidth=4 softtabstop=4 expandtab: