diff --git a/tests/src/python/test_qgsprojectstylesettings.py b/tests/src/python/test_qgsprojectstylesettings.py index b423c4c0242b..2222520abc64 100644 --- a/tests/src/python/test_qgsprojectstylesettings.py +++ b/tests/src/python/test_qgsprojectstylesettings.py @@ -18,6 +18,7 @@ Qt, QTemporaryDir, QTemporaryFile, + QT_VERSION, ) from qgis.PyQt.QtGui import QColor, QColorSpace, QFont from qgis.PyQt.QtTest import QSignalSpy @@ -889,10 +890,14 @@ def testReadWrite(self): [unitTestDataPath() + "/style1.db", unitTestDataPath() + "/style2.db"], ) + @unittest.skipIf( + QT_VERSION < 0x060800, "CMYK support was not complete before Qt 6.8.0" + ) def testColorSettings(self): """ Test ICC profile attachment """ + project = QgsProject() settings = project.styleSettings() self.assertFalse(project.isDirty()) @@ -907,6 +912,7 @@ def testColorSettings(self): project.setDirty(False) self.assertEqual(settings.colorModel(), Qgis.ColorModel.Cmyk) + # set an RGB color space, reset color model to RGB with open(os.path.join(TEST_DATA_DIR, "sRGB2014.icc"), mode="rb") as f: colorSpace = QColorSpace.fromIccProfile(f.read()) @@ -914,10 +920,26 @@ def testColorSettings(self): settings.setColorSpace(colorSpace) self.assertTrue(project.isDirty()) + self.assertEqual(settings.colorModel(), Qgis.ColorModel.Rgb) self.assertTrue(settings.colorSpace().isValid()) self.assertEqual(settings.colorSpace().primaries(), QColorSpace.Primaries.SRgb) self.assertEqual(len(project.attachedFiles()), 2) + # set a CMYK color space, reset color model to CMYK + with open(os.path.join(TEST_DATA_DIR, "CGATS21_CRPC6.icc"), mode="rb") as f: + colorSpace = QColorSpace.fromIccProfile(f.read()) + + self.assertTrue(colorSpace.isValid()) + + settings.setColorSpace(colorSpace) + self.assertTrue(project.isDirty()) + self.assertEqual(settings.colorModel(), Qgis.ColorModel.Cmyk) + self.assertTrue(settings.colorSpace().isValid()) + self.assertEqual( + settings.colorSpace().primaries(), QColorSpace.Primaries.Custom + ) + self.assertEqual(len(project.attachedFiles()), 2) + # save and restore projectFile = QTemporaryFile( QDir.temp().absoluteFilePath("testCmykSettings.qgz") @@ -930,7 +952,9 @@ def testColorSettings(self): settings = project.styleSettings() self.assertEqual(settings.colorModel(), Qgis.ColorModel.Cmyk) self.assertTrue(settings.colorSpace().isValid()) - self.assertEqual(settings.colorSpace().primaries(), QColorSpace.Primaries.SRgb) + self.assertEqual( + settings.colorSpace().primaries(), QColorSpace.Primaries.Custom + ) self.assertEqual(len(project.attachedFiles()), 2) # clear color space