bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / frame / _XDispatchProviderInterception.java
blobb4ab947731e416cebdbde3aed26bde3482d7b0a1
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.frame;
21 import java.io.PrintWriter;
23 import lib.MultiMethodTest;
25 import com.sun.star.frame.DispatchDescriptor;
26 import com.sun.star.frame.XDispatch;
27 import com.sun.star.frame.XDispatchProvider;
28 import com.sun.star.frame.XDispatchProviderInterception;
29 import com.sun.star.frame.XDispatchProviderInterceptor;
30 import com.sun.star.util.URL;
32 /**
33 * Testing <code>com.sun.star.frame.XDispatchProviderInterception</code>
34 * interface methods :
35 * <ul>
36 * <li><code> registerDispatchProviderInterceptor()</code></li>
37 * <li><code> releaseDispatchProviderInterceptor()</code></li>
38 * </ul> <p>
39 * @see com.sun.star.frame.XDispatchProviderInterception
41 public class _XDispatchProviderInterception extends MultiMethodTest {
43 public XDispatchProviderInterception oObj = null;
45 /**
46 * Implementation of <code>XDispatchProviderInterceptor</code> interface
47 * which writes info about method calls to log, stores master and
48 * slave interceptors, and redirect all dispatch queries to the master
49 * provider.
51 public class TestInterceptor implements XDispatchProviderInterceptor {
52 private final PrintWriter log;
53 public XDispatchProvider master = null, slave = null ;
55 public TestInterceptor(PrintWriter log) {
56 this.log = log ;
59 public XDispatchProvider getSlaveDispatchProvider() {
60 log.println("getSlaveDispatchProvider() called.") ;
61 return slave;
63 public XDispatchProvider getMasterDispatchProvider() {
64 log.println("getMasterDispatchProvider() called.") ;
65 return master;
67 public void setSlaveDispatchProvider(XDispatchProvider prov) {
68 log.println("setSlaveDispatchProvider(" + prov + ") called.") ;
69 slave = prov ;
71 public void setMasterDispatchProvider(XDispatchProvider prov) {
72 log.println("setMasterDispatchProvider(" + prov + ") called.") ;
73 master = prov ;
76 public XDispatch queryDispatch(URL url, String frame, int flags) {
77 log.println("my queryDispatch('" + url.Complete + "', '" +
78 frame + "', " + flags + ") called.") ;
79 return slave.queryDispatch(url, frame, flags) ;
81 public XDispatch[] queryDispatches(DispatchDescriptor[] desc) {
82 log.println("my queryDispatches() called.") ;
83 return slave.queryDispatches(desc) ;
88 TestInterceptor interceptor = null ;
89 /**
90 * Cereates new interceptor implementation.
92 @Override
93 public void before() {
94 interceptor = new TestInterceptor(log) ;
97 /**
98 * Registers new interceptor implementation. <p>
99 * Has <b> OK </b> status if during registering interceptor's
100 * <code>setMasterDispatchProvider</code> method with non null
101 * parameter was called. <p>
103 public void _registerDispatchProviderInterceptor() {
105 boolean result = true ;
106 oObj.registerDispatchProviderInterceptor(interceptor) ;
108 result = interceptor.master != null ;
110 tRes.tested("registerDispatchProviderInterceptor()", result) ;
114 * Releases interceptor. <p>
115 * Has <b> OK </b> status if during method call interceptor's
116 * <code>setMasterDispatchProvider</code> method with <code>null</code>
117 * parameter was called. <p>
118 * The following method tests are to be completed successfully before :
119 * <ul>
120 * <li> <code> registerDispatchProviderInterceptor </code> </li>
121 * </ul>
123 public void _releaseDispatchProviderInterceptor() {
124 requiredMethod("registerDispatchProviderInterceptor()") ;
126 boolean result = true ;
127 oObj.releaseDispatchProviderInterceptor(interceptor) ;
129 result = interceptor.master == null ;
131 tRes.tested("releaseDispatchProviderInterceptor()", result) ;