[Libreoffice-commits] core.git: sw/JunitTest_sw_complex.mk sw/PythonTest_sw_python.mk sw/qa

aqcoder flw.aquarius at gmail.com
Thu Mar 24 09:34:28 UTC 2016


 sw/JunitTest_sw_complex.mk                     |    2 
 sw/PythonTest_sw_python.mk                     |    1 
 sw/qa/complex/checkColor/CheckChangeColor.java |  107 -------------------------
 sw/qa/python/check_change_color.py             |   31 +++++++
 4 files changed, 32 insertions(+), 109 deletions(-)

New commits:
commit 0f543e38722f25a2969d500513167a3305097ed8
Author: aqcoder <flw.aquarius at gmail.com>
Date:   Thu Mar 24 13:42:24 2016 +0800

    tdf#97362: Convert Java unit test to Python(check_change_color.py)
    
    Change-Id: I0fa4973b6af028666428fa58438eaf39f7b81d27
    Reviewed-on: https://gerrit.libreoffice.org/23482
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/sw/JunitTest_sw_complex.mk b/sw/JunitTest_sw_complex.mk
index afa5398..9e11a75 100644
--- a/sw/JunitTest_sw_complex.mk
+++ b/sw/JunitTest_sw_complex.mk
@@ -26,7 +26,6 @@ $(eval $(call gb_JunitTest_set_defs,sw_complex,\
 
 $(eval $(call gb_JunitTest_add_sourcefiles,sw_complex,\
     sw/qa/complex/accessibility/AccessibleRelationSet \
-    sw/qa/complex/checkColor/CheckChangeColor \
     sw/qa/complex/indeterminateState/CheckIndeterminateState \
     sw/qa/complex/writer/CheckBookmarks \
     sw/qa/complex/writer/TestDocument \
@@ -43,7 +42,6 @@ $(eval $(call gb_JunitTest_use_jars,sw_complex,\
 
 $(eval $(call gb_JunitTest_add_classes,sw_complex,\
     complex.accessibility.AccessibleRelationSet \
-    complex.checkColor.CheckChangeColor \
     complex.writer.CheckBookmarks \
     complex.writer.TextPortionEnumerationTest \
 ))
diff --git a/sw/PythonTest_sw_python.mk b/sw/PythonTest_sw_python.mk
index 3c5e2d5..774f6f8 100644
--- a/sw/PythonTest_sw_python.mk
+++ b/sw/PythonTest_sw_python.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_PythonTest_set_defs,sw_python,\
 ))
 
 $(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
+	check_change_color \
 	check_index \
 	check_flies \
 	check_fields \
diff --git a/sw/qa/complex/checkColor/CheckChangeColor.java b/sw/qa/complex/checkColor/CheckChangeColor.java
deleted file mode 100644
index 9324e35..0000000
--- a/sw/qa/complex/checkColor/CheckChangeColor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package complex.checkColor;
-
-import com.sun.star.awt.Size;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.container.XNameAccess;
-import com.sun.star.container.XNameContainer;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.style.XStyleFamiliesSupplier;
-import com.sun.star.text.XTextDocument;
-import com.sun.star.uno.Any;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.UnoRuntime;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openoffice.test.OfficeConnection;
-import util.DesktopTools;
-import util.SOfficeFactory;
-import static org.junit.Assert.*;
-
-/**
- * Created because of complaint on dev at openoffice.org: check the changing of
- * BackColor and IsLandscape properties on the PageStyle service.
- */
-public class CheckChangeColor {
-    /**
-     * Check BackColor and IsLandscape properties, wait for an exception: test
-     * is ok if no exception happened.
-     */
-    @Test public void checkChangeColor() throws Exception {
-        // create a supplier to get the Style family collection
-        XStyleFamiliesSupplier xSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, document);
-
-        // get the NameAccess interface from the Style family collection
-        XNameAccess xNameAccess = xSupplier.getStyleFamilies();
-
-        XNameContainer xPageStyleCollection = UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" ));
-
-        // create a PropertySet to set the properties for the new Pagestyle
-        XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") );
-
-        assertEquals(
-            "BackColor", new Any(Type.LONG, 0xFFFFFFFF),
-            Any.complete(xPropertySet.getPropertyValue("BackColor")));
-        assertEquals(
-            "IsLandscape", new Any(Type.BOOLEAN, false),
-            Any.complete(xPropertySet.getPropertyValue("IsLandscape")));
-        assertEquals(
-            "Size", new Type(Size.class),
-            Any.complete(xPropertySet.getPropertyValue("Size")).getType());
-
-        xPropertySet.setPropertyValue("BackColor", 0xFF000000);
-        xPropertySet.setPropertyValue("IsLandscape", true);
-        assertEquals(
-            "BackColor", new Any(Type.LONG, 0xFF000000),
-            Any.complete(xPropertySet.getPropertyValue("BackColor")));
-        assertEquals(
-            "IsLandscape", new Any(Type.BOOLEAN, true),
-            Any.complete(xPropertySet.getPropertyValue("IsLandscape")));
-    }
-
-    @Before public void setUpDocument() throws com.sun.star.uno.Exception {
-        document = SOfficeFactory.getFactory(
-            UnoRuntime.queryInterface(
-                XMultiServiceFactory.class,
-                connection.getComponentContext().getServiceManager())).
-            createTextDoc(null);
-    }
-
-    @After public void tearDownDocument() {
-        DesktopTools.closeDoc(document);
-    }
-
-    private XTextDocument document = null;
-
-    @BeforeClass public static void setUpConnection() throws Exception {
-        connection.setUp();
-    }
-
-    @AfterClass public static void tearDownConnection()
-        throws InterruptedException, com.sun.star.uno.Exception
-    {
-        connection.tearDown();
-    }
-
-    private static final OfficeConnection connection = new OfficeConnection();
-}
diff --git a/sw/qa/python/check_change_color.py b/sw/qa/python/check_change_color.py
new file mode 100644
index 0000000..add544b
--- /dev/null
+++ b/sw/qa/python/check_change_color.py
@@ -0,0 +1,31 @@
+import unittest
+from org.libreoffice.unotest import UnoInProcess
+
+class CheckChangeColor(unittest.TestCase):
+    _uno = None
+    _xDoc = None
+
+    @classmethod
+    def setUpClass(cls):
+        cls._uno = UnoInProcess()
+        cls._uno.setUp()
+        cls._xEmptyDoc = cls._uno.openEmptyWriterDoc()
+
+    @classmethod
+    def tearDownClass(cls):
+        cls._uno.tearDown()
+
+    def test_change_color(self):
+        xDoc = CheckChangeColor._uno.openEmptyWriterDoc()
+        xPageStyles = xDoc.StyleFamilies["PageStyles"]
+        xPageStyle = xPageStyles["Standard"]
+        self.assertEqual(xPageStyle.BackColor, -1)
+        self.assertEqual(xPageStyle.IsLandscape, False)
+
+        xPageStyle.setPropertyValue("BackColor", 0x000000FF)
+        xPageStyle.setPropertyValue("IsLandscape", True)
+        self.assertEqual(xPageStyle.BackColor, 0x000000FF)
+        self.assertEqual(xPageStyle.IsLandscape, True)
+
+if __name__ == '__main__':
+    unittest.main()


More information about the Libreoffice-commits mailing list