| 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. |
| 4 |
* |
| 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 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include <test/testdllapi.hxx> |
| 23 |
|
| 24 |
#include <com/sun/star/uno/Reference.hxx> |
| 25 |
#include <com/sun/star/accessibility/XAccessibleContext.hpp> |
| 26 |
#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> |
| 27 |
#include <vcl/window.hxx> |
| 28 |
|
| 29 |
class OOO_DLLPUBLIC_TEST XAccessibleEventBroadcasterTester |
| 30 |
{ |
| 31 |
private: |
| 32 |
const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster> mxBroadcaster; |
| 33 |
std::function<void()> m_aFireEventFunc; |
| 34 |
|
| 35 |
static bool isTransient( |
| 36 |
const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster>& xBroadcaster); |
| 37 |
static bool |
| 38 |
isTransient(const css::uno::Reference<css::accessibility::XAccessibleContext>& xCtx); |
| 39 |
|
| 40 |
void fireEvent(); |
| 41 |
|
| 42 |
public: |
| 43 |
/** |
| 44 |
* Creates an XAccessibleEventBroadcasterTester that will call @c rFireEventFunc to generate |
| 45 |
* an event. |
| 46 |
* @param xBroadcaster The XAccessibleEventBroadcaster implementation to test. |
| 47 |
* @param rFireEventFunc Function that triggers an accessible event for @c xBroadcaster. |
| 48 |
*/ |
| 49 |
XAccessibleEventBroadcasterTester( |
| 50 |
const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster>& xBroadcaster, |
| 51 |
const std::function<void()>& rFireEventFunc); |
| 52 |
|
| 53 |
void testAddEventListener(); |
| 54 |
void testRemoveEventListener(); |
| 55 |
|
| 56 |
void testAll() |
| 57 |
{ |
| 58 |
testAddEventListener(); |
| 59 |
testRemoveEventListener(); |
| 60 |
} |
| 61 |
}; |
| 62 |
|
| 63 |
/** |
| 64 |
* Specialized XAccessibleEventBroadcaster subclass that modifies the |
| 65 |
* passed vcl::Window so that accessible events are generated for it. |
| 66 |
*/ |
| 67 |
class OOO_DLLPUBLIC_TEST WindowXAccessibleEventBroadcasterTester |
| 68 |
: public XAccessibleEventBroadcasterTester |
| 69 |
{ |
| 70 |
public: |
| 71 |
/** |
| 72 |
* Creates an WindowXAccessibleEventBroadcasterTester that will modify @c pWindow to generate |
| 73 |
* at least one accessible event for it. |
| 74 |
* @param xBroadcaster The XAccessibleEventBroadcaster implementation to test. |
| 75 |
* @param pWindow Window for whose accessible events @c xBroadcaster is responsible. |
| 76 |
*/ |
| 77 |
WindowXAccessibleEventBroadcasterTester( |
| 78 |
const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster>& xBroadcaster, |
| 79 |
vcl::Window* pWindow); |
| 80 |
|
| 81 |
private: |
| 82 |
static void triggerWindowEvent(vcl::Window* pWindow); |
| 83 |
}; |
| 84 |
|
| 85 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |