summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSlobodan Vrkacevic <slobodan@froglogic.com>2016-01-21 15:26:26 +0100
committerKatja Marttila <katja.marttila@theqtcompany.com>2016-02-29 12:22:54 +0000
commitb09fa7168314fd5ed0389eeb264c8dfdd2f97a61 (patch)
treef234b4388746015c43a124fbd2948d00b51ff4f2 /tests
parentadfdbb45b128fb7fc3d35da61bb6706551b25f01 (diff)
Allow specifying the installer size in 'em' or 'ex' units
The WizardDefaultWidth and WizardDefaultHeight configuration settings always expected pixel values. This made the installer look somewhat awkward on high DPI displays, in which case the ratio between the font size and the installer window size was such that the fonts looked very big. Let's fix this by allowing to specify the width/height of the installer using units which are defined in terms of the font size, namely 'em' ("The width of the letter M") and 'ex' ("The width of the letter x"). 'px' is supported as well and means the same thing as not specifying any unit at all: the given size is defined in pixels. We choose to *not* use the font width for 'em' and 'ex' to be consistent with what the Qt CSS parser does (see src/gui/text/qcssparser.cpp), which adheres to what the W3C document at https://www.w3.org/WAI/GL/css2em.htm describes. Change-Id: Iaeb5a29c79d437ef4b956cb318158181f6289ec9 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/settings/data/length_units_invalid.xml7
-rw-r--r--tests/auto/installer/settings/data/length_units_valid_em.xml7
-rw-r--r--tests/auto/installer/settings/data/length_units_valid_ex.xml7
-rw-r--r--tests/auto/installer/settings/data/length_units_valid_px.xml7
-rw-r--r--tests/auto/installer/settings/settings.qrc4
-rw-r--r--tests/auto/installer/settings/tst_settings.cpp29
6 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/installer/settings/data/length_units_invalid.xml b/tests/auto/installer/settings/data/length_units_invalid.xml
new file mode 100644
index 000000000..b1dc5aa62
--- /dev/null
+++ b/tests/auto/installer/settings/data/length_units_invalid.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <WizardDefaultWidth>800pt</WizardDefaultWidth>
+ <WizardDefaultHeight>600pt</WizardDefaultHeight>
+</Installer>
diff --git a/tests/auto/installer/settings/data/length_units_valid_em.xml b/tests/auto/installer/settings/data/length_units_valid_em.xml
new file mode 100644
index 000000000..af087fdfe
--- /dev/null
+++ b/tests/auto/installer/settings/data/length_units_valid_em.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <WizardDefaultWidth>800em</WizardDefaultWidth>
+ <WizardDefaultHeight>600em</WizardDefaultHeight>
+</Installer>
diff --git a/tests/auto/installer/settings/data/length_units_valid_ex.xml b/tests/auto/installer/settings/data/length_units_valid_ex.xml
new file mode 100644
index 000000000..3b39cf7a7
--- /dev/null
+++ b/tests/auto/installer/settings/data/length_units_valid_ex.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <WizardDefaultWidth>800ex</WizardDefaultWidth>
+ <WizardDefaultHeight>600ex</WizardDefaultHeight>
+</Installer>
diff --git a/tests/auto/installer/settings/data/length_units_valid_px.xml b/tests/auto/installer/settings/data/length_units_valid_px.xml
new file mode 100644
index 000000000..3553dd7d8
--- /dev/null
+++ b/tests/auto/installer/settings/data/length_units_valid_px.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <WizardDefaultWidth>800px</WizardDefaultWidth>
+ <WizardDefaultHeight>600px</WizardDefaultHeight>
+</Installer>
diff --git a/tests/auto/installer/settings/settings.qrc b/tests/auto/installer/settings/settings.qrc
index c86847993..092805980 100644
--- a/tests/auto/installer/settings/settings.qrc
+++ b/tests/auto/installer/settings/settings.qrc
@@ -9,5 +9,9 @@
<file>data/minimal_config_tag_defaults.xml</file>
<file>data/unexpectedtag_config.xml</file>
<file>data/unexpectedattribute_config.xml</file>
+ <file>data/length_units_valid_px.xml</file>
+ <file>data/length_units_valid_em.xml</file>
+ <file>data/length_units_valid_ex.xml</file>
+ <file>data/length_units_invalid.xml</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp
index 036decc20..38855dccf 100644
--- a/tests/auto/installer/settings/tst_settings.cpp
+++ b/tests/auto/installer/settings/tst_settings.cpp
@@ -23,6 +23,8 @@ private slots:
void loadMinimalConfigTagDefaults();
void loadUnexpectedAttributeConfig();
void loadUnexpectedTagConfig();
+ void loadConfigWithValidLengthUnits();
+ void loadConfigWithInvalidLengthUnits();
};
void tst_Settings::loadTutorialConfig()
@@ -195,6 +197,33 @@ void tst_Settings::loadUnexpectedTagConfig()
return;
}
+void tst_Settings::loadConfigWithValidLengthUnits()
+{
+ try {
+ Settings settings = Settings::fromFileAndPrefix(":///data/length_units_valid_px.xml", ":///data");
+ QCOMPARE(settings.wizardDefaultWidth(), 800);
+ QCOMPARE(settings.wizardDefaultHeight(), 600);
+
+ // Cannot test the parsed values for these units portably since the
+ // pixel value depends on the font metrics. Let's just check for parse
+ // errors.
+ (void)Settings::fromFileAndPrefix(":///data/length_units_valid_em.xml", ":///data");
+ (void)Settings::fromFileAndPrefix(":///data/length_units_valid_ex.xml", ":///data");
+ } catch (const Error &error) {
+ QFAIL(qPrintable(QString::fromLatin1("Exception caught: %1").arg(error.message())));
+ }
+}
+
+void tst_Settings::loadConfigWithInvalidLengthUnits()
+{
+ try {
+ Settings settings = Settings::fromFileAndPrefix(":///data/length_units_invalid.xml", ":///data");
+ QCOMPARE(settings.wizardDefaultWidth(), 0);
+ QCOMPARE(settings.wizardDefaultHeight(), 0);
+ } catch (const Error &error) {
+ QFAIL(qPrintable(QString::fromLatin1("Exception caught: %1").arg(error.message())));
+ }
+}
QTEST_MAIN(tst_Settings)