From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../java/ifc/text/_XMailMergeBroadcaster.java | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java (limited to 'qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java') diff --git a/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java b/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java new file mode 100644 index 000000000..5ac586b43 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java @@ -0,0 +1,140 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.NamedValue; +import com.sun.star.task.XJob; +import com.sun.star.text.MailMergeEvent; +import com.sun.star.text.XMailMergeBroadcaster; +import com.sun.star.text.XMailMergeListener; + +/** +* Testing com.sun.star.text.XMailMergeBroadcaster +* interface methods: +*

+* This test needs the following object relations : +*

+* +* Test is NOT multithread compliant.

+* @see com.sun.star.text.XMailMergeBroadcaster +*/ +public class _XMailMergeBroadcaster extends MultiMethodTest { + public static XMailMergeBroadcaster oObj = null; + protected boolean changed = false; + + + /** + * Class we need to test methods + */ + protected class MyMailMergeEventListener implements XMailMergeListener { + public void notifyMailMergeEvent ( MailMergeEvent oEvent ) { + System.out.println("Listener called"); + changed = true; + } + } + + protected XMailMergeListener listener = new MyMailMergeEventListener(); + + /** + * Tries to query the tested component for object relation + * executeArgs [NamedValue] and Job + * [XJob] + * @throw StatusException If relations are not found + */ + @Override + public void before() { + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs") ; + if (executeArgs == null) + throw new StatusException(Status.failed + ("'executeArgs' relation not found ")) ; + XJob Job = (XJob) tEnv.getObjRelation("Job") ; + if (Job == null) + throw new StatusException(Status.failed + ("'Job' relation not found ")) ; + } + + /** + * Test executes mail merge process

+ * Has OK status if listener was called + */ + public void _addMailMergeEventListener() { + log.println("Testing addMailMergeEventListener ..."); + + oObj.addMailMergeEventListener( listener ); + + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs"); + XJob Job = (XJob) tEnv.getObjRelation("Job"); + + try { + Job.execute(executeArgs); + } catch ( com.sun.star.lang.IllegalArgumentException e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } catch ( com.sun.star.uno.Exception e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } + + tRes.tested("addMailMergeEventListener()", changed); + } + + /** + * Test executes mail merge process

+ * Has OK status if listener was not called + */ + public void _removeMailMergeEventListener() { + log.println("Testing removeMailMergeEventListener ..."); + requiredMethod("addMailMergeEventListener()"); + changed = false; + + oObj.removeMailMergeEventListener( listener ); + + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs"); + XJob Job = (XJob) tEnv.getObjRelation("Job"); + + try { + Job.execute(executeArgs); + } catch ( com.sun.star.lang.IllegalArgumentException e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } catch ( com.sun.star.uno.Exception e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } + + waitForEventIdle(); + + tRes.tested("removeMailMergeEventListener()", !changed); + } + + +} // finished class _XMailMergeBroadcaster + -- cgit v1.2.3