Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XImageProducer.java
blobb61bb04a374991f10baa2405303e54edbdf9c1e6
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.awt;
22 import java.io.PrintWriter;
24 import lib.MultiMethodTest;
26 import com.sun.star.awt.XImageConsumer;
27 import com.sun.star.awt.XImageProducer;
29 /**
30 * Testing <code>com.sun.star.awt.XImageProducer</code>
31 * interface methods :
32 * <ul>
33 * <li><code> addConsumer()</code></li>
34 * <li><code> removeConsumer()</code></li>
35 * <li><code> startProduction()</code></li>
36 * </ul> <p>
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;
44 /**
45 * Consumer implementation which sets flags on appropriate
46 * method calls.
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" ) ;
58 this.log = log ;
61 public void init(int width, int height) {
62 log.println("### init() called") ;
63 initCalled = true ;
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 ;
95 /**
96 * Creates a new XImageConsumer implementation.
98 @Override
99 public void before() {
100 consumer = new TestImageConsumer(log) ;
104 * Adds a new consumer to producer. <p>
105 * Has <b> OK </b> status if no runtime exceptions occurred
107 public void _addConsumer() {
109 boolean result = true ;
110 oObj.addConsumer(consumer) ;
112 tRes.tested("addConsumer()", result) ;
116 * Removes the consumer added before. <p>
117 * Has <b> OK </b> status if no runtime exceptions occurred
118 * The following method tests are to be executed before :
119 * <ul>
120 * <li> <code> startProduction </code> </li>
121 * </ul>
123 public void _removeConsumer() {
124 executeMethod("startProduction()") ;
126 boolean result = true ;
127 oObj.removeConsumer(consumer) ;
129 tRes.tested("removeConsumer()", result) ;
133 * Starts the production and after short waiting checks what
134 * consumer's methods were called. <p>
135 * Has <b> OK </b> status if at least <code>init</code> consumer
136 * methods was called.
137 * The following method tests are to be completed successfully before :
138 * <ul>
139 * <li> <code> addConsumer </code> </li>
140 * </ul>
142 public void _startProduction() {
143 requiredMethod("addConsumer()") ;
145 oObj.startProduction() ;
147 util.utils.shortWait();
149 tRes.tested("startProduction()", consumer.initCalled) ;