Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qml/controls/CoreCheckBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import QtQuick 2.15
import QtQuick.Controls 2.15
import org.bitcoincore.qt 1.0

AbstractButton {
id: root
Expand Down
1 change: 1 addition & 0 deletions test/qml/bitcoin_qmltests.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<file>tst_contextmenupicker.qml</file>
<file>tst_contextmenu.qml</file>
<file>tst_contextmenutoggle.qml</file>
<file>tst_corecheckbox.qml</file>
<file>tst_createbackup.qml</file>
<file>tst_createname.qml</file>
<file>tst_createpassword.qml</file>
Expand Down
66 changes: 66 additions & 0 deletions test/qml/tst_corecheckbox.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (c) 2026 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtTest 1.2
import org.bitcoincore.qt 1.0
import "../../qml/controls"

TestCase {
name: "CoreCheckBox"
when: windowShown
width: 400
height: 200

property bool initialIsDesktop: true

Component {
id: checkBoxComponent
CoreCheckBox {}
}

function initTestCase() {
// AppMode is a process-wide singleton shared with the other test files.
initialIsDesktop = AppMode.isDesktop
}

function cleanupTestCase() {
AppMode.isDesktop = initialIsDesktop
}

function test_hover_enabled_follows_app_mode() {
const box = createTemporaryObject(checkBoxComponent, this)
verify(box !== null)

AppMode.isDesktop = true
compare(box.hoverEnabled, true)

AppMode.isDesktop = false
compare(box.hoverEnabled, false)

AppMode.isDesktop = true
compare(box.hoverEnabled, true)
}

function test_toggles_and_reflects_checked_state() {
const box = createTemporaryObject(checkBoxComponent, this)
verify(box !== null)
verify(box.checkable)
verify(!box.checked)
compare(box.contentItem.color, "#00000000")
compare(box.contentItem.border.color, box.borderColor)

box.toggle()

verify(box.checked)
compare(box.contentItem.color, box.fillColor)
compare(box.contentItem.border.color, box.fillColor)

box.toggle()

verify(!box.checked)
compare(box.contentItem.color, "#00000000")
compare(box.contentItem.border.color, box.borderColor)
}
}
Loading