summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorRafael Lima <rafael.palma.lima@gmail.com>2024-04-01 14:46:35 +0100
committerTomaž Vajngerl <quikee@gmail.com>2024-04-08 16:03:03 +0200
commit2533960315607bf3e86ad014d2daa4bfa7e3fa59 (patch)
treec50124a2f6cf99cefc5b9aac19dbf076defe8606 /sc/qa
parent1e1b1d46155163380252093d9d2868351236ce0e (diff)
tdf#160064 Hide named ranges/expressions of solver models
Prior to this patch, all named ranges/expressions associated with solver models were visible by default, which clutters the UI with various names in the Manage Names dialog. Now all such named ranges/expressions are hidden by default, thus mimicking what MSO does. Change-Id: I79727b375c48527632c4967d174c61f99ff41050 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165621 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/uitest/data/tdf160104.odsbin18176 -> 19481 bytes
-rw-r--r--sc/qa/uitest/solver/solver.py57
-rw-r--r--sc/qa/unit/data/ods/SolverModel.odsbin0 -> 19482 bytes
-rw-r--r--sc/qa/unit/ucalc_solver.cxx24
4 files changed, 81 insertions, 0 deletions
diff --git a/sc/qa/uitest/data/tdf160104.ods b/sc/qa/uitest/data/tdf160104.ods
index a98340f80a50..ea8f23bb4791 100644
--- a/sc/qa/uitest/data/tdf160104.ods
+++ b/sc/qa/uitest/data/tdf160104.ods
Binary files differ
diff --git a/sc/qa/uitest/solver/solver.py b/sc/qa/uitest/solver/solver.py
index 2a164b90f6c5..ed8132b0f205 100644
--- a/sc/qa/uitest/solver/solver.py
+++ b/sc/qa/uitest/solver/solver.py
@@ -132,4 +132,61 @@ class solver(UITestCase):
# Here isModified needs to be True because changes were made to the Solver dialog
self.assertTrue(calc_doc.isModified())
+
+ # Tests whether all solver named ranges are hidden in the UI
+ def test_tdf160064(self):
+ # This test uses the same file from bug tdf#160104, so no need to check if the model is correct upon opening
+ with self.ui_test.load_file(get_url_for_data_file("tdf160104.ods")) as calc_doc:
+ # The Manage Names dialog must not contain any names
+ with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog:
+ xList = xDialog.getChild("names")
+ self.assertEqual('0', get_state_as_dict(xList)['Children'])
+
+ # Makes a small change in the solver dialog by clicking the "Minimize" button
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:SolverDialog", close_button="") as xDialog:
+ xMin = xDialog.getChild("min")
+ xMin.executeAction("CLICK", ())
+ # Closes the dialog
+ xCloseBtn = xDialog.getChild("close")
+ xCloseBtn.executeAction("CLICK", ())
+
+ # Here the file has been modified and needs to be saved and reloaded
+ self.assertTrue(calc_doc.isModified())
+ self.xUITest.executeCommand('.uno:Save')
+ self.xUITest.executeCommand('.uno:Reload')
+
+ # Open the Solver dialog and check whether the model is loaded correctly
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:SolverDialog", close_button="") as xDialog:
+ xTargetEdit = xDialog.getChild("targetedit")
+ xMin = xDialog.getChild("min")
+ xChangeEdit = xDialog.getChild("changeedit")
+ xRef1Edit = xDialog.getChild("ref1edit")
+ xVal1Edit = xDialog.getChild("val1edit")
+ xOp1List = xDialog.getChild("op1list")
+ xRef2Edit = xDialog.getChild("ref2edit")
+ xVal2Edit = xDialog.getChild("val2edit")
+ xOp2List = xDialog.getChild("op2list")
+
+ # Checks whether the solver model was loaded correctly
+ self.assertEqual("$F$2", get_state_as_dict(xTargetEdit)["Text"])
+ self.assertEqual("true", get_state_as_dict(xMin)["Checked"])
+ self.assertEqual("$D$2:$D$11", get_state_as_dict(xChangeEdit)["Text"])
+ self.assertEqual("$F$5", get_state_as_dict(xRef1Edit)["Text"])
+ self.assertEqual("$F$8", get_state_as_dict(xVal1Edit)["Text"])
+ self.assertEqual("≤", get_state_as_dict(xOp1List)["SelectEntryText"])
+ self.assertEqual("$D$2:$D$11", get_state_as_dict(xRef2Edit)["Text"])
+ self.assertEqual("", get_state_as_dict(xVal2Edit)["Text"])
+ self.assertEqual("Binary", get_state_as_dict(xOp2List)["SelectEntryText"])
+
+ # Closes the dialog
+ xCloseBtn = xDialog.getChild("close")
+ xCloseBtn.executeAction("CLICK", ())
+
+ # Open the Manage Names dialog again; it must not contain any names
+ with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog:
+ xList = xDialog.getChild("names")
+ self.assertEqual('0', get_state_as_dict(xList)['Children'])
+
+
+
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/unit/data/ods/SolverModel.ods b/sc/qa/unit/data/ods/SolverModel.ods
new file mode 100644
index 000000000000..9ebfa69d4e44
--- /dev/null
+++ b/sc/qa/unit/data/ods/SolverModel.ods
Binary files differ
diff --git a/sc/qa/unit/ucalc_solver.cxx b/sc/qa/unit/ucalc_solver.cxx
index f7db19cad59a..06feb5347db4 100644
--- a/sc/qa/unit/ucalc_solver.cxx
+++ b/sc/qa/unit/ucalc_solver.cxx
@@ -216,4 +216,28 @@ CPPUNIT_TEST_FIXTURE(SolverTest, tdf156814)
CPPUNIT_ASSERT_EQUAL(OUString("0"), aConstraints[2].aRightStr);
}
+// Tests if all named ranges and expressions are hidden in the existing model
+CPPUNIT_TEST_FIXTURE(SolverTest, tdf160064)
+{
+ createScDoc("ods/SolverModel.ods");
+ ScDocument* pDoc = getScDoc();
+
+ ScTable* pTable = pDoc->FetchTable(0);
+ ScRangeName* pNamedRanges = pTable->GetRangeName();
+ ScRangeName::const_iterator it = pNamedRanges->begin();
+
+ // There are 34 hidden named ranges and expressions in the file
+ CPPUNIT_ASSERT_EQUAL(size_t(34), pNamedRanges->size());
+
+ // All named ranges and expressions are hidden in the file
+ while (it != pNamedRanges->end())
+ {
+ OUString sName = it->first;
+ ScRangeData* pRangeData
+ = pNamedRanges->findByUpperName(ScGlobal::getCharClass().uppercase(sName));
+ CPPUNIT_ASSERT(pRangeData->HasType(ScRangeData::Type::Hidden));
+ it++;
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();