aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/luatests/luatests/tst_aspectcontainer.lua
blob: f948583e1c18bae7a5bc91b384ff61276fc1cf87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- Copyright (C) 2024 The Qt Company Ltd.
-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
T = require("qtctest")
local S = require('Settings')

local function testAutoApply()
    local container = S.AspectContainer.create({ autoApply = true })

    container.test = S.BoolAspect.create({ defaultValue = true })
    T.compare(container.test.value, true)
    container.test.volatileValue = false
    T.compare(container.test.volatileValue, false)
    T.compare(container.test.value, false)
end

local function testNoAutoApply()
    local container = S.AspectContainer.create({ autoApply = false })

    container.test = S.BoolAspect.create({ defaultValue = true })
    T.compare(container.test.value, true)
    container.test.volatileValue = false
    T.compare(container.test.volatileValue, false)
    T.compare(container.test.value, true)
    container:apply()
    T.compare(container.test.volatileValue, false)
    T.compare(container.test.value, false)
end

return {
    testAutoApply = testAutoApply,
    testNoAutoApply = testNoAutoApply,
}