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 compliant. <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 static class TestImageConsumer
implements XImageConsumer
{
49 PrintWriter log
= null ;
50 public boolean initCalled
= false ;
52 TestImageConsumer(PrintWriter log
) {
53 log
.println("### Consumer initialized" ) ;
57 public void init(int width
, int height
) {
58 log
.println("### init() called") ;
62 public void setColorModel(short bitCount
, int[] RGBAPal
,
63 int redMask
, int greenMask
, int blueMask
, int alphaMask
) {
64 log
.println("### setColorModel() called") ;
67 public void setPixelsByBytes(int x
, int y
, int width
, int height
,
68 byte[] data
, int offset
, int scanSize
) {
69 log
.println("### setPixelByBytes() called") ;
72 public void setPixelsByLongs(int x
, int y
, int width
, int height
,
73 int[] data
, int offset
, int scanSize
) {
74 log
.println("### setPixelByLongs() called") ;
77 public void complete(int status
, XImageProducer prod
) {
78 log
.println("### complete() called") ;
82 TestImageConsumer consumer
= null ;
85 * Creates a new XImageConsumer implementation.
88 public void before() {
89 consumer
= new TestImageConsumer(log
) ;
93 * Adds a new consumer to producer. <p>
94 * Has <b> OK </b> status if no runtime exceptions occurred
96 public void _addConsumer() {
98 boolean result
= true ;
99 oObj
.addConsumer(consumer
) ;
101 tRes
.tested("addConsumer()", result
) ;
105 * Removes the consumer added before. <p>
106 * Has <b> OK </b> status if no runtime exceptions occurred
107 * The following method tests are to be executed before :
109 * <li> <code> startProduction </code> </li>
112 public void _removeConsumer() {
113 executeMethod("startProduction()") ;
115 boolean result
= true ;
116 oObj
.removeConsumer(consumer
) ;
118 tRes
.tested("removeConsumer()", result
) ;
122 * Starts the production and after short waiting checks what
123 * consumer's methods were called. <p>
124 * Has <b> OK </b> status if at least <code>init</code> consumer
125 * methods was called.
126 * The following method tests are to be completed successfully before :
128 * <li> <code> addConsumer </code> </li>
131 public void _startProduction() {
132 requiredMethod("addConsumer()") ;
134 oObj
.startProduction() ;
138 tRes
.tested("startProduction()", consumer
.initCalled
) ;