update credits
[LibreOffice.git] / sw / qa / complex / checkColor / CheckChangeColor.java
blob9324e35fa8fd555ec87c503e30077bc7c726b341
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 complex.checkColor;
21 import com.sun.star.awt.Size;
22 import com.sun.star.beans.XPropertySet;
23 import com.sun.star.container.XNameAccess;
24 import com.sun.star.container.XNameContainer;
25 import com.sun.star.lang.XMultiServiceFactory;
26 import com.sun.star.style.XStyleFamiliesSupplier;
27 import com.sun.star.text.XTextDocument;
28 import com.sun.star.uno.Any;
29 import com.sun.star.uno.Type;
30 import com.sun.star.uno.UnoRuntime;
31 import org.junit.After;
32 import org.junit.AfterClass;
33 import org.junit.Before;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.openoffice.test.OfficeConnection;
37 import util.DesktopTools;
38 import util.SOfficeFactory;
39 import static org.junit.Assert.*;
41 /**
42 * Created because of complaint on dev@openoffice.org: check the changing of
43 * BackColor and IsLandscape properties on the PageStyle service.
45 public class CheckChangeColor {
46 /**
47 * Check BackColor and IsLandscape properties, wait for an exception: test
48 * is ok if no exception happened.
50 @Test public void checkChangeColor() throws Exception {
51 // create a supplier to get the Style family collection
52 XStyleFamiliesSupplier xSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, document);
54 // get the NameAccess interface from the Style family collection
55 XNameAccess xNameAccess = xSupplier.getStyleFamilies();
57 XNameContainer xPageStyleCollection = UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" ));
59 // create a PropertySet to set the properties for the new Pagestyle
60 XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") );
62 assertEquals(
63 "BackColor", new Any(Type.LONG, 0xFFFFFFFF),
64 Any.complete(xPropertySet.getPropertyValue("BackColor")));
65 assertEquals(
66 "IsLandscape", new Any(Type.BOOLEAN, false),
67 Any.complete(xPropertySet.getPropertyValue("IsLandscape")));
68 assertEquals(
69 "Size", new Type(Size.class),
70 Any.complete(xPropertySet.getPropertyValue("Size")).getType());
72 xPropertySet.setPropertyValue("BackColor", 0xFF000000);
73 xPropertySet.setPropertyValue("IsLandscape", true);
74 assertEquals(
75 "BackColor", new Any(Type.LONG, 0xFF000000),
76 Any.complete(xPropertySet.getPropertyValue("BackColor")));
77 assertEquals(
78 "IsLandscape", new Any(Type.BOOLEAN, true),
79 Any.complete(xPropertySet.getPropertyValue("IsLandscape")));
82 @Before public void setUpDocument() throws com.sun.star.uno.Exception {
83 document = SOfficeFactory.getFactory(
84 UnoRuntime.queryInterface(
85 XMultiServiceFactory.class,
86 connection.getComponentContext().getServiceManager())).
87 createTextDoc(null);
90 @After public void tearDownDocument() {
91 DesktopTools.closeDoc(document);
94 private XTextDocument document = null;
96 @BeforeClass public static void setUpConnection() throws Exception {
97 connection.setUp();
100 @AfterClass public static void tearDownConnection()
101 throws InterruptedException, com.sun.star.uno.Exception
103 connection.tearDown();
106 private static final OfficeConnection connection = new OfficeConnection();