Skip to content
Snippets Groups Projects
Commit 4af31f8a authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ComboProperty: rm unused fct selectedIndices

parent 604ad985
No related branches found
No related tags found
1 merge request!2669ComboProperty: rm many unused member fcts and operators
...@@ -51,8 +51,6 @@ public: ...@@ -51,8 +51,6 @@ public:
QVariant variant() const; QVariant variant() const;
QVector<int> selectedIndices() const { return m_selected_indices; }
void setSelected(int index, bool value = true); void setSelected(int index, bool value = true);
void setSelected(const QString& name, bool value = true); void setSelected(const QString& name, bool value = true);
......
...@@ -28,7 +28,6 @@ TEST_F(TestComboProperty, initialState) ...@@ -28,7 +28,6 @@ TEST_F(TestComboProperty, initialState)
EXPECT_EQ(combo.values(), QStringList()); EXPECT_EQ(combo.values(), QStringList());
EXPECT_EQ(combo.toolTips(), QStringList()); EXPECT_EQ(combo.toolTips(), QStringList());
EXPECT_EQ(combo.currentIndex(), -1); EXPECT_EQ(combo.currentIndex(), -1);
EXPECT_EQ(combo.selectedIndices(), QVector<int>());
} }
TEST_F(TestComboProperty, factoryMethods) TEST_F(TestComboProperty, factoryMethods)
...@@ -40,7 +39,6 @@ TEST_F(TestComboProperty, factoryMethods) ...@@ -40,7 +39,6 @@ TEST_F(TestComboProperty, factoryMethods)
EXPECT_EQ(combo.values(), expected); EXPECT_EQ(combo.values(), expected);
EXPECT_EQ(combo.currentIndex(), -1); EXPECT_EQ(combo.currentIndex(), -1);
EXPECT_EQ(combo.currentValue(), ""); EXPECT_EQ(combo.currentValue(), "");
EXPECT_EQ(combo.selectedIndices(), QVector<int>());
} }
TEST_F(TestComboProperty, setValues) TEST_F(TestComboProperty, setValues)
...@@ -52,7 +50,6 @@ TEST_F(TestComboProperty, setValues) ...@@ -52,7 +50,6 @@ TEST_F(TestComboProperty, setValues)
EXPECT_EQ(combo.values(), expectedValues); EXPECT_EQ(combo.values(), expectedValues);
EXPECT_EQ(combo.currentValue(), "a1"); EXPECT_EQ(combo.currentValue(), "a1");
EXPECT_EQ(combo.currentIndex(), 0); EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
// setting values from setter, old values have to be overriden // setting values from setter, old values have to be overriden
QStringList newValues = QStringList() << "b1" QStringList newValues = QStringList() << "b1"
...@@ -62,7 +59,6 @@ TEST_F(TestComboProperty, setValues) ...@@ -62,7 +59,6 @@ TEST_F(TestComboProperty, setValues)
EXPECT_EQ(combo.currentValue(), "b1"); EXPECT_EQ(combo.currentValue(), "b1");
EXPECT_EQ(combo.values(), newValues); EXPECT_EQ(combo.values(), newValues);
EXPECT_EQ(combo.currentIndex(), 0); EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
// setting new/old values through setter, old value should be preserved // setting new/old values through setter, old value should be preserved
newValues = QStringList() << "c1" newValues = QStringList() << "c1"
...@@ -72,7 +68,6 @@ TEST_F(TestComboProperty, setValues) ...@@ -72,7 +68,6 @@ TEST_F(TestComboProperty, setValues)
EXPECT_EQ(combo.currentValue(), "b1"); EXPECT_EQ(combo.currentValue(), "b1");
EXPECT_EQ(combo.values(), newValues); EXPECT_EQ(combo.values(), newValues);
EXPECT_EQ(combo.currentIndex(), 1); EXPECT_EQ(combo.currentIndex(), 1);
EXPECT_EQ(combo.selectedIndices(), QVector<int>({1}));
} }
TEST_F(TestComboProperty, setCurrentIndex) TEST_F(TestComboProperty, setCurrentIndex)
...@@ -83,55 +78,13 @@ TEST_F(TestComboProperty, setCurrentIndex) ...@@ -83,55 +78,13 @@ TEST_F(TestComboProperty, setCurrentIndex)
combo << "c1" combo << "c1"
<< "c2"; << "c2";
EXPECT_EQ(combo.currentIndex(), 0); EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
combo.setCurrentValue("c2"); combo.setCurrentValue("c2");
EXPECT_EQ(combo.currentIndex(), 1); EXPECT_EQ(combo.currentIndex(), 1);
EXPECT_EQ(combo.selectedIndices(), QVector<int>({1}));
combo.setCurrentIndex(0); combo.setCurrentIndex(0);
EXPECT_EQ(combo.currentValue(), "c1"); EXPECT_EQ(combo.currentValue(), "c1");
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
} }
TEST_F(TestComboProperty, selectedIndices)
{
QStringList expectedValues = QStringList() << "a1"
<< "a2"
<< "a3";
ComboProperty combo = ComboProperty() << expectedValues;
EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.currentValue(), "a1");
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
// selecting already selected element, nothing should change
combo.setSelected(0);
EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.currentValue(), "a1");
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0}));
// deselecting index
combo.setSelected(0, false);
EXPECT_EQ(combo.currentIndex(), -1);
EXPECT_EQ(combo.currentValue(), "");
EXPECT_EQ(combo.selectedIndices(), QVector<int>());
// selecting two indeces
combo.setSelected(1, true);
combo.setSelected(2, true);
EXPECT_EQ(combo.currentIndex(), 1);
EXPECT_EQ(combo.currentValue(), "a2");
EXPECT_EQ(combo.selectedIndices(), QVector<int>({1, 2}));
// selecting by name
combo.setSelected("a2", false);
combo.setSelected("a1", true);
EXPECT_EQ(combo.currentIndex(), 0);
EXPECT_EQ(combo.currentValue(), "a1");
EXPECT_EQ(combo.selectedIndices(), QVector<int>({0, 2}));
}
TEST_F(TestComboProperty, comboEquality) TEST_F(TestComboProperty, comboEquality)
{ {
ComboProperty c1; ComboProperty c1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment