From 6c06e14a49773ce5572935864ed6b9be219c6103 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 May 2012 18:02:16 +0200 Subject: QIcon: move back to QtGui - Move the files and tests git mv src/widgets/kernel/qicon* qrc/gui/image/ git mv tests/auto/widgets/kernel/qicon/ tests/auto/gui/image/ - update the include of QIcon git grep -O"sed -i s,QtWidgets/qicon,QtGui/qicon," "QtWidgets/qicon" git grep -O"sed -i s,QtWidgets/QIcon,QtGui/QIcon," "QtWidgets/QIcon" - Adapt QIcon \ingroup documentation sed -i s/QtWidgets/QtGui/ src/gui/images/qicon* - Adapt export macro sed -i s/Q_WIDGETS_EXPORT/Q_GUI_EXPORT/g src/gui/image/qicon* - Update .pri and .pro files - Remove the use of QStyle::alignedRect by copying its content (and adapt slightly - Use QGuiApplication::palette() instead of QApplication::palette() - Add a hook in QGuiApplicationPrivate to call the QStyle::generatedIconPixmap() from QtWidgets Another commit follows to adjust QMetaType::Icon and move the QVariant and QMetaType icon handler back in QtGui Change-Id: I1b63759f892ebc02dfc30f41bb6e76e0b7451182 Reviewed-by: Lars Knoll Reviewed-by: Girish Ramakrishnan --- tests/auto/gui/image/image.pro | 1 + tests/auto/gui/image/qicon/.gitignore | 1 + .../testtheme/16x16/actions/appointment-new.png | Bin 0 -> 897 bytes .../testtheme/22x22/actions/appointment-new.png | Bin 0 -> 1411 bytes .../testtheme/32x32/actions/appointment-new.png | Bin 0 -> 2399 bytes .../gui/image/qicon/icons/testtheme/index.theme | 492 ++++++++++++++++ .../icons/testtheme/scalable/actions/svg-only.svg | 425 ++++++++++++++ .../themeparent/16x16/actions/address-book-new.png | Bin 0 -> 796 bytes .../themeparent/16x16/actions/appointment-new.png | Bin 0 -> 897 bytes .../themeparent/22x22/actions/address-book-new.png | Bin 0 -> 924 bytes .../themeparent/22x22/actions/appointment-new.png | Bin 0 -> 1411 bytes .../themeparent/32x32/actions/address-book-new.png | Bin 0 -> 1897 bytes .../themeparent/32x32/actions/appointment-new.png | Bin 0 -> 2399 bytes .../gui/image/qicon/icons/themeparent/index.theme | 492 ++++++++++++++++ .../scalable/actions/address-book-new.svg | 389 +++++++++++++ .../scalable/actions/appointment-new.svg | 425 ++++++++++++++ tests/auto/gui/image/qicon/image.png | Bin 0 -> 14743 bytes tests/auto/gui/image/qicon/qicon.pro | 12 + tests/auto/gui/image/qicon/rect.png | Bin 0 -> 175 bytes tests/auto/gui/image/qicon/tst_qicon.cpp | 637 +++++++++++++++++++++ tests/auto/gui/image/qicon/tst_qicon.qrc | 20 + tests/auto/widgets/kernel/kernel.pro | 1 - tests/auto/widgets/kernel/qicon/.gitignore | 1 - .../testtheme/16x16/actions/appointment-new.png | Bin 897 -> 0 bytes .../testtheme/22x22/actions/appointment-new.png | Bin 1411 -> 0 bytes .../testtheme/32x32/actions/appointment-new.png | Bin 2399 -> 0 bytes .../kernel/qicon/icons/testtheme/index.theme | 492 ---------------- .../icons/testtheme/scalable/actions/svg-only.svg | 425 -------------- .../themeparent/16x16/actions/address-book-new.png | Bin 796 -> 0 bytes .../themeparent/16x16/actions/appointment-new.png | Bin 897 -> 0 bytes .../themeparent/22x22/actions/address-book-new.png | Bin 924 -> 0 bytes .../themeparent/22x22/actions/appointment-new.png | Bin 1411 -> 0 bytes .../themeparent/32x32/actions/address-book-new.png | Bin 1897 -> 0 bytes .../themeparent/32x32/actions/appointment-new.png | Bin 2399 -> 0 bytes .../kernel/qicon/icons/themeparent/index.theme | 492 ---------------- .../scalable/actions/address-book-new.svg | 389 ------------- .../scalable/actions/appointment-new.svg | 425 -------------- tests/auto/widgets/kernel/qicon/image.png | Bin 14743 -> 0 bytes tests/auto/widgets/kernel/qicon/qicon.pro | 12 - tests/auto/widgets/kernel/qicon/rect.png | Bin 175 -> 0 bytes tests/auto/widgets/kernel/qicon/tst_qicon.cpp | 637 --------------------- tests/auto/widgets/kernel/qicon/tst_qicon.qrc | 20 - 42 files changed, 2894 insertions(+), 2894 deletions(-) create mode 100644 tests/auto/gui/image/qicon/.gitignore create mode 100644 tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/testtheme/index.theme create mode 100644 tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/index.theme create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg create mode 100644 tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg create mode 100644 tests/auto/gui/image/qicon/image.png create mode 100644 tests/auto/gui/image/qicon/qicon.pro create mode 100644 tests/auto/gui/image/qicon/rect.png create mode 100644 tests/auto/gui/image/qicon/tst_qicon.cpp create mode 100644 tests/auto/gui/image/qicon/tst_qicon.qrc delete mode 100644 tests/auto/widgets/kernel/qicon/.gitignore delete mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme delete mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg delete mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg delete mode 100644 tests/auto/widgets/kernel/qicon/image.png delete mode 100644 tests/auto/widgets/kernel/qicon/qicon.pro delete mode 100644 tests/auto/widgets/kernel/qicon/rect.png delete mode 100644 tests/auto/widgets/kernel/qicon/tst_qicon.cpp delete mode 100644 tests/auto/widgets/kernel/qicon/tst_qicon.qrc (limited to 'tests') diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro index 5a03063f47..1ef52df4ba 100644 --- a/tests/auto/gui/image/image.pro +++ b/tests/auto/gui/image/image.pro @@ -9,6 +9,7 @@ SUBDIRS=\ qimagewriter \ qmovie \ qpicture \ + qicon \ !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qpixmapcache \ diff --git a/tests/auto/gui/image/qicon/.gitignore b/tests/auto/gui/image/qicon/.gitignore new file mode 100644 index 0000000000..c101ef9d28 --- /dev/null +++ b/tests/auto/gui/image/qicon/.gitignore @@ -0,0 +1 @@ +tst_qicon diff --git a/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png new file mode 100644 index 0000000000..18b7c6781e Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png new file mode 100644 index 0000000000..d676ffd463 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png new file mode 100644 index 0000000000..85daef3b0b Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/index.theme b/tests/auto/gui/image/qicon/icons/testtheme/index.theme new file mode 100644 index 0000000000..e18736ab43 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/testtheme/index.theme @@ -0,0 +1,492 @@ +[Icon Theme] +_Name=Test +_Comment=Test Theme +Inherits=crystalsvg, themeparent +Example=x-directory-normal + +# KDE Specific Stuff +DisplayDepth=32 +LinkOverlay=link_overlay +LockOverlay=lock_overlay +ZipOverlay=zip_overlay +DesktopDefault=48 +DesktopSizes=16,22,32,48,64,72,96,128 +ToolbarDefault=22 +ToolbarSizes=16,22,32,48 +MainToolbarDefault=22 +MainToolbarSizes=16,22,32,48 +SmallDefault=16 +SmallSizes=16 +PanelDefault=32 +PanelSizes=16,22,32,48,64,72,96,128 + +# Directory list +Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[16x16/apps] +Size=16 +Context=Applications +Type=Fixed + +[16x16/categories] +Size=16 +Context=Categories +Type=Fixed + +[16x16/devices] +Size=16 +Context=Devices +Type=Fixed + +[16x16/emblems] +Size=16 +Context=Emblems +Type=Fixed + +[16x16/emotes] +Size=16 +Context=Emotes +Type=Fixed + +[16x16/mimetypes] +Size=16 +Context=MimeTypes +Type=Fixed + +[16x16/places] +Size=16 +Context=Places +Type=Fixed + +[16x16/status] +Size=16 +Context=Status +Type=Fixed + +[22x22/actions] +Size=22 +Context=Actions +Type=Fixed + +[22x22/apps] +Size=22 +Context=Applications +Type=Fixed + +[22x22/categories] +Size=22 +Context=Categories +Type=Fixed + +[22x22/devices] +Size=22 +Context=Devices +Type=Fixed + +[22x22/emblems] +Size=22 +Context=Emblems +Type=Fixed + +[22x22/emotes] +Size=22 +Context=Emotes +Type=Fixed + +[22x22/mimetypes] +Size=22 +Context=MimeTypes +Type=Fixed + +[22x22/places] +Size=22 +Context=Places +Type=Fixed + +[22x22/status] +Size=22 +Context=Status +Type=Fixed + +[24x24/actions] +Size=24 +Context=Actions +Type=Fixed + +[24x24/apps] +Size=24 +Context=Applications +Type=Fixed + +[24x24/categories] +Size=24 +Context=Categories +Type=Fixed + +[24x24/devices] +Size=24 +Context=Devices +Type=Fixed + +[24x24/emblems] +Size=24 +Context=Emblems +Type=Fixed + +[24x24/emotes] +Size=24 +Context=Emotes +Type=Fixed + +[24x24/mimetypes] +Size=24 +Context=MimeTypes +Type=Fixed + +[24x24/places] +Size=24 +Context=Places +Type=Fixed + +[24x24/status] +Size=24 +Context=Status +Type=Fixed + +[32x32/actions] +Size=32 +Context=Actions +Type=Fixed + +[32x32/apps] +Size=32 +Context=Applications +Type=Fixed + +[32x32/categories] +Size=32 +Context=Categories +Type=Fixed + +[32x32/devices] +Size=32 +Context=Devices +Type=Fixed + +[32x32/emblems] +Size=32 +Context=Emblems +Type=Fixed + +[32x32/emotes] +Size=32 +Context=Emotes +Type=Fixed + +[32x32/mimetypes] +Size=32 +Context=MimeTypes +Type=Fixed + +[32x32/places] +Size=32 +Context=Places +Type=Fixed + +[32x32/status] +Size=32 +Context=Status +Type=Fixed + +[48x48/actions] +Size=48 +Context=Actions +Type=Fixed + +[48x48/apps] +Size=48 +Context=Applications +Type=Fixed + +[48x48/categories] +Size=48 +Context=Categories +Type=Fixed + +[48x48/devices] +Size=48 +Context=Devices +Type=Fixed + +[48x48/emblems] +Size=48 +Context=Emblems +Type=Fixed + +[48x48/emotes] +Size=48 +Context=Emotes +Type=Fixed + +[48x48/mimetypes] +Size=48 +Context=MimeTypes +Type=Fixed + +[48x48/places] +Size=48 +Context=Places +Type=Fixed + +[48x48/status] +Size=48 +Context=Status +Type=Fixed + +[64x64/actions] +Size=64 +Context=Actions +Type=Fixed + +[64x64/apps] +Size=64 +Context=Applications +Type=Fixed + +[64x64/categories] +Size=64 +Context=Categories +Type=Fixed + +[64x64/devices] +Size=64 +Context=Devices +Type=Fixed + +[64x64/emblems] +Size=64 +Context=Emblems +Type=Fixed + +[64x64/emotes] +Size=64 +Context=Emotes +Type=Fixed + +[64x64/mimetypes] +Size=64 +Context=MimeTypes +Type=Fixed + +[64x64/places] +Size=64 +Context=Places +Type=Fixed + +[64x64/status] +Size=64 +Context=Status +Type=Fixed + +[72x72/actions] +Size=72 +Context=Actions +Type=Fixed + +[72x72/apps] +Size=72 +Context=Applications +Type=Fixed + +[72x72/categories] +Size=72 +Context=Categories +Type=Fixed + +[72x72/devices] +Size=72 +Context=Devices +Type=Fixed + +[72x72/emblems] +Size=72 +Context=Emblems +Type=Fixed + +[72x72/emotes] +Size=72 +Context=Emotes +Type=Fixed + +[72x72/mimetypes] +Size=72 +Context=MimeTypes +Type=Fixed + +[72x72/places] +Size=72 +Context=Places +Type=Fixed + +[72x72/status] +Size=72 +Context=Status +Type=Fixed + +[96x96/actions] +Size=96 +Context=Actions +Type=Fixed + +[96x96/apps] +Size=96 +Context=Applications +Type=Fixed + +[96x96/categories] +Size=96 +Context=Categories +Type=Fixed + +[96x96/devices] +Size=96 +Context=Devices +Type=Fixed + +[96x96/emblems] +Size=96 +Context=Emblems +Type=Fixed + +[96x96/emotes] +Size=96 +Context=Emotes +Type=Fixed + +[96x96/mimetypes] +Size=96 +Context=MimeTypes +Type=Fixed + +[96x96/places] +Size=96 +Context=Places +Type=Fixed + +[96x96/status] +Size=96 +Context=Status +Type=Fixed + +[128x128/actions] +Size=128 +Context=Actions +Type=Fixed + +[128x128/apps] +Size=128 +Context=Applications +Type=Fixed + +[128x128/categories] +Size=128 +Context=Categories +Type=Fixed + +[128x128/devices] +Size=128 +Context=Devices +Type=Fixed + +[128x128/emblems] +Size=128 +Context=Emblems +Type=Fixed + +[128x128/emotes] +Size=128 +Context=Emotes +Type=Fixed + +[128x128/mimetypes] +Size=128 +Context=MimeTypes +Type=Fixed + +[128x128/places] +Size=128 +Context=Places +Type=Fixed + +[128x128/status] +Size=128 +Context=Status +Type=Fixed + +[scalable/actions] +Size=48 +Context=Actions +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/apps] +Size=48 +Context=Applications +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/categories] +Size=48 +Context=Categories +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/devices] +Size=48 +Context=Devices +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emblems] +Size=48 +Context=Emblems +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emotes] +Size=48 +Context=Emotes +Type=Scalable +Minsize=32 +MaxSize=256 + +[scalable/mimetypes] +Size=48 +Context=MimeTypes +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/places] +Size=48 +Context=Places +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/status] +Size=48 +Context=Status +Type=Scalable +MinSize=32 +MaxSize=256 diff --git a/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg b/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg new file mode 100644 index 0000000000..4cb14f82f0 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + New Appointment + + + appointment + new + meeting + rvsp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png new file mode 100644 index 0000000000..2098cfdf36 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png new file mode 100644 index 0000000000..18b7c6781e Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png new file mode 100644 index 0000000000..fad446cd92 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png new file mode 100644 index 0000000000..d676ffd463 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png new file mode 100644 index 0000000000..420139d307 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png new file mode 100644 index 0000000000..85daef3b0b Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/index.theme b/tests/auto/gui/image/qicon/icons/themeparent/index.theme new file mode 100644 index 0000000000..e536a0bf2f --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/themeparent/index.theme @@ -0,0 +1,492 @@ +[Icon Theme] +_Name=Test +_Comment=Test Theme +Inherits=gnome,crystalsvg +Example=x-directory-normal + +# KDE Specific Stuff +DisplayDepth=32 +LinkOverlay=link_overlay +LockOverlay=lock_overlay +ZipOverlay=zip_overlay +DesktopDefault=48 +DesktopSizes=16,22,32,48,64,72,96,128 +ToolbarDefault=22 +ToolbarSizes=16,22,32,48 +MainToolbarDefault=22 +MainToolbarSizes=16,22,32,48 +SmallDefault=16 +SmallSizes=16 +PanelDefault=32 +PanelSizes=16,22,32,48,64,72,96,128 + +# Directory list +Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[16x16/apps] +Size=16 +Context=Applications +Type=Fixed + +[16x16/categories] +Size=16 +Context=Categories +Type=Fixed + +[16x16/devices] +Size=16 +Context=Devices +Type=Fixed + +[16x16/emblems] +Size=16 +Context=Emblems +Type=Fixed + +[16x16/emotes] +Size=16 +Context=Emotes +Type=Fixed + +[16x16/mimetypes] +Size=16 +Context=MimeTypes +Type=Fixed + +[16x16/places] +Size=16 +Context=Places +Type=Fixed + +[16x16/status] +Size=16 +Context=Status +Type=Fixed + +[22x22/actions] +Size=22 +Context=Actions +Type=Fixed + +[22x22/apps] +Size=22 +Context=Applications +Type=Fixed + +[22x22/categories] +Size=22 +Context=Categories +Type=Fixed + +[22x22/devices] +Size=22 +Context=Devices +Type=Fixed + +[22x22/emblems] +Size=22 +Context=Emblems +Type=Fixed + +[22x22/emotes] +Size=22 +Context=Emotes +Type=Fixed + +[22x22/mimetypes] +Size=22 +Context=MimeTypes +Type=Fixed + +[22x22/places] +Size=22 +Context=Places +Type=Fixed + +[22x22/status] +Size=22 +Context=Status +Type=Fixed + +[24x24/actions] +Size=24 +Context=Actions +Type=Fixed + +[24x24/apps] +Size=24 +Context=Applications +Type=Fixed + +[24x24/categories] +Size=24 +Context=Categories +Type=Fixed + +[24x24/devices] +Size=24 +Context=Devices +Type=Fixed + +[24x24/emblems] +Size=24 +Context=Emblems +Type=Fixed + +[24x24/emotes] +Size=24 +Context=Emotes +Type=Fixed + +[24x24/mimetypes] +Size=24 +Context=MimeTypes +Type=Fixed + +[24x24/places] +Size=24 +Context=Places +Type=Fixed + +[24x24/status] +Size=24 +Context=Status +Type=Fixed + +[32x32/actions] +Size=32 +Context=Actions +Type=Fixed + +[32x32/apps] +Size=32 +Context=Applications +Type=Fixed + +[32x32/categories] +Size=32 +Context=Categories +Type=Fixed + +[32x32/devices] +Size=32 +Context=Devices +Type=Fixed + +[32x32/emblems] +Size=32 +Context=Emblems +Type=Fixed + +[32x32/emotes] +Size=32 +Context=Emotes +Type=Fixed + +[32x32/mimetypes] +Size=32 +Context=MimeTypes +Type=Fixed + +[32x32/places] +Size=32 +Context=Places +Type=Fixed + +[32x32/status] +Size=32 +Context=Status +Type=Fixed + +[48x48/actions] +Size=48 +Context=Actions +Type=Fixed + +[48x48/apps] +Size=48 +Context=Applications +Type=Fixed + +[48x48/categories] +Size=48 +Context=Categories +Type=Fixed + +[48x48/devices] +Size=48 +Context=Devices +Type=Fixed + +[48x48/emblems] +Size=48 +Context=Emblems +Type=Fixed + +[48x48/emotes] +Size=48 +Context=Emotes +Type=Fixed + +[48x48/mimetypes] +Size=48 +Context=MimeTypes +Type=Fixed + +[48x48/places] +Size=48 +Context=Places +Type=Fixed + +[48x48/status] +Size=48 +Context=Status +Type=Fixed + +[64x64/actions] +Size=64 +Context=Actions +Type=Fixed + +[64x64/apps] +Size=64 +Context=Applications +Type=Fixed + +[64x64/categories] +Size=64 +Context=Categories +Type=Fixed + +[64x64/devices] +Size=64 +Context=Devices +Type=Fixed + +[64x64/emblems] +Size=64 +Context=Emblems +Type=Fixed + +[64x64/emotes] +Size=64 +Context=Emotes +Type=Fixed + +[64x64/mimetypes] +Size=64 +Context=MimeTypes +Type=Fixed + +[64x64/places] +Size=64 +Context=Places +Type=Fixed + +[64x64/status] +Size=64 +Context=Status +Type=Fixed + +[72x72/actions] +Size=72 +Context=Actions +Type=Fixed + +[72x72/apps] +Size=72 +Context=Applications +Type=Fixed + +[72x72/categories] +Size=72 +Context=Categories +Type=Fixed + +[72x72/devices] +Size=72 +Context=Devices +Type=Fixed + +[72x72/emblems] +Size=72 +Context=Emblems +Type=Fixed + +[72x72/emotes] +Size=72 +Context=Emotes +Type=Fixed + +[72x72/mimetypes] +Size=72 +Context=MimeTypes +Type=Fixed + +[72x72/places] +Size=72 +Context=Places +Type=Fixed + +[72x72/status] +Size=72 +Context=Status +Type=Fixed + +[96x96/actions] +Size=96 +Context=Actions +Type=Fixed + +[96x96/apps] +Size=96 +Context=Applications +Type=Fixed + +[96x96/categories] +Size=96 +Context=Categories +Type=Fixed + +[96x96/devices] +Size=96 +Context=Devices +Type=Fixed + +[96x96/emblems] +Size=96 +Context=Emblems +Type=Fixed + +[96x96/emotes] +Size=96 +Context=Emotes +Type=Fixed + +[96x96/mimetypes] +Size=96 +Context=MimeTypes +Type=Fixed + +[96x96/places] +Size=96 +Context=Places +Type=Fixed + +[96x96/status] +Size=96 +Context=Status +Type=Fixed + +[128x128/actions] +Size=128 +Context=Actions +Type=Fixed + +[128x128/apps] +Size=128 +Context=Applications +Type=Fixed + +[128x128/categories] +Size=128 +Context=Categories +Type=Fixed + +[128x128/devices] +Size=128 +Context=Devices +Type=Fixed + +[128x128/emblems] +Size=128 +Context=Emblems +Type=Fixed + +[128x128/emotes] +Size=128 +Context=Emotes +Type=Fixed + +[128x128/mimetypes] +Size=128 +Context=MimeTypes +Type=Fixed + +[128x128/places] +Size=128 +Context=Places +Type=Fixed + +[128x128/status] +Size=128 +Context=Status +Type=Fixed + +[scalable/actions] +Size=48 +Context=Actions +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/apps] +Size=48 +Context=Applications +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/categories] +Size=48 +Context=Categories +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/devices] +Size=48 +Context=Devices +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emblems] +Size=48 +Context=Emblems +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emotes] +Size=48 +Context=Emotes +Type=Scalable +Minsize=32 +MaxSize=256 + +[scalable/mimetypes] +Size=48 +Context=MimeTypes +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/places] +Size=48 +Context=Places +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/status] +Size=48 +Context=Status +Type=Scalable +MinSize=32 +MaxSize=256 diff --git a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg new file mode 100644 index 0000000000..600a82c1b0 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Addess Book - New + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + address + contact + book + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg new file mode 100644 index 0000000000..4cb14f82f0 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + New Appointment + + + appointment + new + meeting + rvsp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/gui/image/qicon/image.png b/tests/auto/gui/image/qicon/image.png new file mode 100644 index 0000000000..8d703640c1 Binary files /dev/null and b/tests/auto/gui/image/qicon/image.png differ diff --git a/tests/auto/gui/image/qicon/qicon.pro b/tests/auto/gui/image/qicon/qicon.pro new file mode 100644 index 0000000000..c44c080ced --- /dev/null +++ b/tests/auto/gui/image/qicon/qicon.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qicon + +QT += widgets testlib +SOURCES += tst_qicon.cpp +RESOURCES = tst_qicon.qrc + +wince* { + QT += xml svg + DEPLOYMENT_PLUGIN += qsvg +} +TESTDATA += icons/* *.png *.svg *.svgz diff --git a/tests/auto/gui/image/qicon/rect.png b/tests/auto/gui/image/qicon/rect.png new file mode 100644 index 0000000000..b5d3ecbddf Binary files /dev/null and b/tests/auto/gui/image/qicon/rect.png differ diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp new file mode 100644 index 0000000000..cca0887a21 --- /dev/null +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -0,0 +1,637 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QSize) + +class tst_QIcon : public QObject +{ + Q_OBJECT +public: + tst_QIcon(); + +private slots: + void actualSize_data(); // test with 1 pixmap + void actualSize(); + void actualSize2_data(); // test with 2 pixmaps with different aspect ratio + void actualSize2(); + void isNull(); + void swap(); + void bestMatch(); + void cacheKey(); + void detach(); + void addFile(); + void availableSizes(); + void name(); + void streamAvailableSizes_data(); + void streamAvailableSizes(); + void fromTheme(); + + void task184901_badCache(); + void task223279_inconsistentAddFile(); + +private: + bool haveImageFormat(QByteArray const&); + + const static QIcon staticIcon; +}; + +// Creating an icon statically should not cause a crash. +// But we do not officially support this. See QTBUG-8666 +const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); + +bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) +{ + return QImageReader::supportedImageFormats().contains(desiredFormat); +} + +tst_QIcon::tst_QIcon() +{ +} + +void tst_QIcon::actualSize_data() +{ + QTest::addColumn("source"); + QTest::addColumn("argument"); + QTest::addColumn("result"); + + // square image + QTest::newRow("resource0") << ":/image.png" << QSize(128, 128) << QSize(128, 128); + QTest::newRow("resource1") << ":/image.png" << QSize( 64, 64) << QSize( 64, 64); + QTest::newRow("resource2") << ":/image.png" << QSize( 32, 64) << QSize( 32, 32); + QTest::newRow("resource3") << ":/image.png" << QSize( 16, 64) << QSize( 16, 16); + QTest::newRow("resource4") << ":/image.png" << QSize( 16, 128) << QSize( 16, 16); + QTest::newRow("resource5") << ":/image.png" << QSize( 128, 16) << QSize( 16, 16); + QTest::newRow("resource6") << ":/image.png" << QSize( 150, 150) << QSize( 128, 128); + // rect image + QTest::newRow("resource7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); + QTest::newRow("resource8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); + QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); + QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); + + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); + QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); + QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); + QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16); + QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16); + QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16); + QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128); + // rect image + QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); + QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); + QTest::newRow("external9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); + QTest::newRow("external10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); +} + +void tst_QIcon::actualSize() +{ + QFETCH(QString, source); + QFETCH(QSize, argument); + QFETCH(QSize, result); + + { + QPixmap pixmap(source); + QIcon icon(pixmap); + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); + } + + { + QIcon icon(source); + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); + } +} + +void tst_QIcon::actualSize2_data() +{ + QTest::addColumn("argument"); + QTest::addColumn("result"); + + // two images - 128x128 and 20x40. Let the games begin + QTest::newRow("trivial1") << QSize( 128, 128) << QSize( 128, 128); + QTest::newRow("trivial2") << QSize( 20, 40) << QSize( 20, 40); + + // QIcon chooses the one with the smallest area to choose the pixmap + QTest::newRow("best1") << QSize( 100, 100) << QSize( 100, 100); + QTest::newRow("best2") << QSize( 20, 20) << QSize( 10, 20); + QTest::newRow("best3") << QSize( 15, 30) << QSize( 15, 30); + QTest::newRow("best4") << QSize( 5, 5) << QSize( 2, 5); + QTest::newRow("best5") << QSize( 10, 15) << QSize( 7, 15); +} + +void tst_QIcon::actualSize2() +{ + QIcon icon; + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + + icon.addPixmap(QPixmap(prefix + "image.png")); + icon.addPixmap(QPixmap(prefix + "rect.png")); + + QFETCH(QSize, argument); + QFETCH(QSize, result); + + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); +} + +void tst_QIcon::isNull() { + // test default constructor + QIcon defaultConstructor; + QVERIFY(defaultConstructor.isNull()); + + // test copy constructor + QVERIFY(QIcon(defaultConstructor).isNull()); + + // test pixmap constructor + QPixmap nullPixmap; + QVERIFY(QIcon(nullPixmap).isNull()); + + // test string constructor with empty string + QIcon iconEmptyString = QIcon(QString()); + QVERIFY(iconEmptyString.isNull()); + QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());; + + // test string constructor with non-existing file + QIcon iconNoFile = QIcon("imagedoesnotexist"); + QVERIFY(!iconNoFile.isNull()); + QVERIFY(!iconNoFile.actualSize(QSize(32, 32)).isValid()); + + // test string constructor with non-existing file with suffix + QIcon iconNoFileSuffix = QIcon("imagedoesnotexist.png"); + QVERIFY(!iconNoFileSuffix.isNull()); + QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); + + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + // test string constructor with existing file but unsupported format + QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); + QVERIFY(!iconUnsupportedFormat.isNull()); + QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); + + // test string constructor with existing file and supported format + QIcon iconSupportedFormat = QIcon(prefix + "image.png"); + QVERIFY(!iconSupportedFormat.isNull()); + QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); +} + +void tst_QIcon::swap() +{ + QPixmap p1(1, 1), p2(2, 2); + p1.fill(Qt::black); + p2.fill(Qt::black); + + QIcon i1(p1), i2(p2); + const qint64 i1k = i1.cacheKey(); + const qint64 i2k = i2.cacheKey(); + QVERIFY(i1k != i2k); + i1.swap(i2); + QCOMPARE(i1.cacheKey(), i2k); + QCOMPARE(i2.cacheKey(), i1k); +} + +void tst_QIcon::bestMatch() +{ + QPixmap p1(1, 1); + QPixmap p2(2, 2); + QPixmap p3(3, 3); + QPixmap p4(4, 4); + QPixmap p5(5, 5); + QPixmap p6(6, 6); + QPixmap p7(7, 7); + QPixmap p8(8, 8); + + p1.fill(Qt::black); + p2.fill(Qt::black); + p3.fill(Qt::black); + p4.fill(Qt::black); + p5.fill(Qt::black); + p6.fill(Qt::black); + p7.fill(Qt::black); + p8.fill(Qt::black); + + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 2; ++j) { + QIcon::State state = (j == 0) ? QIcon::On : QIcon::Off; + QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off + : QIcon::On; + QIcon::Mode mode; + QIcon::Mode oppositeMode; + + QIcon icon; + + switch (i) { + case 0: + default: + mode = QIcon::Normal; + oppositeMode = QIcon::Active; + break; + case 1: + mode = QIcon::Active; + oppositeMode = QIcon::Normal; + break; + case 2: + mode = QIcon::Disabled; + oppositeMode = QIcon::Selected; + break; + case 3: + mode = QIcon::Selected; + oppositeMode = QIcon::Disabled; + } + + /* + The test mirrors the code in + QPixmapIconEngine::bestMatch(), to make sure that + nobody breaks QPixmapIconEngine by mistake. Before + you change this test or the code that it tests, + please talk to the maintainer if possible. + */ + if (mode == QIcon::Disabled || mode == QIcon::Selected) { + icon.addPixmap(p1, oppositeMode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); + + icon.addPixmap(p2, oppositeMode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); + + icon.addPixmap(p3, QIcon::Active, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); + + icon.addPixmap(p4, QIcon::Normal, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); + + icon.addPixmap(p5, mode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); + + icon.addPixmap(p6, QIcon::Active, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); + + icon.addPixmap(p7, QIcon::Normal, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); + + icon.addPixmap(p8, mode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); + } else { + icon.addPixmap(p1, QIcon::Selected, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); + + icon.addPixmap(p2, QIcon::Disabled, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); + + icon.addPixmap(p3, QIcon::Selected, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); + + icon.addPixmap(p4, QIcon::Disabled, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); + + icon.addPixmap(p5, oppositeMode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); + + icon.addPixmap(p6, mode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); + + icon.addPixmap(p7, oppositeMode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); + + icon.addPixmap(p8, mode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); + } + } + } +} + +void tst_QIcon::cacheKey() +{ + QIcon icon1("image.png"); + qint64 icon1_key = icon1.cacheKey(); + QIcon icon2 = icon1; + + QVERIFY(icon2.cacheKey() == icon1.cacheKey()); + icon2.detach(); + QVERIFY(icon2.cacheKey() != icon1.cacheKey()); + QVERIFY(icon1.cacheKey() == icon1_key); +} + +void tst_QIcon::detach() +{ + QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); + img.fill(0xffff0000); + QIcon icon1(QPixmap::fromImage(img)); + QIcon icon2 = icon1; + icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64)); + + QImage img1 = icon1.pixmap(64, 64).toImage(); + QImage img2 = icon2.pixmap(64, 64).toImage(); + QVERIFY(img1 != img2); + + img1 = icon1.pixmap(32, 32).toImage(); + img2 = icon2.pixmap(32, 32).toImage(); + QVERIFY(img1 == img2); +} + +void tst_QIcon::addFile() +{ + QIcon icon; + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); + +#ifndef Q_OS_WINCE + QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); + QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); + QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); + QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); +#else + // WinCE only includes the 16x16 images for size reasons + QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); +#endif +} + +static bool sizeLess(const QSize &a, const QSize &b) +{ + return a.width() < b.width(); +} + +void tst_QIcon::availableSizes() +{ + { + QIcon icon; + icon.addFile("image.png", QSize(32,32)); + icon.addFile("image.png", QSize(64,64)); + icon.addFile("image.png", QSize(128,128)); + icon.addFile("image.png", QSize(256,256), QIcon::Disabled); + icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On); + + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 3); + qSort(availableSizes.begin(), availableSizes.end(), sizeLess); + QCOMPARE(availableSizes.at(0), QSize(32,32)); + QCOMPARE(availableSizes.at(1), QSize(64,64)); + QCOMPARE(availableSizes.at(2), QSize(128,128)); + + availableSizes = icon.availableSizes(QIcon::Disabled); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(256,256)); + + availableSizes = icon.availableSizes(QIcon::Normal, QIcon::On); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16,16)); + } + + { + // we try to load an icon from resources + QIcon icon(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16, 16)); + } + + { + // load an icon from binary data. + QPixmap pix; + QFile file(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + QVERIFY(file.open(QIODevice::ReadOnly)); + uchar *data = file.map(0, file.size()); + QVERIFY(data != 0); + pix.loadFromData(data, file.size()); + QIcon icon(pix); + + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16,16)); + } + + { + // there shouldn't be available sizes for invalid images! + QVERIFY(QIcon(QLatin1String("")).availableSizes().isEmpty()); + QVERIFY(QIcon(QLatin1String("non-existing.png")).availableSizes().isEmpty()); + } +} + +void tst_QIcon::name() +{ + { + // No name if icon does not come from a theme + QIcon icon(":/image.png"); + QString name = icon.name(); + QVERIFY(name.isEmpty()); + } + + { + // Getting the name of an icon coming from a theme should work + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + + QIcon icon = QIcon::fromTheme("appointment-new"); + QString name = icon.name(); + QCOMPARE(name, QLatin1String("appointment-new")); + } +} + +void tst_QIcon::streamAvailableSizes_data() +{ + QTest::addColumn("icon"); + + QIcon icon; + icon.addFile(":/image.png", QSize(32,32)); + QTest::newRow( "32x32" ) << icon; + icon.addFile(":/image.png", QSize(64,64)); + QTest::newRow( "64x64" ) << icon; + icon.addFile(":/image.png", QSize(128,128)); + QTest::newRow( "128x128" ) << icon; + icon.addFile(":/image.png", QSize(256,256)); + QTest::newRow( "256x256" ) << icon; +} + +void tst_QIcon::streamAvailableSizes() +{ + QFETCH(QIcon, icon); + + QByteArray ba; + // write to QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + stream << icon; + } + + // read from QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + QDataStream stream(&buffer); + QIcon i; + stream >> i; + QCOMPARE(i.isNull(), icon.isNull()); + QCOMPARE(i.availableSizes(), icon.availableSizes()); + } +} + + +static inline bool operator<(const QSize &lhs, const QSize &rhs) +{ + if (lhs.width() < rhs.width()) + return true; + else if (lhs.width() == lhs.width()) + return lhs.height() < lhs.height(); + return false; +} + +void tst_QIcon::task184901_badCache() +{ + QPixmap pm(QFINDTESTDATA("image.png")); + QIcon icon(pm); + + //the disabled icon must have an effect (grayed) + QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() != icon.pixmap(32, QIcon::Disabled).toImage()); + + icon.addPixmap(pm, QIcon::Disabled); + //the disabled icon must now be the same as the normal one. + QVERIFY( icon.pixmap(32, QIcon::Normal).toImage() == icon.pixmap(32, QIcon::Disabled).toImage() ); +} + +void tst_QIcon::fromTheme() +{ + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QVERIFY(QIcon::themeSearchPaths().size() == 1); + QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); + + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + QCOMPARE(QIcon::themeName(), themeName); + + // Test normal icon + QIcon appointmentIcon = QIcon::fromTheme("appointment-new"); + QVERIFY(!appointmentIcon.isNull()); + QVERIFY(!appointmentIcon.availableSizes(QIcon::Normal, QIcon::Off).isEmpty()); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(16, 16))); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(32, 32))); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(22, 22))); + + // Test icon from parent theme + QIcon abIcon = QIcon::fromTheme("address-book-new"); + QVERIFY(!abIcon.isNull()); + QVERIFY(QIcon::hasThemeIcon("address-book-new")); + QVERIFY(!abIcon.availableSizes().isEmpty()); + + // Test non existing icon + QIcon noIcon = QIcon::fromTheme("broken-icon"); + QVERIFY(noIcon.isNull()); + QVERIFY(!QIcon::hasThemeIcon("broken-icon")); + + // Test non existing icon with fallback + noIcon = QIcon::fromTheme("broken-icon", abIcon); + QVERIFY(noIcon.cacheKey() == abIcon.cacheKey()); + + // Test svg-only icon + noIcon = QIcon::fromTheme("svg-icon", abIcon); + QVERIFY(!noIcon.availableSizes().isEmpty()); + + QByteArray ba; + // write to QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + stream << abIcon; + } + + // read from QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + QDataStream stream(&buffer); + QIcon i; + stream >> i; + QCOMPARE(i.isNull(), abIcon.isNull()); + QCOMPARE(i.availableSizes(), abIcon.availableSizes()); + } + + // Make sure setting the theme name clears the state + QIcon::setThemeName(""); + abIcon = QIcon::fromTheme("address-book-new"); + QVERIFY(abIcon.isNull()); +} + + +void tst_QIcon::task223279_inconsistentAddFile() +{ + QIcon icon1; + icon1.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); + QPixmap pm1 = icon1.pixmap(32, 32); + + QIcon icon2; + icon2.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + icon2.addFile(QLatin1String("IconThatDoesntExist")); + QPixmap pm2 = icon1.pixmap(32, 32); + + QCOMPARE(pm1.isNull(), false); + QCOMPARE(pm1.size(), QSize(16,16)); + QCOMPARE(pm1.isNull(), pm2.isNull()); + QCOMPARE(pm1.size(), pm2.size()); +} + + +QTEST_MAIN(tst_QIcon) +#include "tst_qicon.moc" diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc new file mode 100644 index 0000000000..7925a33c84 --- /dev/null +++ b/tests/auto/gui/image/qicon/tst_qicon.qrc @@ -0,0 +1,20 @@ + + +image.png +rect.png +./icons/testtheme/16x16/actions/appointment-new.png +./icons/testtheme/22x22/actions/appointment-new.png +./icons/testtheme/32x32/actions/appointment-new.png +./icons/testtheme/index.theme +./icons/testtheme/scalable/actions/svg-only.svg +./icons/themeparent/16x16/actions/address-book-new.png +./icons/themeparent/16x16/actions/appointment-new.png +./icons/themeparent/22x22/actions/address-book-new.png +./icons/themeparent/22x22/actions/appointment-new.png +./icons/themeparent/32x32/actions/address-book-new.png +./icons/themeparent/32x32/actions/appointment-new.png +./icons/themeparent/index.theme +./icons/themeparent/scalable/actions/address-book-new.svg +./icons/themeparent/scalable/actions/appointment-new.svg + + diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index e1c245d9d1..c2540ec229 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -13,7 +13,6 @@ SUBDIRS=\ qwidget \ qwidget_window \ qwidgetaction \ - qicon \ qshortcut \ SUBDIRS -= qsound diff --git a/tests/auto/widgets/kernel/qicon/.gitignore b/tests/auto/widgets/kernel/qicon/.gitignore deleted file mode 100644 index c101ef9d28..0000000000 --- a/tests/auto/widgets/kernel/qicon/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qicon diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png deleted file mode 100644 index 18b7c6781e..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png deleted file mode 100644 index d676ffd463..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png deleted file mode 100644 index 85daef3b0b..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme b/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme deleted file mode 100644 index e18736ab43..0000000000 --- a/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme +++ /dev/null @@ -1,492 +0,0 @@ -[Icon Theme] -_Name=Test -_Comment=Test Theme -Inherits=crystalsvg, themeparent -Example=x-directory-normal - -# KDE Specific Stuff -DisplayDepth=32 -LinkOverlay=link_overlay -LockOverlay=lock_overlay -ZipOverlay=zip_overlay -DesktopDefault=48 -DesktopSizes=16,22,32,48,64,72,96,128 -ToolbarDefault=22 -ToolbarSizes=16,22,32,48 -MainToolbarDefault=22 -MainToolbarSizes=16,22,32,48 -SmallDefault=16 -SmallSizes=16 -PanelDefault=32 -PanelSizes=16,22,32,48,64,72,96,128 - -# Directory list -Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status - -[16x16/actions] -Size=16 -Context=Actions -Type=Fixed - -[16x16/apps] -Size=16 -Context=Applications -Type=Fixed - -[16x16/categories] -Size=16 -Context=Categories -Type=Fixed - -[16x16/devices] -Size=16 -Context=Devices -Type=Fixed - -[16x16/emblems] -Size=16 -Context=Emblems -Type=Fixed - -[16x16/emotes] -Size=16 -Context=Emotes -Type=Fixed - -[16x16/mimetypes] -Size=16 -Context=MimeTypes -Type=Fixed - -[16x16/places] -Size=16 -Context=Places -Type=Fixed - -[16x16/status] -Size=16 -Context=Status -Type=Fixed - -[22x22/actions] -Size=22 -Context=Actions -Type=Fixed - -[22x22/apps] -Size=22 -Context=Applications -Type=Fixed - -[22x22/categories] -Size=22 -Context=Categories -Type=Fixed - -[22x22/devices] -Size=22 -Context=Devices -Type=Fixed - -[22x22/emblems] -Size=22 -Context=Emblems -Type=Fixed - -[22x22/emotes] -Size=22 -Context=Emotes -Type=Fixed - -[22x22/mimetypes] -Size=22 -Context=MimeTypes -Type=Fixed - -[22x22/places] -Size=22 -Context=Places -Type=Fixed - -[22x22/status] -Size=22 -Context=Status -Type=Fixed - -[24x24/actions] -Size=24 -Context=Actions -Type=Fixed - -[24x24/apps] -Size=24 -Context=Applications -Type=Fixed - -[24x24/categories] -Size=24 -Context=Categories -Type=Fixed - -[24x24/devices] -Size=24 -Context=Devices -Type=Fixed - -[24x24/emblems] -Size=24 -Context=Emblems -Type=Fixed - -[24x24/emotes] -Size=24 -Context=Emotes -Type=Fixed - -[24x24/mimetypes] -Size=24 -Context=MimeTypes -Type=Fixed - -[24x24/places] -Size=24 -Context=Places -Type=Fixed - -[24x24/status] -Size=24 -Context=Status -Type=Fixed - -[32x32/actions] -Size=32 -Context=Actions -Type=Fixed - -[32x32/apps] -Size=32 -Context=Applications -Type=Fixed - -[32x32/categories] -Size=32 -Context=Categories -Type=Fixed - -[32x32/devices] -Size=32 -Context=Devices -Type=Fixed - -[32x32/emblems] -Size=32 -Context=Emblems -Type=Fixed - -[32x32/emotes] -Size=32 -Context=Emotes -Type=Fixed - -[32x32/mimetypes] -Size=32 -Context=MimeTypes -Type=Fixed - -[32x32/places] -Size=32 -Context=Places -Type=Fixed - -[32x32/status] -Size=32 -Context=Status -Type=Fixed - -[48x48/actions] -Size=48 -Context=Actions -Type=Fixed - -[48x48/apps] -Size=48 -Context=Applications -Type=Fixed - -[48x48/categories] -Size=48 -Context=Categories -Type=Fixed - -[48x48/devices] -Size=48 -Context=Devices -Type=Fixed - -[48x48/emblems] -Size=48 -Context=Emblems -Type=Fixed - -[48x48/emotes] -Size=48 -Context=Emotes -Type=Fixed - -[48x48/mimetypes] -Size=48 -Context=MimeTypes -Type=Fixed - -[48x48/places] -Size=48 -Context=Places -Type=Fixed - -[48x48/status] -Size=48 -Context=Status -Type=Fixed - -[64x64/actions] -Size=64 -Context=Actions -Type=Fixed - -[64x64/apps] -Size=64 -Context=Applications -Type=Fixed - -[64x64/categories] -Size=64 -Context=Categories -Type=Fixed - -[64x64/devices] -Size=64 -Context=Devices -Type=Fixed - -[64x64/emblems] -Size=64 -Context=Emblems -Type=Fixed - -[64x64/emotes] -Size=64 -Context=Emotes -Type=Fixed - -[64x64/mimetypes] -Size=64 -Context=MimeTypes -Type=Fixed - -[64x64/places] -Size=64 -Context=Places -Type=Fixed - -[64x64/status] -Size=64 -Context=Status -Type=Fixed - -[72x72/actions] -Size=72 -Context=Actions -Type=Fixed - -[72x72/apps] -Size=72 -Context=Applications -Type=Fixed - -[72x72/categories] -Size=72 -Context=Categories -Type=Fixed - -[72x72/devices] -Size=72 -Context=Devices -Type=Fixed - -[72x72/emblems] -Size=72 -Context=Emblems -Type=Fixed - -[72x72/emotes] -Size=72 -Context=Emotes -Type=Fixed - -[72x72/mimetypes] -Size=72 -Context=MimeTypes -Type=Fixed - -[72x72/places] -Size=72 -Context=Places -Type=Fixed - -[72x72/status] -Size=72 -Context=Status -Type=Fixed - -[96x96/actions] -Size=96 -Context=Actions -Type=Fixed - -[96x96/apps] -Size=96 -Context=Applications -Type=Fixed - -[96x96/categories] -Size=96 -Context=Categories -Type=Fixed - -[96x96/devices] -Size=96 -Context=Devices -Type=Fixed - -[96x96/emblems] -Size=96 -Context=Emblems -Type=Fixed - -[96x96/emotes] -Size=96 -Context=Emotes -Type=Fixed - -[96x96/mimetypes] -Size=96 -Context=MimeTypes -Type=Fixed - -[96x96/places] -Size=96 -Context=Places -Type=Fixed - -[96x96/status] -Size=96 -Context=Status -Type=Fixed - -[128x128/actions] -Size=128 -Context=Actions -Type=Fixed - -[128x128/apps] -Size=128 -Context=Applications -Type=Fixed - -[128x128/categories] -Size=128 -Context=Categories -Type=Fixed - -[128x128/devices] -Size=128 -Context=Devices -Type=Fixed - -[128x128/emblems] -Size=128 -Context=Emblems -Type=Fixed - -[128x128/emotes] -Size=128 -Context=Emotes -Type=Fixed - -[128x128/mimetypes] -Size=128 -Context=MimeTypes -Type=Fixed - -[128x128/places] -Size=128 -Context=Places -Type=Fixed - -[128x128/status] -Size=128 -Context=Status -Type=Fixed - -[scalable/actions] -Size=48 -Context=Actions -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/apps] -Size=48 -Context=Applications -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/categories] -Size=48 -Context=Categories -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/devices] -Size=48 -Context=Devices -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emblems] -Size=48 -Context=Emblems -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emotes] -Size=48 -Context=Emotes -Type=Scalable -Minsize=32 -MaxSize=256 - -[scalable/mimetypes] -Size=48 -Context=MimeTypes -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/places] -Size=48 -Context=Places -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/status] -Size=48 -Context=Status -Type=Scalable -MinSize=32 -MaxSize=256 diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg b/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg deleted file mode 100644 index 4cb14f82f0..0000000000 --- a/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - New Appointment - - - appointment - new - meeting - rvsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png deleted file mode 100644 index 2098cfdf36..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png deleted file mode 100644 index 18b7c6781e..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png deleted file mode 100644 index fad446cd92..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png deleted file mode 100644 index d676ffd463..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png deleted file mode 100644 index 420139d307..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png deleted file mode 100644 index 85daef3b0b..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme b/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme deleted file mode 100644 index e536a0bf2f..0000000000 --- a/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme +++ /dev/null @@ -1,492 +0,0 @@ -[Icon Theme] -_Name=Test -_Comment=Test Theme -Inherits=gnome,crystalsvg -Example=x-directory-normal - -# KDE Specific Stuff -DisplayDepth=32 -LinkOverlay=link_overlay -LockOverlay=lock_overlay -ZipOverlay=zip_overlay -DesktopDefault=48 -DesktopSizes=16,22,32,48,64,72,96,128 -ToolbarDefault=22 -ToolbarSizes=16,22,32,48 -MainToolbarDefault=22 -MainToolbarSizes=16,22,32,48 -SmallDefault=16 -SmallSizes=16 -PanelDefault=32 -PanelSizes=16,22,32,48,64,72,96,128 - -# Directory list -Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status - -[16x16/actions] -Size=16 -Context=Actions -Type=Fixed - -[16x16/apps] -Size=16 -Context=Applications -Type=Fixed - -[16x16/categories] -Size=16 -Context=Categories -Type=Fixed - -[16x16/devices] -Size=16 -Context=Devices -Type=Fixed - -[16x16/emblems] -Size=16 -Context=Emblems -Type=Fixed - -[16x16/emotes] -Size=16 -Context=Emotes -Type=Fixed - -[16x16/mimetypes] -Size=16 -Context=MimeTypes -Type=Fixed - -[16x16/places] -Size=16 -Context=Places -Type=Fixed - -[16x16/status] -Size=16 -Context=Status -Type=Fixed - -[22x22/actions] -Size=22 -Context=Actions -Type=Fixed - -[22x22/apps] -Size=22 -Context=Applications -Type=Fixed - -[22x22/categories] -Size=22 -Context=Categories -Type=Fixed - -[22x22/devices] -Size=22 -Context=Devices -Type=Fixed - -[22x22/emblems] -Size=22 -Context=Emblems -Type=Fixed - -[22x22/emotes] -Size=22 -Context=Emotes -Type=Fixed - -[22x22/mimetypes] -Size=22 -Context=MimeTypes -Type=Fixed - -[22x22/places] -Size=22 -Context=Places -Type=Fixed - -[22x22/status] -Size=22 -Context=Status -Type=Fixed - -[24x24/actions] -Size=24 -Context=Actions -Type=Fixed - -[24x24/apps] -Size=24 -Context=Applications -Type=Fixed - -[24x24/categories] -Size=24 -Context=Categories -Type=Fixed - -[24x24/devices] -Size=24 -Context=Devices -Type=Fixed - -[24x24/emblems] -Size=24 -Context=Emblems -Type=Fixed - -[24x24/emotes] -Size=24 -Context=Emotes -Type=Fixed - -[24x24/mimetypes] -Size=24 -Context=MimeTypes -Type=Fixed - -[24x24/places] -Size=24 -Context=Places -Type=Fixed - -[24x24/status] -Size=24 -Context=Status -Type=Fixed - -[32x32/actions] -Size=32 -Context=Actions -Type=Fixed - -[32x32/apps] -Size=32 -Context=Applications -Type=Fixed - -[32x32/categories] -Size=32 -Context=Categories -Type=Fixed - -[32x32/devices] -Size=32 -Context=Devices -Type=Fixed - -[32x32/emblems] -Size=32 -Context=Emblems -Type=Fixed - -[32x32/emotes] -Size=32 -Context=Emotes -Type=Fixed - -[32x32/mimetypes] -Size=32 -Context=MimeTypes -Type=Fixed - -[32x32/places] -Size=32 -Context=Places -Type=Fixed - -[32x32/status] -Size=32 -Context=Status -Type=Fixed - -[48x48/actions] -Size=48 -Context=Actions -Type=Fixed - -[48x48/apps] -Size=48 -Context=Applications -Type=Fixed - -[48x48/categories] -Size=48 -Context=Categories -Type=Fixed - -[48x48/devices] -Size=48 -Context=Devices -Type=Fixed - -[48x48/emblems] -Size=48 -Context=Emblems -Type=Fixed - -[48x48/emotes] -Size=48 -Context=Emotes -Type=Fixed - -[48x48/mimetypes] -Size=48 -Context=MimeTypes -Type=Fixed - -[48x48/places] -Size=48 -Context=Places -Type=Fixed - -[48x48/status] -Size=48 -Context=Status -Type=Fixed - -[64x64/actions] -Size=64 -Context=Actions -Type=Fixed - -[64x64/apps] -Size=64 -Context=Applications -Type=Fixed - -[64x64/categories] -Size=64 -Context=Categories -Type=Fixed - -[64x64/devices] -Size=64 -Context=Devices -Type=Fixed - -[64x64/emblems] -Size=64 -Context=Emblems -Type=Fixed - -[64x64/emotes] -Size=64 -Context=Emotes -Type=Fixed - -[64x64/mimetypes] -Size=64 -Context=MimeTypes -Type=Fixed - -[64x64/places] -Size=64 -Context=Places -Type=Fixed - -[64x64/status] -Size=64 -Context=Status -Type=Fixed - -[72x72/actions] -Size=72 -Context=Actions -Type=Fixed - -[72x72/apps] -Size=72 -Context=Applications -Type=Fixed - -[72x72/categories] -Size=72 -Context=Categories -Type=Fixed - -[72x72/devices] -Size=72 -Context=Devices -Type=Fixed - -[72x72/emblems] -Size=72 -Context=Emblems -Type=Fixed - -[72x72/emotes] -Size=72 -Context=Emotes -Type=Fixed - -[72x72/mimetypes] -Size=72 -Context=MimeTypes -Type=Fixed - -[72x72/places] -Size=72 -Context=Places -Type=Fixed - -[72x72/status] -Size=72 -Context=Status -Type=Fixed - -[96x96/actions] -Size=96 -Context=Actions -Type=Fixed - -[96x96/apps] -Size=96 -Context=Applications -Type=Fixed - -[96x96/categories] -Size=96 -Context=Categories -Type=Fixed - -[96x96/devices] -Size=96 -Context=Devices -Type=Fixed - -[96x96/emblems] -Size=96 -Context=Emblems -Type=Fixed - -[96x96/emotes] -Size=96 -Context=Emotes -Type=Fixed - -[96x96/mimetypes] -Size=96 -Context=MimeTypes -Type=Fixed - -[96x96/places] -Size=96 -Context=Places -Type=Fixed - -[96x96/status] -Size=96 -Context=Status -Type=Fixed - -[128x128/actions] -Size=128 -Context=Actions -Type=Fixed - -[128x128/apps] -Size=128 -Context=Applications -Type=Fixed - -[128x128/categories] -Size=128 -Context=Categories -Type=Fixed - -[128x128/devices] -Size=128 -Context=Devices -Type=Fixed - -[128x128/emblems] -Size=128 -Context=Emblems -Type=Fixed - -[128x128/emotes] -Size=128 -Context=Emotes -Type=Fixed - -[128x128/mimetypes] -Size=128 -Context=MimeTypes -Type=Fixed - -[128x128/places] -Size=128 -Context=Places -Type=Fixed - -[128x128/status] -Size=128 -Context=Status -Type=Fixed - -[scalable/actions] -Size=48 -Context=Actions -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/apps] -Size=48 -Context=Applications -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/categories] -Size=48 -Context=Categories -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/devices] -Size=48 -Context=Devices -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emblems] -Size=48 -Context=Emblems -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emotes] -Size=48 -Context=Emotes -Type=Scalable -Minsize=32 -MaxSize=256 - -[scalable/mimetypes] -Size=48 -Context=MimeTypes -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/places] -Size=48 -Context=Places -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/status] -Size=48 -Context=Status -Type=Scalable -MinSize=32 -MaxSize=256 diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg deleted file mode 100644 index 600a82c1b0..0000000000 --- a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Addess Book - New - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - address - contact - book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg deleted file mode 100644 index 4cb14f82f0..0000000000 --- a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - New Appointment - - - appointment - new - meeting - rvsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/widgets/kernel/qicon/image.png b/tests/auto/widgets/kernel/qicon/image.png deleted file mode 100644 index 8d703640c1..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/image.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/qicon.pro b/tests/auto/widgets/kernel/qicon/qicon.pro deleted file mode 100644 index c44c080ced..0000000000 --- a/tests/auto/widgets/kernel/qicon/qicon.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qicon - -QT += widgets testlib -SOURCES += tst_qicon.cpp -RESOURCES = tst_qicon.qrc - -wince* { - QT += xml svg - DEPLOYMENT_PLUGIN += qsvg -} -TESTDATA += icons/* *.png *.svg *.svgz diff --git a/tests/auto/widgets/kernel/qicon/rect.png b/tests/auto/widgets/kernel/qicon/rect.png deleted file mode 100644 index b5d3ecbddf..0000000000 Binary files a/tests/auto/widgets/kernel/qicon/rect.png and /dev/null differ diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp deleted file mode 100644 index cca0887a21..0000000000 --- a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp +++ /dev/null @@ -1,637 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QSize) - -class tst_QIcon : public QObject -{ - Q_OBJECT -public: - tst_QIcon(); - -private slots: - void actualSize_data(); // test with 1 pixmap - void actualSize(); - void actualSize2_data(); // test with 2 pixmaps with different aspect ratio - void actualSize2(); - void isNull(); - void swap(); - void bestMatch(); - void cacheKey(); - void detach(); - void addFile(); - void availableSizes(); - void name(); - void streamAvailableSizes_data(); - void streamAvailableSizes(); - void fromTheme(); - - void task184901_badCache(); - void task223279_inconsistentAddFile(); - -private: - bool haveImageFormat(QByteArray const&); - - const static QIcon staticIcon; -}; - -// Creating an icon statically should not cause a crash. -// But we do not officially support this. See QTBUG-8666 -const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); - -bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) -{ - return QImageReader::supportedImageFormats().contains(desiredFormat); -} - -tst_QIcon::tst_QIcon() -{ -} - -void tst_QIcon::actualSize_data() -{ - QTest::addColumn("source"); - QTest::addColumn("argument"); - QTest::addColumn("result"); - - // square image - QTest::newRow("resource0") << ":/image.png" << QSize(128, 128) << QSize(128, 128); - QTest::newRow("resource1") << ":/image.png" << QSize( 64, 64) << QSize( 64, 64); - QTest::newRow("resource2") << ":/image.png" << QSize( 32, 64) << QSize( 32, 32); - QTest::newRow("resource3") << ":/image.png" << QSize( 16, 64) << QSize( 16, 16); - QTest::newRow("resource4") << ":/image.png" << QSize( 16, 128) << QSize( 16, 16); - QTest::newRow("resource5") << ":/image.png" << QSize( 128, 16) << QSize( 16, 16); - QTest::newRow("resource6") << ":/image.png" << QSize( 150, 150) << QSize( 128, 128); - // rect image - QTest::newRow("resource7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); - QTest::newRow("resource8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); - QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); - QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); - - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); - QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); - QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); - QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16); - QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16); - QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16); - QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128); - // rect image - QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); - QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); - QTest::newRow("external9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); - QTest::newRow("external10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); -} - -void tst_QIcon::actualSize() -{ - QFETCH(QString, source); - QFETCH(QSize, argument); - QFETCH(QSize, result); - - { - QPixmap pixmap(source); - QIcon icon(pixmap); - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); - } - - { - QIcon icon(source); - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); - } -} - -void tst_QIcon::actualSize2_data() -{ - QTest::addColumn("argument"); - QTest::addColumn("result"); - - // two images - 128x128 and 20x40. Let the games begin - QTest::newRow("trivial1") << QSize( 128, 128) << QSize( 128, 128); - QTest::newRow("trivial2") << QSize( 20, 40) << QSize( 20, 40); - - // QIcon chooses the one with the smallest area to choose the pixmap - QTest::newRow("best1") << QSize( 100, 100) << QSize( 100, 100); - QTest::newRow("best2") << QSize( 20, 20) << QSize( 10, 20); - QTest::newRow("best3") << QSize( 15, 30) << QSize( 15, 30); - QTest::newRow("best4") << QSize( 5, 5) << QSize( 2, 5); - QTest::newRow("best5") << QSize( 10, 15) << QSize( 7, 15); -} - -void tst_QIcon::actualSize2() -{ - QIcon icon; - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - - icon.addPixmap(QPixmap(prefix + "image.png")); - icon.addPixmap(QPixmap(prefix + "rect.png")); - - QFETCH(QSize, argument); - QFETCH(QSize, result); - - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); -} - -void tst_QIcon::isNull() { - // test default constructor - QIcon defaultConstructor; - QVERIFY(defaultConstructor.isNull()); - - // test copy constructor - QVERIFY(QIcon(defaultConstructor).isNull()); - - // test pixmap constructor - QPixmap nullPixmap; - QVERIFY(QIcon(nullPixmap).isNull()); - - // test string constructor with empty string - QIcon iconEmptyString = QIcon(QString()); - QVERIFY(iconEmptyString.isNull()); - QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());; - - // test string constructor with non-existing file - QIcon iconNoFile = QIcon("imagedoesnotexist"); - QVERIFY(!iconNoFile.isNull()); - QVERIFY(!iconNoFile.actualSize(QSize(32, 32)).isValid()); - - // test string constructor with non-existing file with suffix - QIcon iconNoFileSuffix = QIcon("imagedoesnotexist.png"); - QVERIFY(!iconNoFileSuffix.isNull()); - QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); - - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - // test string constructor with existing file but unsupported format - QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); - QVERIFY(!iconUnsupportedFormat.isNull()); - QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); - - // test string constructor with existing file and supported format - QIcon iconSupportedFormat = QIcon(prefix + "image.png"); - QVERIFY(!iconSupportedFormat.isNull()); - QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); -} - -void tst_QIcon::swap() -{ - QPixmap p1(1, 1), p2(2, 2); - p1.fill(Qt::black); - p2.fill(Qt::black); - - QIcon i1(p1), i2(p2); - const qint64 i1k = i1.cacheKey(); - const qint64 i2k = i2.cacheKey(); - QVERIFY(i1k != i2k); - i1.swap(i2); - QCOMPARE(i1.cacheKey(), i2k); - QCOMPARE(i2.cacheKey(), i1k); -} - -void tst_QIcon::bestMatch() -{ - QPixmap p1(1, 1); - QPixmap p2(2, 2); - QPixmap p3(3, 3); - QPixmap p4(4, 4); - QPixmap p5(5, 5); - QPixmap p6(6, 6); - QPixmap p7(7, 7); - QPixmap p8(8, 8); - - p1.fill(Qt::black); - p2.fill(Qt::black); - p3.fill(Qt::black); - p4.fill(Qt::black); - p5.fill(Qt::black); - p6.fill(Qt::black); - p7.fill(Qt::black); - p8.fill(Qt::black); - - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 2; ++j) { - QIcon::State state = (j == 0) ? QIcon::On : QIcon::Off; - QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off - : QIcon::On; - QIcon::Mode mode; - QIcon::Mode oppositeMode; - - QIcon icon; - - switch (i) { - case 0: - default: - mode = QIcon::Normal; - oppositeMode = QIcon::Active; - break; - case 1: - mode = QIcon::Active; - oppositeMode = QIcon::Normal; - break; - case 2: - mode = QIcon::Disabled; - oppositeMode = QIcon::Selected; - break; - case 3: - mode = QIcon::Selected; - oppositeMode = QIcon::Disabled; - } - - /* - The test mirrors the code in - QPixmapIconEngine::bestMatch(), to make sure that - nobody breaks QPixmapIconEngine by mistake. Before - you change this test or the code that it tests, - please talk to the maintainer if possible. - */ - if (mode == QIcon::Disabled || mode == QIcon::Selected) { - icon.addPixmap(p1, oppositeMode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); - - icon.addPixmap(p2, oppositeMode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); - - icon.addPixmap(p3, QIcon::Active, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); - - icon.addPixmap(p4, QIcon::Normal, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); - - icon.addPixmap(p5, mode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); - - icon.addPixmap(p6, QIcon::Active, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); - - icon.addPixmap(p7, QIcon::Normal, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); - - icon.addPixmap(p8, mode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); - } else { - icon.addPixmap(p1, QIcon::Selected, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); - - icon.addPixmap(p2, QIcon::Disabled, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); - - icon.addPixmap(p3, QIcon::Selected, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); - - icon.addPixmap(p4, QIcon::Disabled, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); - - icon.addPixmap(p5, oppositeMode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); - - icon.addPixmap(p6, mode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); - - icon.addPixmap(p7, oppositeMode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); - - icon.addPixmap(p8, mode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); - } - } - } -} - -void tst_QIcon::cacheKey() -{ - QIcon icon1("image.png"); - qint64 icon1_key = icon1.cacheKey(); - QIcon icon2 = icon1; - - QVERIFY(icon2.cacheKey() == icon1.cacheKey()); - icon2.detach(); - QVERIFY(icon2.cacheKey() != icon1.cacheKey()); - QVERIFY(icon1.cacheKey() == icon1_key); -} - -void tst_QIcon::detach() -{ - QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); - img.fill(0xffff0000); - QIcon icon1(QPixmap::fromImage(img)); - QIcon icon2 = icon1; - icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64)); - - QImage img1 = icon1.pixmap(64, 64).toImage(); - QImage img2 = icon2.pixmap(64, 64).toImage(); - QVERIFY(img1 != img2); - - img1 = icon1.pixmap(32, 32).toImage(); - img2 = icon2.pixmap(32, 32).toImage(); - QVERIFY(img1 == img2); -} - -void tst_QIcon::addFile() -{ - QIcon icon; - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")); - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")); - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); - -#ifndef Q_OS_WINCE - QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); - QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); - QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); - QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); - QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); - QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); -#else - // WinCE only includes the 16x16 images for size reasons - QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); - QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); -#endif -} - -static bool sizeLess(const QSize &a, const QSize &b) -{ - return a.width() < b.width(); -} - -void tst_QIcon::availableSizes() -{ - { - QIcon icon; - icon.addFile("image.png", QSize(32,32)); - icon.addFile("image.png", QSize(64,64)); - icon.addFile("image.png", QSize(128,128)); - icon.addFile("image.png", QSize(256,256), QIcon::Disabled); - icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On); - - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 3); - qSort(availableSizes.begin(), availableSizes.end(), sizeLess); - QCOMPARE(availableSizes.at(0), QSize(32,32)); - QCOMPARE(availableSizes.at(1), QSize(64,64)); - QCOMPARE(availableSizes.at(2), QSize(128,128)); - - availableSizes = icon.availableSizes(QIcon::Disabled); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(256,256)); - - availableSizes = icon.availableSizes(QIcon::Normal, QIcon::On); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16,16)); - } - - { - // we try to load an icon from resources - QIcon icon(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16, 16)); - } - - { - // load an icon from binary data. - QPixmap pix; - QFile file(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); - QVERIFY(file.open(QIODevice::ReadOnly)); - uchar *data = file.map(0, file.size()); - QVERIFY(data != 0); - pix.loadFromData(data, file.size()); - QIcon icon(pix); - - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16,16)); - } - - { - // there shouldn't be available sizes for invalid images! - QVERIFY(QIcon(QLatin1String("")).availableSizes().isEmpty()); - QVERIFY(QIcon(QLatin1String("non-existing.png")).availableSizes().isEmpty()); - } -} - -void tst_QIcon::name() -{ - { - // No name if icon does not come from a theme - QIcon icon(":/image.png"); - QString name = icon.name(); - QVERIFY(name.isEmpty()); - } - - { - // Getting the name of an icon coming from a theme should work - QString searchPath = QLatin1String(":/icons"); - QIcon::setThemeSearchPaths(QStringList() << searchPath); - QString themeName("testtheme"); - QIcon::setThemeName(themeName); - - QIcon icon = QIcon::fromTheme("appointment-new"); - QString name = icon.name(); - QCOMPARE(name, QLatin1String("appointment-new")); - } -} - -void tst_QIcon::streamAvailableSizes_data() -{ - QTest::addColumn("icon"); - - QIcon icon; - icon.addFile(":/image.png", QSize(32,32)); - QTest::newRow( "32x32" ) << icon; - icon.addFile(":/image.png", QSize(64,64)); - QTest::newRow( "64x64" ) << icon; - icon.addFile(":/image.png", QSize(128,128)); - QTest::newRow( "128x128" ) << icon; - icon.addFile(":/image.png", QSize(256,256)); - QTest::newRow( "256x256" ) << icon; -} - -void tst_QIcon::streamAvailableSizes() -{ - QFETCH(QIcon, icon); - - QByteArray ba; - // write to QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << icon; - } - - // read from QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream stream(&buffer); - QIcon i; - stream >> i; - QCOMPARE(i.isNull(), icon.isNull()); - QCOMPARE(i.availableSizes(), icon.availableSizes()); - } -} - - -static inline bool operator<(const QSize &lhs, const QSize &rhs) -{ - if (lhs.width() < rhs.width()) - return true; - else if (lhs.width() == lhs.width()) - return lhs.height() < lhs.height(); - return false; -} - -void tst_QIcon::task184901_badCache() -{ - QPixmap pm(QFINDTESTDATA("image.png")); - QIcon icon(pm); - - //the disabled icon must have an effect (grayed) - QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() != icon.pixmap(32, QIcon::Disabled).toImage()); - - icon.addPixmap(pm, QIcon::Disabled); - //the disabled icon must now be the same as the normal one. - QVERIFY( icon.pixmap(32, QIcon::Normal).toImage() == icon.pixmap(32, QIcon::Disabled).toImage() ); -} - -void tst_QIcon::fromTheme() -{ - QString searchPath = QLatin1String(":/icons"); - QIcon::setThemeSearchPaths(QStringList() << searchPath); - QVERIFY(QIcon::themeSearchPaths().size() == 1); - QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); - - QString themeName("testtheme"); - QIcon::setThemeName(themeName); - QCOMPARE(QIcon::themeName(), themeName); - - // Test normal icon - QIcon appointmentIcon = QIcon::fromTheme("appointment-new"); - QVERIFY(!appointmentIcon.isNull()); - QVERIFY(!appointmentIcon.availableSizes(QIcon::Normal, QIcon::Off).isEmpty()); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(16, 16))); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(32, 32))); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(22, 22))); - - // Test icon from parent theme - QIcon abIcon = QIcon::fromTheme("address-book-new"); - QVERIFY(!abIcon.isNull()); - QVERIFY(QIcon::hasThemeIcon("address-book-new")); - QVERIFY(!abIcon.availableSizes().isEmpty()); - - // Test non existing icon - QIcon noIcon = QIcon::fromTheme("broken-icon"); - QVERIFY(noIcon.isNull()); - QVERIFY(!QIcon::hasThemeIcon("broken-icon")); - - // Test non existing icon with fallback - noIcon = QIcon::fromTheme("broken-icon", abIcon); - QVERIFY(noIcon.cacheKey() == abIcon.cacheKey()); - - // Test svg-only icon - noIcon = QIcon::fromTheme("svg-icon", abIcon); - QVERIFY(!noIcon.availableSizes().isEmpty()); - - QByteArray ba; - // write to QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << abIcon; - } - - // read from QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream stream(&buffer); - QIcon i; - stream >> i; - QCOMPARE(i.isNull(), abIcon.isNull()); - QCOMPARE(i.availableSizes(), abIcon.availableSizes()); - } - - // Make sure setting the theme name clears the state - QIcon::setThemeName(""); - abIcon = QIcon::fromTheme("address-book-new"); - QVERIFY(abIcon.isNull()); -} - - -void tst_QIcon::task223279_inconsistentAddFile() -{ - QIcon icon1; - icon1.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); - icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); - QPixmap pm1 = icon1.pixmap(32, 32); - - QIcon icon2; - icon2.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); - icon2.addFile(QLatin1String("IconThatDoesntExist")); - QPixmap pm2 = icon1.pixmap(32, 32); - - QCOMPARE(pm1.isNull(), false); - QCOMPARE(pm1.size(), QSize(16,16)); - QCOMPARE(pm1.isNull(), pm2.isNull()); - QCOMPARE(pm1.size(), pm2.size()); -} - - -QTEST_MAIN(tst_QIcon) -#include "tst_qicon.moc" diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.qrc b/tests/auto/widgets/kernel/qicon/tst_qicon.qrc deleted file mode 100644 index 7925a33c84..0000000000 --- a/tests/auto/widgets/kernel/qicon/tst_qicon.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - -image.png -rect.png -./icons/testtheme/16x16/actions/appointment-new.png -./icons/testtheme/22x22/actions/appointment-new.png -./icons/testtheme/32x32/actions/appointment-new.png -./icons/testtheme/index.theme -./icons/testtheme/scalable/actions/svg-only.svg -./icons/themeparent/16x16/actions/address-book-new.png -./icons/themeparent/16x16/actions/appointment-new.png -./icons/themeparent/22x22/actions/address-book-new.png -./icons/themeparent/22x22/actions/appointment-new.png -./icons/themeparent/32x32/actions/address-book-new.png -./icons/themeparent/32x32/actions/appointment-new.png -./icons/themeparent/index.theme -./icons/themeparent/scalable/actions/address-book-new.svg -./icons/themeparent/scalable/actions/appointment-new.svg - - -- cgit v1.2.3