Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / ucb / _XDataContainer.java
blob0f07c41ef5325c97280168b9b4a7ebc0e6dc452c
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.ucb;
21 import lib.MultiMethodTest;
23 import com.sun.star.ucb.XDataContainer;
25 /**
26 * Testing <code>com.sun.star.ucb.XDataContainer</code>
27 * interface methods :
28 * <ul>
29 * <li><code> getContentType()</code></li>
30 * <li><code> setContentType()</code></li>
31 * <li><code> getData()</code></li>
32 * <li><code> setData()</code></li>
33 * <li><code> getDataURL()</code></li>
34 * <li><code> setDataURL()</code></li>
35 * </ul> <p>
36 * Test is <b> NOT </b> multithread compliant. <p>
37 * @see com.sun.star.ucb.XDataContainer
39 public class _XDataContainer extends MultiMethodTest {
41 public static XDataContainer oObj = null; // oObj filled by MultiMethodTest
42 private final byte[] data = new byte[] {34, 35, 36} ;
43 private String dataURL = null;
45 /**
46 * Sets the content type to some value. <p>
47 * Has <b>OK</b> status if no runtime exseptions occurred.
49 public void _setContentType() {
50 oObj.setContentType("image/jpeg") ;
51 tRes.tested("setContentType()", true) ;
54 /**
55 * Check if values 'set' and 'get' are equal. <p>
56 * Has <b>OK</b> status if they are equal. <p>
57 * The following method tests are to be completed successfully before :
58 * <ul>
59 * <li> <code> setContentType() </code> </li>
60 * </ul>
62 public void _getContentType() {
63 requiredMethod("setContentType()") ;
65 String type = oObj.getContentType() ;
66 tRes.tested("getContentType()", "image/jpeg".equals(type)) ;
69 /**
70 * Sets the data to some byte array. <p>
71 * Has <b>OK</b> status if no runtime exseptions occurred.
73 public void _setData() {
74 oObj.setData(data) ;
75 tRes.tested("setData()", true) ;
78 /**
79 * Check if arrays 'set' and 'get' are equal. <p>
80 * Has <b>OK</b> status if they are equal. <p>
81 * The following method tests are to be completed successfully before :
82 * <ul>
83 * <li> <code> setData() </code> </li>
84 * </ul>
86 public void _getData() {
87 requiredMethod("setData()") ;
89 byte[] gData = oObj.getData() ;
90 boolean res = true ;
91 if (res = (gData != null && gData.length == data.length)) {
92 for (int i = 0; i < data.length; i++) {
93 res &= data[i] == gData[i] ;
97 tRes.tested("getData()", res) ;
101 * Sets the data URL to some URL. <p>
102 * Has <b>OK</b> status if no runtime exseptions occurred.
104 public void _setDataURL() {
105 dataURL = util.utils.getOfficeTemp(tParam.getMSF()) ;
106 oObj.setDataURL(dataURL) ;
107 tRes.tested("setDataURL()", true) ;
111 * Check if URLs 'set' and 'get' are equal. <p>
112 * Has <b>OK</b> status if they are equal. <p>
113 * The following method tests are to be completed successfully before :
114 * <ul>
115 * <li> <code> setDataURL() </code> </li>
116 * </ul>
118 public void _getDataURL() {
119 requiredMethod("setDataURL()") ;
121 String gURL = oObj.getDataURL() ;
122 tRes.tested("getDataURL()", dataURL.equals(gURL)) ;