1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ucb_XDataContainer" script:language="StarBasic">
4cdf0e10cSrcweir
5cdf0e10cSrcweir
6cdf0e10cSrcweir'*************************************************************************
7cdf0e10cSrcweir'
8*3e6afcd2SAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
9*3e6afcd2SAndrew Rist'  or more contributor license agreements.  See the NOTICE file
10*3e6afcd2SAndrew Rist'  distributed with this work for additional information
11*3e6afcd2SAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
12*3e6afcd2SAndrew Rist'  to you under the Apache License, Version 2.0 (the
13*3e6afcd2SAndrew Rist'  "License"); you may not use this file except in compliance
14*3e6afcd2SAndrew Rist'  with the License.  You may obtain a copy of the License at
15*3e6afcd2SAndrew Rist'
16*3e6afcd2SAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
17*3e6afcd2SAndrew Rist'
18*3e6afcd2SAndrew Rist'  Unless required by applicable law or agreed to in writing,
19*3e6afcd2SAndrew Rist'  software distributed under the License is distributed on an
20*3e6afcd2SAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*3e6afcd2SAndrew Rist'  KIND, either express or implied.  See the License for the
22*3e6afcd2SAndrew Rist'  specific language governing permissions and limitations
23*3e6afcd2SAndrew Rist'  under the License.
24cdf0e10cSrcweir'
25cdf0e10cSrcweir'*************************************************************************
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29*3e6afcd2SAndrew Rist
30*3e6afcd2SAndrew Rist
31cdf0e10cSrcweir' Be sure that all variables are dimensioned:
32cdf0e10cSrcweiroption explicit
33cdf0e10cSrcweir
34cdf0e10cSrcweir
35cdf0e10cSrcweir
36cdf0e10cSrcweirSub RunTest()
37cdf0e10cSrcweir
38cdf0e10cSrcweir'*************************************************************************
39cdf0e10cSrcweir' INTERFACE:
40cdf0e10cSrcweir' com.sun.star.ucb.XDataContainer
41cdf0e10cSrcweir'*************************************************************************
42cdf0e10cSrcweirOn Error Goto ErrHndl
43cdf0e10cSrcweir    Dim bOK As Boolean
44cdf0e10cSrcweir    Dim i As Integer
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir    Test.StartMethod("setContentType()")
48cdf0e10cSrcweir    Test.StartMethod("getContentType()")
49cdf0e10cSrcweir
50cdf0e10cSrcweir    Dim aContType As String
51cdf0e10cSrcweir    Dim objContType As String
52cdf0e10cSrcweir    Dim newContType As String
53cdf0e10cSrcweir
54cdf0e10cSrcweir    bOK = true
55cdf0e10cSrcweir    aContType = oObj.getContentType()
56cdf0e10cSrcweir    Out.Log("Current content type is: '" + aContType + "'")
57cdf0e10cSrcweir    newContType = "text/html"
58cdf0e10cSrcweir
59cdf0e10cSrcweir    if (newContType = aContType) then
60cdf0e10cSrcweir        newContType = "text/plain"
61cdf0e10cSrcweir    end if
62cdf0e10cSrcweir
63cdf0e10cSrcweir    Out.Log("Trying to change type to " + newContType)
64cdf0e10cSrcweir    oObj.setContentType(newContType)
65cdf0e10cSrcweir
66cdf0e10cSrcweir    objContType = oObj.getContentType()
67cdf0e10cSrcweir    Out.Log("Actual content type is: '" + objContType + "'")
68cdf0e10cSrcweir    bOK = bOK AND objContType = newContType
69cdf0e10cSrcweir    Out.Log("Change type back to original...")
70cdf0e10cSrcweir    oObj.setContentType(aContType)
71cdf0e10cSrcweir
72cdf0e10cSrcweir    Test.MethodTested("getContentType()", bOK)
73cdf0e10cSrcweir    Test.MethodTested("setContentType()", bOK)
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir    Test.StartMethod("getData()")
77cdf0e10cSrcweir    bOK = true
78cdf0e10cSrcweir
79cdf0e10cSrcweir    Dim Data As Variant
80cdf0e10cSrcweir
81cdf0e10cSrcweir    Data = oObj.getData()
82cdf0e10cSrcweir    Out.Log("getData returned array with ubound = " + ubound(Data))
83cdf0e10cSrcweir    bOK = bOK AND ubound(Data) &gt;= -1
84cdf0e10cSrcweir    for i  = 0 to ubound(Data)
85cdf0e10cSrcweir        Out.Log("" + Data(i) + " " + chr(Data(i)))
86cdf0e10cSrcweir    next i
87cdf0e10cSrcweir    Test.MethodTested("getData()", bOK)
88cdf0e10cSrcweir
89cdf0e10cSrcweir    Test.StartMethod("setData()")
90cdf0e10cSrcweir    bOK = true
91cdf0e10cSrcweir
92cdf0e10cSrcweir    Dim DataToSet As Variant
93cdf0e10cSrcweir    DataToSet = DimArray(ubound(Data()))
94cdf0e10cSrcweir
95cdf0e10cSrcweir    for i = 0 to ubound(DataToSet())
96cdf0e10cSrcweir        DataToSet(i) = Data(i) + 1
97cdf0e10cSrcweir    next i
98cdf0e10cSrcweir
99cdf0e10cSrcweir    oObj.setData(DataToSet)
100cdf0e10cSrcweir    Data = oObj.getData()
101cdf0e10cSrcweir    Out.Log("after setData() call: getData returned array with ubound = " + ubound(Data))
102cdf0e10cSrcweir    bOK = bOK AND (ubound(Data) = ubound(DataToSet))
103cdf0e10cSrcweir    if (bOK) then
104cdf0e10cSrcweir        for i  = 0 to ubound(Data)
105cdf0e10cSrcweir            Out.Log("" + Data(i) + " " + chr(Data(i)))
106cdf0e10cSrcweir            bOK = bOK AND (DataToSet(i) = Data(i))
107cdf0e10cSrcweir        next i
108cdf0e10cSrcweir    end if
109cdf0e10cSrcweir
110cdf0e10cSrcweir    Test.MethodTested("setData()", bOK)
111cdf0e10cSrcweir
112cdf0e10cSrcweir    Test.StartMethod("getDataURL()")
113cdf0e10cSrcweir    Test.StartMethod("setDataURL()")
114cdf0e10cSrcweir
115cdf0e10cSrcweir
116cdf0e10cSrcweir    Dim aDataURL As String
117cdf0e10cSrcweir    Dim objDataURL As String
118cdf0e10cSrcweir    Dim newDataURL As String
119cdf0e10cSrcweir
120cdf0e10cSrcweir    bOK = true
121cdf0e10cSrcweir    aDataURL = oObj.getDataURL()
122cdf0e10cSrcweir    Out.Log("Current data URL is: '" + aDataURL + "'")
123cdf0e10cSrcweir    newDataURL = "http://www.sun.com"
124cdf0e10cSrcweir    if (newDataURL = aDataURL) then
125cdf0e10cSrcweir        newDataURL = "http://www.openoffice.org"
126cdf0e10cSrcweir    end if
127cdf0e10cSrcweir
128cdf0e10cSrcweir    Out.Log("Trying to change data URL to " + newDataURL)
129cdf0e10cSrcweir    oObj.setDataURL(newDataURL)
130cdf0e10cSrcweir
131cdf0e10cSrcweir    objDataURL = oObj.getDataURL()
132cdf0e10cSrcweir    Out.Log("Actual data URL is: '" + objDataURL + "'")
133cdf0e10cSrcweir    bOK = bOK AND objDataURL = newDataURL
134cdf0e10cSrcweir    Out.Log("Change data URL back to original...")
135cdf0e10cSrcweir    oObj.setDataURL(aDataURL)
136cdf0e10cSrcweir
137cdf0e10cSrcweir    Out.Log("Methods getDataURL() and setDataURL() are DEPRICATED. The result of test is ALWAYS true!")
138cdf0e10cSrcweir
139cdf0e10cSrcweir    bOK = true
140cdf0e10cSrcweir
141cdf0e10cSrcweir    Test.MethodTested("getDataURL()", bOK)
142cdf0e10cSrcweir    Test.MethodTested("setDataURL()", bOK)
143cdf0e10cSrcweir
144cdf0e10cSrcweirExit Sub
145cdf0e10cSrcweirErrHndl:
146cdf0e10cSrcweir    Test.Exception()
147cdf0e10cSrcweir    bOK = false
148cdf0e10cSrcweir    resume next
149cdf0e10cSrcweirEnd Sub
150cdf0e10cSrcweir</script:module>
151