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

rm TestComboProperty

parent f9a37a6c
No related branches found
No related tags found
1 merge request!2669ComboProperty: rm many unused member fcts and operators
Pipeline #151664 passed
#include "GUI/Model/Descriptor/ComboProperty.h"
#include "Tests/GTestWrapper/google_test.h"
#include "Tests/Unit/GUI/Utils.h"
//! Helper class to register custom variants comparators and to report
//! unit tests if comparators should be tested.
class Comparators {
public:
static void registerComparators() { m_is_registered = true; }
static bool registered() { return m_is_registered; }
private:
static bool m_is_registered;
};
bool Comparators::m_is_registered = false;
class TestComboProperty : public ::testing::Test {
public:
TestComboProperty() { Comparators::registerComparators(); }
};
TEST_F(TestComboProperty, initialState)
{
ComboProperty combo;
EXPECT_EQ(combo.currentValue(), "");
EXPECT_EQ(combo.values(), QStringList());
EXPECT_EQ(combo.toolTips(), QStringList());
EXPECT_EQ(combo.currentIndex(), -1);
}
TEST_F(TestComboProperty, factoryMethods)
{
// initialization from list sets values only, no index selected
QStringList expected = QStringList() << "a1"
<< "a2";
ComboProperty combo = ComboProperty::fromList(expected);
EXPECT_EQ(combo.values(), expected);
EXPECT_EQ(combo.currentIndex(), -1);
EXPECT_EQ(combo.currentValue(), "");
}
TEST_F(TestComboProperty, setValues)
{
// seting values through stream
QStringList expectedValues = QStringList() << "a1"
<< "a2";
ComboProperty combo = ComboProperty() << expectedValues;
EXPECT_EQ(combo.values(), expectedValues);
EXPECT_EQ(combo.currentValue(), "a1");
EXPECT_EQ(combo.currentIndex(), 0);
// setting values from setter, old values have to be overriden
QStringList newValues = QStringList() << "b1"
<< "b2"
<< "b3";
combo.setValues(newValues);
EXPECT_EQ(combo.currentValue(), "b1");
EXPECT_EQ(combo.values(), newValues);
EXPECT_EQ(combo.currentIndex(), 0);
// setting new/old values through setter, old value should be preserved
newValues = QStringList() << "c1"
<< "b1"
<< "c2";
combo.setValues(newValues);
EXPECT_EQ(combo.currentValue(), "b1");
EXPECT_EQ(combo.values(), newValues);
EXPECT_EQ(combo.currentIndex(), 1);
}
TEST_F(TestComboProperty, setCurrentIndex)
{
ComboProperty combo;
EXPECT_EQ(combo.currentIndex(), -1);
combo << "c1"
<< "c2";
EXPECT_EQ(combo.currentIndex(), 0);
combo.setCurrentValue("c2");
EXPECT_EQ(combo.currentIndex(), 1);
combo.setCurrentIndex(0);
EXPECT_EQ(combo.currentValue(), "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