Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / test / qa / cppunit / dialog.cxx
blobc69f41b58d7c23f3ff572382dafaf1bdc950badb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <test/a11y/accessibletestbase.hxx>
12 // FIXME: dialog API doesn't work on macos yet
13 #if !defined(MACOSX)
15 /* Checks an unexpected dialog opening (instead of the expected one) is properly caught, as it would
16 * otherwise block the test potentially indefinitely */
17 CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, SelfTestIncorrectDialog)
19 load(u"private:factory/swriter");
21 auto dialogWaiter = awaitDialog(u"This Dialog Does Not Exist", [](Dialog&) {
22 CPPUNIT_ASSERT_MESSAGE("This code should not be reached", false);
23 });
25 CPPUNIT_ASSERT(activateMenuItem(u"Insert", u"Section..."));
26 /* Make sure an incorrect dialog popping up is caught and raises. The exception is thrown in
27 * waitEndDialog() for consistency even though the error itself is likely to have been triggered
28 * by the activateMenuItem() call above */
29 CPPUNIT_ASSERT_THROW(dialogWaiter->waitEndDialog(), css::uno::RuntimeException);
32 /* Checks that an exception in the dialog callback code is properly handled and won't disturb
33 * subsequent tests if caught -- especially that DialogWaiter::waitEndDialog() won't timeout. */
34 CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, SelfTestThrowInDialogCallback)
36 load(u"private:factory/swriter");
38 class DummyException : public std::exception
42 auto dialogWaiter = awaitDialog(u"Hyperlink", [](Dialog&) { throw DummyException(); });
44 CPPUNIT_ASSERT(activateMenuItem(u"Insert", u"Hyperlink..."));
45 CPPUNIT_ASSERT_THROW(dialogWaiter->waitEndDialog(), DummyException);
48 // Checks timeout if dialog does not show up as expected
49 CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, SelfTestNoDialog)
51 load(u"private:factory/swriter");
53 auto dialogWaiter = awaitDialog(u"This Dialog Did Not Show Up", [](Dialog&) {
54 CPPUNIT_ASSERT_MESSAGE("This code should not be reached", false);
55 });
57 // as we don't actually call any dialog up, this should fail after a timeout
58 CPPUNIT_ASSERT(!dialogWaiter->waitEndDialog());
61 #endif //defined(MACOSX)
63 CPPUNIT_PLUGIN_IMPLEMENT();
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */