tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _streams / uno / DataInputStream.java
blob9fbb3563c24bf23202b3234c42544ac233fbb010
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 mod._streams.uno;
21 import com.sun.star.io.XActiveDataSink;
22 import com.sun.star.io.XActiveDataSource;
23 import com.sun.star.io.XDataOutputStream;
24 import com.sun.star.io.XInputStream;
25 import com.sun.star.io.XOutputStream;
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.uno.UnoRuntime;
28 import com.sun.star.uno.XInterface;
30 import java.io.PrintWriter;
31 import java.util.ArrayList;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.io.DataInputStream</code>.
40 * <ul>
41 * <li> <code>com::sun::star::io::XInputStream</code></li>
42 * <li> <code>com::sun::star::io::XDataInputStream</code></li>
43 * <li> <code>com::sun::star::io::XConnectable</code></li>
44 * <li> <code>com::sun::star::io::XActiveDataSink</code></li>
45 * </ul>
46 * @see com.sun.star.io.DataInputStream
47 * @see com.sun.star.io.XInputStream
48 * @see com.sun.star.io.XDataInputStream
49 * @see com.sun.star.io.XConnectable
50 * @see com.sun.star.io.XActiveDataSink
51 * @see ifc.io._XInputStream
52 * @see ifc.io._XDataInputStream
53 * @see ifc.io._XConnectable
54 * @see ifc.io._XActiveDataSink
56 public class DataInputStream extends TestCase {
58 /**
59 * Creates a TestEnvironment for the interfaces to be tested.
60 * Creates <code>com.sun.star.io.DataInputStream</code> object,
61 * connects it to <code>com.sun.star.io.DataOutputStream</code>
62 * through <code>com.sun.star.io.Pipe</code>. All of possible data
63 * types are written into <code>DataOutputStream</code>.
64 * Object relations created :
65 * <ul>
66 * <li> <code>'StreamData'</code> for
67 * {@link ifc.io._XDataInputStream}(the data that should be written into
68 * the stream) </li>
69 * <li> <code>'ByteData'</code> for
70 * {@link ifc.io._XInputStream}(the data that should be written into
71 * the stream) </li>
72 * <li> <code>'StreamWriter'</code> for
73 * {@link ifc.io._XDataInputStream}
74 * {@link ifc.io._XInputStream}(a stream to write data to) </li>
75 * <li> <code>'Connectable'</code> for
76 * {@link ifc.io._XConnectable}(another object that can be connected) </li>
77 * <li> <code>'InputStream'</code> for
78 * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li>
79 * </ul>
81 @Override
82 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
84 Object oInterface = null;
86 XMultiServiceFactory xMSF = Param.getMSF();
87 oInterface = xMSF.createInstance("com.sun.star.io.DataInputStream");
89 XInterface oObj = (XInterface) oInterface;
91 // creating and connecting DataOutputStream to the
92 // DataInputStream created through the Pipe
93 XActiveDataSink xDataSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj);
95 XInterface oPipe = (XInterface)
96 xMSF.createInstance("com.sun.star.io.Pipe");
98 XInputStream xPipeInput = UnoRuntime.queryInterface(XInputStream.class, oPipe);
99 XOutputStream xPipeOutput = UnoRuntime.queryInterface(XOutputStream.class, oPipe);
101 XInterface oDataOutput = (XInterface)
102 xMSF.createInstance("com.sun.star.io.DataOutputStream");
104 XDataOutputStream xDataOutput = UnoRuntime.queryInterface(XDataOutputStream.class, oDataOutput) ;
105 XActiveDataSource xDataSource = UnoRuntime.queryInterface(XActiveDataSource.class, oDataOutput) ;
107 xDataSource.setOutputStream(xPipeOutput) ;
108 xDataSink.setInputStream(xPipeInput) ;
110 // all data types for writing to an XDataInputStream
111 ArrayList<Object> data = new ArrayList<Object>() ;
112 data.add(Boolean.TRUE) ;
113 data.add(Byte.valueOf((byte)123)) ;
114 data.add(Character.valueOf((char)1234)) ;
115 data.add(Short.valueOf((short)1234)) ;
116 data.add(Integer.valueOf(123456)) ;
117 data.add(Float.valueOf(1.234f)) ;
118 data.add(Double.valueOf(1.23456)) ;
119 data.add("DataInputStream") ;
120 // information for writing to the pipe
121 byte[] byteData = new byte[] {
122 1, 2, 3, 4, 5, 6, 7, 8 } ;
124 // creating a connectable object for XConnectable interface
125 XInterface xConnect = (XInterface)xMSF.createInstance(
126 "com.sun.star.io.DataInputStream") ;
128 // creating an input stream to set in XActiveDataSink
129 XInterface oDataInput = (XInterface) xMSF.createInstance(
130 "com.sun.star.io.Pipe" );
133 log.println("creating a new environment for object");
134 TestEnvironment tEnv = new TestEnvironment( oObj );
136 // adding sequence of data that must be read
137 // by XDataInputStream interface methods
138 tEnv.addObjRelation("StreamData", data) ;
139 // add a writer
140 tEnv.addObjRelation("StreamWriter", xDataOutput);
141 // add a connectable
142 tEnv.addObjRelation("Connectable", xConnect);
143 // add an inputStream
144 tEnv.addObjRelation("InputStream", oDataInput);
145 tEnv.addObjRelation("ByteData", byteData);
147 return tEnv;
148 } // finish method getTestEnvironment