Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XSheetLinkable.java
blob8494525b40d50fad906be571279f195251fbf7aa
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 .
18 package ifc.sheet;
20 import com.sun.star.sheet.SheetLinkMode;
21 import com.sun.star.sheet.XSheetLinkable;
22 import lib.MultiMethodTest;
23 import util.utils;
25 /**
28 public class _XSheetLinkable extends MultiMethodTest {
29 public XSheetLinkable oObj = null;
30 SheetLinkMode slm = null;
31 String linkSheetName = null;
32 String linkUrl = null;
33 String linkUrl2 = null;
35 @Override
36 public void before() {
37 // get a document for linking.
38 linkUrl = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet");
39 linkUrl = utils.getFullTestURL(linkUrl);
41 // get a second sheet for changing the link url: if it's not set,
42 // this part of the test is omitted.
43 linkUrl2 = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet2");
44 if (linkUrl2 != null)
45 linkUrl = utils.getFullTestURL(linkUrl);
47 // set a name for the sheet.
48 linkSheetName = "Sheet1";
51 public void _getLinkMode() {
52 requiredMethod("link()");
53 slm = oObj.getLinkMode();
54 tRes.tested("getLinkMode()", slm == SheetLinkMode.VALUE);
57 public void _getLinkSheetName() {
58 requiredMethod("link()");
59 String lSheetName = oObj.getLinkSheetName();
60 tRes.tested("getLinkSheetName()", linkSheetName.equals(lSheetName));
63 public void _getLinkUrl() {
64 requiredMethod("link()");
65 String lUrl = oObj.getLinkUrl();
66 System.out.println("URL: " + lUrl);
67 tRes.tested("getLinkUrl()", lUrl.equals(linkUrl));
70 public void _link() {
71 oObj.link(linkUrl, linkSheetName, "", "", SheetLinkMode.VALUE);
72 tRes.tested("link()", true);
75 public void _setLinkMode() {
76 requiredMethod("getLinkMode()");
77 oObj.setLinkMode(SheetLinkMode.NONE);
78 slm = oObj.getLinkMode();
79 tRes.tested("setLinkMode()", slm == SheetLinkMode.NONE);
82 public void _setLinkSheetName() {
83 requiredMethod("getLinkSheetName()");
84 oObj.setLinkSheetName("Sheet2");
85 linkSheetName = oObj.getLinkSheetName();
86 tRes.tested("setLinkSheetName()", linkSheetName.equals("Sheet2"));
89 public void _setLinkUrl() {
90 requiredMethod("getLinkUrl()");
91 boolean result = false;
92 if (linkUrl2 == null) {
93 // set back to the original value
94 oObj.setLinkUrl(linkUrl);
95 result = true;
97 else {
98 oObj.setLinkUrl(linkUrl2);
99 linkUrl = oObj.getLinkUrl();
100 result = linkUrl.equals(linkUrl2);
102 tRes.tested("setLinkUrl()", result);