Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XImageProducer.java
blobba224bd1d01da2ed531a6db777d9448631a5a6da
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XImageProducer.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.awt;
34 import java.io.PrintWriter;
36 import lib.MultiMethodTest;
38 import com.sun.star.awt.XImageConsumer;
39 import com.sun.star.awt.XImageProducer;
41 /**
42 * Testing <code>com.sun.star.awt.XImageProducer</code>
43 * interface methods :
44 * <ul>
45 * <li><code> addConsumer()</code></li>
46 * <li><code> removeConsumer()</code></li>
47 * <li><code> startProduction()</code></li>
48 * </ul> <p>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.awt.XImageProducer
52 public class _XImageProducer extends MultiMethodTest {
54 public XImageProducer oObj = null;
56 /**
57 * Consumer implementation which sets flags on appropriate
58 * method calls.
60 protected class TestImageConsumer implements XImageConsumer {
61 PrintWriter log = null ;
62 public boolean initCalled = false ;
63 public boolean setColorModelCalled = false ;
64 public boolean setPixelsByBytesCalled = false ;
65 public boolean setPixelsByLongsCalled = false ;
66 public boolean completeCalled = false ;
68 TestImageConsumer(PrintWriter log) {
69 log.println("### Consumer initialized" ) ;
70 this.log = log ;
73 public void init(int width, int height) {
74 log.println("### init() called") ;
75 initCalled = true ;
78 public void setColorModel(short bitCount, int[] RGBAPal,
79 int redMask, int greenMask, int blueMask, int alphaMask) {
81 log.println("### setColorModel() called") ;
82 setColorModelCalled = true ;
85 public void setPixelsByBytes(int x, int y, int width, int height,
86 byte[] data, int offset, int scanSize) {
88 log.println("### setPixelByBytes() called") ;
89 setPixelsByBytesCalled = true ;
92 public void setPixelsByLongs(int x, int y, int width, int height,
93 int[] data, int offset, int scanSize) {
95 log.println("### setPixelByLongs() called") ;
96 setPixelsByLongsCalled = true ;
99 public void complete(int status, XImageProducer prod) {
100 log.println("### complete() called") ;
101 completeCalled = true ;
105 TestImageConsumer consumer = null ;
108 * Creates a new XImageConsumer implementation.
110 public void before() {
111 consumer = new TestImageConsumer(log) ;
115 * Adds a new consumer to producer. <p>
116 * Has <b> OK </b> status if no runtime exceptions occured
118 public void _addConsumer() {
120 boolean result = true ;
121 oObj.addConsumer(consumer) ;
123 tRes.tested("addConsumer()", result) ;
127 * Removes the consumer added before. <p>
128 * Has <b> OK </b> status if no runtime exceptions occured
129 * The following method tests are to be executed before :
130 * <ul>
131 * <li> <code> startProduction </code> </li>
132 * </ul>
134 public void _removeConsumer() {
135 executeMethod("startProduction()") ;
137 boolean result = true ;
138 oObj.removeConsumer(consumer) ;
140 tRes.tested("removeConsumer()", result) ;
144 * Starts the production and after short waiting checks what
145 * consumer's methods were called. <p>
146 * Has <b> OK </b> status if at least <code>init</code> consumer
147 * methods was called.
148 * The following method tests are to be completed successfully before :
149 * <ul>
150 * <li> <code> addConsumer </code> </li>
151 * </ul>
153 public void _startProduction() {
154 requiredMethod("addConsumer()") ;
156 boolean result = true ;
157 oObj.startProduction() ;
159 try {
160 Thread.sleep(500) ;
161 } catch (InterruptedException e) {}
163 tRes.tested("startProduction()", consumer.initCalled) ;