summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShiko <aelshreif7@gmail.com>2020-06-03 06:38:59 +0200
committerAhmed ElShreif <aelshreif7@gmail.com>2020-06-07 14:19:31 +0200
commitd3ae37c935209621d90da6c3a059c0c013adb772 (patch)
tree806d08d1b1badfca301c1ab9574d5f14fa6cdb83
parent24c0efb471479b2f59695333c3bcec4cc44ffb0d (diff)
uitest: Add support for Calc - Set Zoom
Also add a test case for zoom in calc Change-Id: Ic59480a884ed61bfdecdc6b4d509706dde9a194c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95389 Tested-by: Jenkins Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/qa/uitest/calc_tests/zoom.py70
-rw-r--r--sc/source/ui/uitest/uiobject.cxx27
2 files changed, 97 insertions, 0 deletions
diff --git a/sc/qa/uitest/calc_tests/zoom.py b/sc/qa/uitest/calc_tests/zoom.py
new file mode 100644
index 000000000000..647507ef70c9
--- /dev/null
+++ b/sc/qa/uitest/calc_tests/zoom.py
@@ -0,0 +1,70 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+import importlib
+#uitest sc / View-Zoom
+
+class calcZoom(UITestCase):
+ def test_zoom_calc(self):
+ MainDoc = self.ui_test.create_doc_in_start_center("calc")
+ MainWindow = self.xUITest.getTopFocusWindow()
+ gridwin = MainWindow.getChild("grid_window")
+ gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"}))
+ gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+
+ #Set the Zoom to be 100%
+ gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "100"}))
+ self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100")
+
+ #dialog View-Zoom-Zoom
+ self.ui_test.execute_dialog_through_command(".uno:Zoom")
+ xDialog = self.xUITest.getTopFocusWindow()
+
+ #select fit weight & height - OK - open and verify
+ fitwandh = xDialog.getChild("fitwandh")
+ fitwandh.executeAction("CLICK",tuple())
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ self.ui_test.execute_dialog_through_command(".uno:Zoom")
+ xDialog = self.xUITest.getTopFocusWindow()
+ #select fit weight - OK - open and verify
+ fitw = xDialog.getChild("fitw")
+ fitw.executeAction("CLICK",tuple())
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ self.ui_test.execute_dialog_through_command(".uno:Zoom")
+ xDialog = self.xUITest.getTopFocusWindow()
+ #select 100% & Automatic - OK - open and verify
+ x100pc = xDialog.getChild("100pc")
+ x100pc.executeAction("CLICK", tuple())
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+ self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100")
+
+ #Set the Zoom to be 103%
+ gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "103"}))
+ self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "103")
+
+ self.ui_test.execute_dialog_through_command(".uno:Zoom")
+ xDialog = self.xUITest.getTopFocusWindow()
+ #select variable option and make zoom 100% again - OK - open and verify
+ zoomsb = xDialog.getChild("zoomsb")
+ self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%")
+ zoomsb.executeAction("DOWN",tuple())
+ zoomsb.executeAction("DOWN",tuple())
+ zoomsb.executeAction("DOWN",tuple())
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+ self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100")
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file
diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx
index d52a8a75e6ab..0782ea500d28 100644
--- a/sc/source/ui/uitest/uiobject.cxx
+++ b/sc/source/ui/uitest/uiobject.cxx
@@ -20,6 +20,8 @@
#include <navipi.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
#include <sfx2/viewfrm.hxx>
+#include <appoptio.hxx>
+#include <scmod.hxx>
#include <svx/svditer.hxx>
#include <svx/svdobj.hxx>
@@ -72,6 +74,9 @@ StringMap ScGridWinUIObject::get_state()
ScRangeStringConverter::GetStringFromRangeList(aMarkedAreaString, &aMarkedArea, mxGridWindow->getViewData()->GetDocument(), formula::FormulaGrammar::CONV_OOO);
aMap["MarkedArea"] = aMarkedAreaString;
+
+ ScAppOptions aOpt = SC_MOD()->GetAppOptions();
+ aMap["Zoom"] = OUString::number( aOpt.GetZoom() );
return aMap;
}
@@ -221,6 +226,28 @@ void ScGridWinUIObject::execute(const OUString& rAction,
::sfx2::sidebar::Sidebar::ShowPanel(aVal, pViewFrm->GetFrame().GetFrameInterface());
}
}
+ else if (rAction == "SET")
+ {
+ if (rParameters.find("ZOOM") != rParameters.end())
+ {
+ auto itr = rParameters.find("ZOOM");
+ OUString aVal = itr->second;
+ sal_Int32 nVal = aVal.toInt32();
+ ScTabViewShell* pViewShell = getViewShell();
+ ScModule* pScMod = SC_MOD();
+ if( nVal )
+ {
+ ScAppOptions aNewOpt = pScMod->GetAppOptions();
+ aNewOpt.SetZoom( nVal );
+ pScMod->SetAppOptions( aNewOpt );
+ Fraction aFract( nVal, 100 );
+ pViewShell->SetZoom( aFract, aFract, true );
+ pViewShell->PaintGrid();
+ pViewShell->PaintTop();
+ pViewShell->PaintLeft();
+ }
+ }
+ }
else
{
WindowUIObject::execute(rAction, rParameters);