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.XCheckBox; 25 26 /** 27 * Testing <code>com.sun.star.awt.XCheckBox</code> 28 * interface methods : 29 * <ul> 30 * <li><code> addItemListener()</code></li> 31 * <li><code> removeItemListener()</code></li> 32 * <li><code> getState()</code></li> 33 * <li><code> setState()</code></li> 34 * <li><code> setLabel()</code></li> 35 * <li><code> enableTriState()</code></li> 36 * </ul> <p> 37 * 38 * @see com.sun.star.awt.XCheckBox 39 */ 40 public class _XCheckBox extends MultiMethodTest { 41 42 public XCheckBox oObj = null; 43 44 /** 45 * Listener implementation which sets flags on appropriate method calls 46 */ 47 protected static class TestItemListener implements com.sun.star.awt.XItemListener { 48 disposing(com.sun.star.lang.EventObject e)49 public void disposing(com.sun.star.lang.EventObject e) { 50 } 51 itemStateChanged(com.sun.star.awt.ItemEvent e)52 public void itemStateChanged(com.sun.star.awt.ItemEvent e) {} 53 } 54 TestItemListener listener = new TestItemListener() ; 55 short state = -1 ; 56 57 /** 58 * !!! Can be checked only interactively !!! 59 */ _addItemListener()60 public void _addItemListener() { 61 62 boolean result = true ; 63 oObj.addItemListener(listener) ; 64 tRes.tested("addItemListener()", result) ; 65 } 66 67 /** 68 * !!! Can be checked only interactively !!! 69 */ _removeItemListener()70 public void _removeItemListener() { 71 72 boolean result = true ; 73 oObj.removeItemListener(listener) ; 74 75 tRes.tested("removeItemListener()", result) ; 76 } 77 78 /** 79 * Just retrieves current state and stores it. <p> 80 * Has <b>OK</b> status if no runtime exceptions occurs. 81 */ _getState()82 public void _getState() { 83 84 boolean result = true ; 85 state = oObj.getState() ; 86 87 tRes.tested("getState()", result) ; 88 } 89 90 /** 91 * Sets a new value and then checks get value. <p> 92 * Has <b>OK</b> status if set and get values are equal. <p> 93 * The following method tests are to be completed successfully before : 94 * <ul> 95 * <li> <code> getState </code> </li> 96 * </ul> 97 */ _setState()98 public void _setState() { 99 requiredMethod("getState()") ; 100 101 boolean result = true ; 102 short newState = state == 0 ? (short)1 : (short)0 ; 103 oObj.setState(newState) ; 104 result = newState == oObj.getState() ; 105 106 tRes.tested("setState()", result) ; 107 } 108 109 /** 110 * Just sets some text for label. <p> 111 * Has <b>OK</b> status if no runtime exceptions occurs. 112 */ _setLabel()113 public void _setLabel() { 114 115 boolean result = true ; 116 oObj.setLabel("XCheckBox test") ; 117 118 tRes.tested("setLabel()", result) ; 119 } 120 121 /** 122 * Just enables tristate. <p> 123 * Has <b>OK</b> status if no runtime exceptions occurs. 124 */ _enableTriState()125 public void _enableTriState() { 126 127 boolean result = true ; 128 oObj.enableTriState(true) ; 129 130 tRes.tested("enableTriState()", result) ; 131 } 132 133 } 134 135 136