bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / frame / _XDispatchProviderInterception.java
blob29ce2a580638f764785971c248af412a346a5e5f
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 PrintWriter log = null ;
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 public void before() {
93 interceptor = new TestInterceptor(log) ;
96 /**
97 * Registers new interceptor implementation. <p>
98 * Has <b> OK </b> status if during registering interceptor's
99 * <code>setMasterDispatchProvider</code> method with non null
100 * parameter was called. <p>
102 public void _registerDispatchProviderInterceptor() {
104 boolean result = true ;
105 oObj.registerDispatchProviderInterceptor(interceptor) ;
107 result = interceptor.master != null ;
109 tRes.tested("registerDispatchProviderInterceptor()", result) ;
113 * Releases interceptor. <p>
114 * Has <b> OK </b> status if during method call interceptor's
115 * <code>setMasterDispatchProvider</code> method with <code>null</code>
116 * parameter was called. <p>
117 * The following method tests are to be completed successfully before :
118 * <ul>
119 * <li> <code> registerDispatchProviderInterceptor </code> </li>
120 * </ul>
122 public void _releaseDispatchProviderInterceptor() {
123 requiredMethod("registerDispatchProviderInterceptor()") ;
125 boolean result = true ;
126 oObj.releaseDispatchProviderInterceptor(interceptor) ;
128 result = interceptor.master == null ;
130 tRes.tested("releaseDispatchProviderInterceptor()", result) ;