1 /*
2  * This file is part of the LibreOffice project.
3  *
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/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
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 .
17  */
18 
19 package ifc.awt;
20 
21 
22 import lib.MultiMethodTest;
23 
24 import com.sun.star.awt.TextAlign;
25 import com.sun.star.awt.XFixedText;
26 
27 /**
28 * Testing <code>com.sun.star.awt.XFixedText</code>
29 * interface methods :
30 * <ul>
31 *  <li><code> setText()</code></li>
32 *  <li><code> getText()</code></li>
33 *  <li><code> setAlignment()</code></li>
34 *  <li><code> getAlignment()</code></li>
35 * </ul> <p>
36 * Test is <b> NOT </b> multithread compliant. <p>
37 * @see com.sun.star.awt.XFixedText
38 */
39 public class _XFixedText extends MultiMethodTest {
40 
41     public XFixedText oObj = null;
42     private String text = null ;
43     private int align = -1 ;
44 
45     /**
46     * Sets value changed and then compares it to get value. <p>
47     * Has <b>OK</b> status if set and get values are equal.
48     * The following method tests are to be completed successfully before :
49     * <ul>
50     *  <li> <code> getText </code>  </li>
51     * </ul>
52     */
_setText()53     public void _setText() {
54         requiredMethod("getText()") ;
55 
56         boolean result = true ;
57         oObj.setText(text + "_") ;
58         result = (text+"_").equals(oObj.getText()) ;
59 
60         tRes.tested("setText()", result) ;
61     }
62 
63     /**
64     * Just calls the method and stores value returned. <p>
65     * Has <b>OK</b> status if no runtime exceptions occurred.
66     */
_getText()67     public void _getText() {
68 
69         boolean result = true ;
70         text = oObj.getText() ;
71         if (util.utils.isVoid(text)) text = "XFixedText";
72 
73         tRes.tested("getText()", result) ;
74     }
75 
76     /**
77     * Sets value changed and then compares it to get value. <p>
78     * Has <b>OK</b> status if set and get values are equal.
79     * The following method tests are to be completed successfully before :
80     * <ul>
81     *  <li> <code> getAlignment </code>  </li>
82     * </ul>
83     */
_setAlignment()84     public void _setAlignment() {
85         requiredMethod("getAlignment()") ;
86 
87         boolean result = true ;
88         int newAlign = align ==
89             TextAlign.CENTER ? TextAlign.LEFT : TextAlign.CENTER ;
90         oObj.setAlignment((short)newAlign) ;
91         short getAlign = oObj.getAlignment() ;
92         result = newAlign == getAlign ;
93 
94         tRes.tested("setAlignment()", result) ;
95     }
96 
97     /**
98     * Just calls the method and stores value returned. <p>
99     * Has <b>OK</b> status if no runtime exceptions occurred.
100     */
_getAlignment()101     public void _getAlignment() {
102 
103         boolean result = true ;
104         align = oObj.getAlignment() ;
105 
106         tRes.tested("getAlignment()", result) ;
107     }
108 
109 }
110 
111 
112