1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="io_XInputStream" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31
32
33Sub RunTest()
34
35'*************************************************************************
36' INTERFACE:
37' com.sun.star.io.XInputStream
38'*************************************************************************
39On Error Goto ErrHndl
40    Dim bOK As Boolean
41    Dim Bytes(10) As Integer
42    Dim rBytes(10) As Integer
43    Dim oOutputStream As Object
44    Dim i As Integer
45    Dim nRead As Integer
46
47    Out.Log("First writeBytes()...")
48    bOK = true
49
50    for i = 0 to ubound(Bytes())
51        Bytes(i) = i
52    next i
53
54    oOutputStream = getOutStream()
55    oOutputStream.writeBytes(Bytes())
56
57    if (cObjectName &lt;&gt; "stm.Pipe") then ResetStreams()
58
59    Test.StartMethod("readBytes()")
60    bOK = true
61    nRead = oObj.readBytes(Bytes(), 5)
62    bOK = bOK AND nRead = 5
63    for i = 0 to 4
64        Out.Log("Expected " &amp; i &amp; ", actual is " &amp; int(Bytes(i)))
65        bOK = bOK AND Bytes(i) = i
66    next i
67    Test.MethodTested("readBytes()", bOK)
68
69    Test.StartMethod("skipBytes()")
70    bOK = true
71    oObj.skipBytes(2)
72    nRead = oObj.readBytes(Bytes(), 2)
73    Out.Log("Expected " &amp; 7 &amp; ", actual is " &amp; int(Bytes(0)))
74    bOK = bOK AND Bytes(0) = 7
75    Test.MethodTested("skipBytes()", bOK)
76
77    Test.StartMethod("available()")
78    bOK = true
79    iAvail = oObj.available()
80    Out.Log("bytes available without blocking: " &amp; iAvail)
81    bOK = bOK AND iAvail &gt;= 0
82    Test.MethodTested("available()", bOK)
83
84    Test.StartMethod("readSomeBytes()")
85    bOK = true
86    nRead = oObj.readSomeBytes(Bytes(), 10)
87    Out.Log("Can read " &amp; nRead &amp; " bytes.")
88    for i = 0 to ubound(Bytes())
89        Out.Log(int(Bytes(i)))
90    next i
91    bOK = bOK AND ubound(Bytes()) = 1
92    bOK = bOK AND nRead = 2
93    bOK = bOK AND Bytes(0) = 9
94    bOK = bOK AND Bytes(1) = 10
95    Test.MethodTested("readSomeBytes()", bOK)
96
97    Test.StartMethod("closeInput()")
98    bOK = true
99    Out.Log("This method is called in main module.")
100    Test.MethodTested("closeInput()", bOK)
101
102    ResetStreams()
103
104Exit Sub
105ErrHndl:
106    Test.Exception()
107    bOK = false
108    resume next
109End Sub
110</script:module>
111