Merge branch 'development' into cmake/SPEC-7484

This commit is contained in:
Esteban Papp
2021-08-10 14:30:07 -07:00
153 changed files with 5217 additions and 2016 deletions
@@ -22,8 +22,6 @@ namespace AzQtComponents
QApplication::setApplicationName("O3DE Tools Application");
AzQtComponents::PrepareQtPaths();
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
}
void AzQtApplication::InitializeDpiScaling()
@@ -129,8 +129,6 @@ int main(int argc, char **argv)
QApplication::setOrganizationDomain("o3de.org");
QApplication::setApplicationName("O3DEWidgetGallery");
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
@@ -13,54 +13,94 @@
TEST(AzQtComponents, FloatToString_Truncate2Decimals)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = false;
const int numDecimalPlaces = 2;
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocal, showThousandsSeparator), "0.12");
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator), "0.12");
}
TEST(AzQtComponents, FloatToString_AllZerosButOne)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = false;
int numDecimalPlaces = 2;
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
}
TEST(AzQtComponents, FloatToString_TruncateAllZerosButOne)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = false;
int numDecimalPlaces = 2;
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
}
TEST(AzQtComponents, FloatToString_TruncateNotRound)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = false;
int numDecimalPlaces = 3;
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "0.123");
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "0.123");
}
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRound)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = true;
int numDecimalPlaces = 3;
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.123");
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.123");
}
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimal)
{
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
const bool showThousandsSeparator = true;
int numDecimalPlaces = 2;
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.0");
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.0");
}
TEST(AzQtComponents, FloatToString_Truncate2DecimalsWithLocale)
{
QLocale testLocale{ QLocale() };
const bool showThousandsSeparator = false;
const int numDecimalPlaces = 2;
QString testString = "0" + QString(testLocale.decimalPoint()) + "12";
EXPECT_EQ(testString, AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator));
}
TEST(AzQtComponents, FloatToString_AllZerosButOneWithLocale)
{
QLocale testLocale{ QLocale() };
const bool showThousandsSeparator = false;
const int numDecimalPlaces = 2;
QString testString = "1" + QString(testLocale.decimalPoint()) + "0";
EXPECT_EQ(testString, AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator));
}
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRoundWithLocale)
{
QLocale testLocale{ QLocale() };
const bool showThousandsSeparator = true;
const int numDecimalPlaces = 3;
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "123";
EXPECT_EQ(testString, AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator));
}
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimalWithLocale)
{
QLocale testLocale{ QLocale() };
const bool showThousandsSeparator = true;
int numDecimalPlaces = 2;
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "0";
EXPECT_EQ(testString, AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator));
}