[Libreoffice-commits] core.git: 2 commits - include/svx svx/inc svx/Library_svx.mk svx/source uitest/test_main.py
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Jun 24 22:19:56 UTC 2016
include/svx/charmap.hxx | 2 +
svx/Library_svx.mk | 1
svx/inc/uiobject.hxx | 34 ++++++++++++++++++++
svx/source/dialog/charmap.cxx | 7 ++++
svx/source/uitest/uiobject.cxx | 68 +++++++++++++++++++++++++++++++++++++++++
uitest/test_main.py | 34 ++++++++++++--------
6 files changed, 132 insertions(+), 14 deletions(-)
New commits:
commit 46773b0b59bb9061c5f5660e65e4ebc0d455fe02
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jun 25 00:17:33 2016 +0200
uitest: add a mode to just run one file
Change-Id: I99906dfc34ebcb7ab0ce76ca446435ae0902443f
diff --git a/uitest/test_main.py b/uitest/test_main.py
index 41a1b16..4939d05 100644
--- a/uitest/test_main.py
+++ b/uitest/test_main.py
@@ -19,7 +19,7 @@ from connection import PersistentConnection, OfficeConnection
def parseArgs(argv):
(optlist,args) = getopt.getopt(argv[1:], "hr",
- ["help", "soffice=", "userdir=", "dir="])
+ ["help", "soffice=", "userdir=", "dir=", "file="])
return (dict(optlist), args)
def usage():
@@ -63,22 +63,24 @@ def get_test_case_classes_of_module(module):
classes = get_classes_of_module(module)
return [ c for c in classes if issubclass(c, UITestCase) ]
-def get_test_suite(opts):
+def add_tests_for_file(test_file, test_suite):
test_loader = unittest.TestLoader()
+ module_name = os.path.splitext(os.path.split(test_file)[1])[0]
+ loader = importlib.machinery.SourceFileLoader(module_name, test_file)
+ mod = loader.load_module()
+ classes = get_test_case_classes_of_module(mod)
+ for c in classes:
+ test_names = test_loader.getTestCaseNames(c)
+ for test_name in test_names:
+ obj = c(test_name, opts)
+ test_suite.addTest(obj)
+
+def get_test_suite_for_dir(opts):
test_suite = unittest.TestSuite()
valid_test_files = find_test_files(opts['--dir'])
for test_file in valid_test_files:
- module_name = os.path.splitext(os.path.split(test_file)[1])[0]
- loader = importlib.machinery.SourceFileLoader(module_name, test_file)
- mod = loader.load_module()
- classes = get_test_case_classes_of_module(mod)
- for c in classes:
- test_names = test_loader.getTestCaseNames(c)
- for test_name in test_names:
- obj = c(test_name, opts)
- test_suite.addTest(obj)
-
+ add_tests_for_file(test_file, test_suite)
return test_suite
@@ -90,10 +92,14 @@ if __name__ == '__main__':
elif not "--soffice" in opts:
usage()
sys.exit(1)
- elif not "--dir" in opts:
+ elif "--dir" in opts:
+ test_suite = get_test_suite_for_dir(opts)
+ elif "--file" in opts:
+ test_suite = unittest.TestSuite()
+ add_tests_for_file(opts['--file'], test_suite)
+ else:
usage()
sys.exit()
- test_suite = get_test_suite(opts)
result = unittest.TextTestRunner(verbosity=2).run(test_suite)
print("Tests run: %d" % result.testsRun)
commit 6db92434c664116eb1ec6cb127f2cd957a03bb65
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jun 25 00:16:45 2016 +0200
uitest: add wrapper for special character window
Change-Id: I22acd9da3570e967f427207e242638f2bfd6ffb7
diff --git a/include/svx/charmap.hxx b/include/svx/charmap.hxx
index 5de50c7..fbdf77c 100644
--- a/include/svx/charmap.hxx
+++ b/include/svx/charmap.hxx
@@ -74,6 +74,8 @@ public:
virtual void Resize() override;
+ virtual FactoryFunction GetUITestFactory() const override;
+
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) override;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index c026002..047eb9d 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -241,6 +241,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/tbxctrls/tbxcolor \
svx/source/tbxctrls/tbxdrctl \
svx/source/tbxctrls/verttexttbxctrl \
+ svx/source/uitest/uiobject \
svx/source/unodraw/recoveryui \
svx/source/unodraw/unoctabl \
svx/source/unodraw/UnoNamespaceMap \
diff --git a/svx/inc/uiobject.hxx b/svx/inc/uiobject.hxx
new file mode 100644
index 0000000..2e90385
--- /dev/null
+++ b/svx/inc/uiobject.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <vcl/uitest/uiobject.hxx>
+
+class SvxShowCharSet;
+
+class SvxShowCharSetUIObject : WindowUIObject
+{
+ VclPtr<SvxShowCharSet> mxCharSet;
+
+public:
+
+ SvxShowCharSetUIObject(VclPtr<SvxShowCharSet> xCharSet);
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ OUString get_name() const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index 3076deb..f214b0d 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -33,6 +33,8 @@
#include <svx/svxdlg.hxx>
#include "charmapacc.hxx"
+#include "uiobject.hxx"
+
#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -745,6 +747,11 @@ sal_Int32 SvxShowCharSet::getMaxCharCount() const
return mxFontCharMap->GetCharCount();
}
+FactoryFunction SvxShowCharSet::GetUITestFactory() const
+{
+ return SvxShowCharSetUIObject::create;
+}
+
// TODO: should be moved into Font Attributes stuff
// we let it mature here though because it is currently the only use
diff --git a/svx/source/uitest/uiobject.cxx b/svx/source/uitest/uiobject.cxx
new file mode 100644
index 0000000..dc5db9e
--- /dev/null
+++ b/svx/source/uitest/uiobject.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include "uiobject.hxx"
+
+#include <svx/charmap.hxx>
+
+SvxShowCharSetUIObject::SvxShowCharSetUIObject(VclPtr<SvxShowCharSet> xCharSet):
+ WindowUIObject(xCharSet),
+ mxCharSet(xCharSet)
+{
+}
+
+StringMap SvxShowCharSetUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+
+ return aMap;
+}
+
+void SvxShowCharSetUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "SELECT")
+ {
+ if (rParameters.find("INDEX") != rParameters.end())
+ {
+ OUString aIndexStr = rParameters.find("INDEX")->second;
+
+ sal_Int32 nIndex = aIndexStr.toInt32();
+ mxCharSet->OutputIndex(nIndex);
+ }
+ else if (rParameters.find("COLUMN") != rParameters.end() &&
+ rParameters.find("ROW") != rParameters.end())
+ {
+ OUString aColStr = rParameters.find("COLUMN")->second;
+ OUString aRowStr = rParameters.find("ROW")->second;
+
+ sal_Int32 nColumn = aColStr.toInt32();
+ sal_Int32 nRow = aRowStr.toInt32();
+
+ sal_Int32 nIndex = nColumn * COLUMN_COUNT + nRow;
+ mxCharSet->OutputIndex(nIndex);
+ }
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> SvxShowCharSetUIObject::create(vcl::Window* pWindow)
+{
+ SvxShowCharSet* pCharSet = dynamic_cast<SvxShowCharSet*>(pWindow);
+ assert(pCharSet);
+ return std::unique_ptr<UIObject>(new SvxShowCharSetUIObject(pCharSet));
+}
+
+OUString SvxShowCharSetUIObject::get_name() const
+{
+ return OUString("SvxShowCharSetUIObject");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list