Warning, /frameworks/kirigami/autotests/tst_ImageColors.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtTest
0009 import org.kde.kirigami as Kirigami
0010 
0011 TestCase {
0012     id: testCase
0013     name: "ImageColorsTest"
0014 
0015     width: 400
0016     height: 400
0017     visible: true
0018 
0019     when: windowShown
0020 
0021     Component {
0022         id: windowComponent
0023         Window {
0024             id: window
0025             width: 100
0026             height: 100
0027             visible: true
0028             property alias colorArea: colorArea
0029             property alias imageColors: imageColors
0030             property alias paletteChangedSpy: paletteChangedSpy
0031             Rectangle {
0032                 id: colorArea
0033                 anchors.fill: parent
0034                 color: "transparent"
0035             }
0036             Kirigami.ImageColors {
0037                 id: imageColors
0038                 source: colorArea
0039             }
0040             SignalSpy {
0041                 id: paletteChangedSpy
0042                 target: imageColors
0043                 signalName: "paletteChanged"
0044             }
0045         }
0046     }
0047 
0048 
0049     function test_extractColors() {
0050         const window = createTemporaryObject(windowComponent, testCase)
0051 
0052         tryVerify(() => window.visible)
0053 
0054         window.colorArea.color = Qt.rgba(1, 0, 0)
0055         window.imageColors.update()
0056         window.paletteChangedSpy.wait()
0057         compare(window.paletteChangedSpy.count, 1)
0058         compare(window.imageColors.palette.length, 1)
0059         compare(window.imageColors.dominant, window.colorArea.color)
0060     }
0061 }