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 .
22 import java
.io
.PrintWriter
;
24 import lib
.MultiMethodTest
;
26 import com
.sun
.star
.awt
.XImageConsumer
;
27 import com
.sun
.star
.awt
.XImageProducer
;
30 * Testing <code>com.sun.star.awt.XImageProducer</code>
33 * <li><code> addConsumer()</code></li>
34 * <li><code> removeConsumer()</code></li>
35 * <li><code> startProduction()</code></li>
37 * Test is <b> NOT </b> multithread compilant. <p>
38 * @see com.sun.star.awt.XImageProducer
40 public class _XImageProducer
extends MultiMethodTest
{
42 public XImageProducer oObj
= null;
45 * Consumer implementation which sets flags on appropriate
48 protected class TestImageConsumer
implements XImageConsumer
{
49 PrintWriter log
= null ;
50 public boolean initCalled
= false ;
51 public boolean setColorModelCalled
= false ;
52 public boolean setPixelsByBytesCalled
= false ;
53 public boolean setPixelsByLongsCalled
= false ;
54 public boolean completeCalled
= false ;
56 TestImageConsumer(PrintWriter log
) {
57 log
.println("### Consumer initialized" ) ;
61 public void init(int width
, int height
) {
62 log
.println("### init() called") ;
66 public void setColorModel(short bitCount
, int[] RGBAPal
,
67 int redMask
, int greenMask
, int blueMask
, int alphaMask
) {
69 log
.println("### setColorModel() called") ;
70 setColorModelCalled
= true ;
73 public void setPixelsByBytes(int x
, int y
, int width
, int height
,
74 byte[] data
, int offset
, int scanSize
) {
76 log
.println("### setPixelByBytes() called") ;
77 setPixelsByBytesCalled
= true ;
80 public void setPixelsByLongs(int x
, int y
, int width
, int height
,
81 int[] data
, int offset
, int scanSize
) {
83 log
.println("### setPixelByLongs() called") ;
84 setPixelsByLongsCalled
= true ;
87 public void complete(int status
, XImageProducer prod
) {
88 log
.println("### complete() called") ;
89 completeCalled
= true ;
93 TestImageConsumer consumer
= null ;
96 * Creates a new XImageConsumer implementation.
98 public void before() {
99 consumer
= new TestImageConsumer(log
) ;
103 * Adds a new consumer to producer. <p>
104 * Has <b> OK </b> status if no runtime exceptions occurred
106 public void _addConsumer() {
108 boolean result
= true ;
109 oObj
.addConsumer(consumer
) ;
111 tRes
.tested("addConsumer()", result
) ;
115 * Removes the consumer added before. <p>
116 * Has <b> OK </b> status if no runtime exceptions occurred
117 * The following method tests are to be executed before :
119 * <li> <code> startProduction </code> </li>
122 public void _removeConsumer() {
123 executeMethod("startProduction()") ;
125 boolean result
= true ;
126 oObj
.removeConsumer(consumer
) ;
128 tRes
.tested("removeConsumer()", result
) ;
132 * Starts the production and after short waiting checks what
133 * consumer's methods were called. <p>
134 * Has <b> OK </b> status if at least <code>init</code> consumer
135 * methods was called.
136 * The following method tests are to be completed successfully before :
138 * <li> <code> addConsumer </code> </li>
141 public void _startProduction() {
142 requiredMethod("addConsumer()") ;
144 oObj
.startProduction() ;
148 } catch (InterruptedException e
) {}
150 tRes
.tested("startProduction()", consumer
.initCalled
) ;