Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XSheetAnnotationAnchor.java
blob8c33d9f4542e4ab0d27c1811d2082a509556b2d4
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.sheet;
21 import lib.MultiMethodTest;
23 import com.sun.star.sheet.XSheetAnnotation;
24 import com.sun.star.sheet.XSheetAnnotationAnchor;
25 import com.sun.star.table.CellAddress;
26 import com.sun.star.text.XSimpleText;
27 import com.sun.star.uno.UnoRuntime;
29 /**
30 * Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code>
31 * interface methods :
32 * <ul>
33 * <li><code> getAnnotation()</code></li>
34 * </ul>
35 * @see com.sun.star.sheet.XSheetAnnotationAnchor
37 public class _XSheetAnnotationAnchor extends MultiMethodTest {
39 public XSheetAnnotationAnchor oObj = null;
40 protected XSheetAnnotation anno = null;
42 public void _getAnnotation() {
43 anno = oObj.getAnnotation();
44 tRes.tested("getAnnotation()",checkAnnotation());
47 protected boolean checkAnnotation() {
48 boolean res = true;
49 res &= check_getAuthor();
50 res &= check_getDate();
51 res &= check_getIsVisible();
52 res &= check_getPosition();
53 res &= check_setIsVisible();
54 return res;
57 /**
58 * Gets the author of annotation. <p>
59 * Returns <b>true</b> if not null value returned.
61 protected boolean check_getAuthor() {
62 String author = anno.getAuthor();
63 return (author != null);
66 /**
67 * Gets the modification date of annotation. <p>
68 * Returns <b>true</b> if not null value returned.
70 protected boolean check_getDate() {
71 String date = anno.getDate();
72 return (date != null);
75 /**
76 * Sets the string of annotation, then makes it visible and
77 * checks the value returned by <code>getIsVisible</code> method. <p>
78 * Returns <b>true</b> if the method returns <code>true</code>.
80 protected boolean check_getIsVisible() {
81 XSimpleText oText = UnoRuntime.queryInterface(XSimpleText.class, anno);
82 oText.setString("XSheetAnnotation");
83 anno.setIsVisible(true);
84 boolean bVis = anno.getIsVisible();
85 return bVis;
88 /**
89 * Gets the position of annotated cell
90 * Returns <b>true</b> if this position is not null.
92 protected boolean check_getPosition() {
93 CellAddress oCAddr = anno.getPosition();
94 return (oCAddr != null);
97 /**
98 * Sets the string of annotation, makes it hidden and then
99 * visible. Visibility is checked in both cases. <p>
100 * Returns <b>true</b> if the <code>getIsVisible</code> method
101 * returns <code>false</code> in the first case and <code>true</code>
102 * in the second.
104 protected boolean check_setIsVisible() {
105 boolean bResult = true;
106 XSimpleText oText = UnoRuntime.queryInterface(XSimpleText.class, anno);
107 oText.setString("XSheetAnnotation");
108 anno.setIsVisible(false);
109 boolean bVis = anno.getIsVisible();
110 if (!bVis) {
111 anno.setIsVisible(true);
112 bVis = anno.getIsVisible();
113 if (bVis) {
114 bResult = true;
118 return bResult;