Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,10 @@ Item {
// Not "top": every Item already has a FINAL top anchor line, and
// Qt 6.12 refuses to load a file that redeclares it.
readonly property real shadeTop: root.wide ? sheet.y : sheet.y + sheet.height + Style.spacing.lg
readonly property real room: window.height - shadeTop - Style.gapsOut
// Sliding changes position, not the settled notification viewport.
// Expansion still updates the available room through sheet.height.
readonly property real restingTop: root.wide ? Style.gapsOut : Style.gapsOut + sheet.height + Style.spacing.lg
readonly property real room: window.height - restingTop - Style.gapsOut
readonly property real insets: shade.contentTopInset + shade.contentBottomInset
readonly property real listHeight: root.notifications.length > 0 ? shadeList.contentHeight : shadeEmpty.implicitHeight
// The media card and the gap under it, when a player is up.
Expand Down
13 changes: 13 additions & 0 deletions packages/omamobile-shell/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,19 @@ elif [[ $rc != 0 ]]; then
else
pass "the shade under touch: a swipe forgets one, a short one springs back, a tap taps, a drag scrolls"
fi
# The notification viewport keeps its settled height during sheet motion.
rc=0
out=$(python3 -B test/quicksettings-shade-layout.py \
plugins/omamobile.quicksettings/QuickSettings.qml 2>&1) || rc=$?
if [[ $rc == 77 ]]; then
pass "stable notification viewport # SKIP no qmltestrunner"
elif [[ $rc != 0 ]]; then
printf '%s\n' "$out" >&2
fail "stable notification viewport (test/quicksettings-shade-layout.py)"
else
pass "notification viewport stays stable while sliding and follows expansion"
fi

# The shade's media card (MPRIS): which player shows, what each control
# calls, the seek bar, the card's tap. test/media-touch drives it; the art
# rule and the order are in test/media-model.js; test/quicksettings-render
Expand Down
100 changes: 100 additions & 0 deletions packages/omamobile-shell/test/quicksettings-shade-layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
"""Exercise actual QuickSettings geometry expressions under real Qt bindings."""

import argparse
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile


def expression(section, name):
pattern = r"^ readonly property real " + name + r": (.+)$"
match = re.search(pattern, section, re.MULTILINE)
if not match:
raise RuntimeError("Missing production property " + name)
return match[1].replace("Style.", "style.")


def fixture(source, baseline):
section = source[source.index(" // ---------- The notification shade:"):]
position = re.search(r"^ y: (Style.gapsOut.+)$", source, re.MULTILINE)
if not position:
raise RuntimeError("Missing production sheet position")

if baseline:
resting = (
"root.wide ? style.gapsOut : "
"style.gapsOut + sheet.height + style.spacing.lg"
)
churn = "verify(root.roomChanges > 3);\n verify(root.heightChanges > 3);"
drag = "compare(shade.height, before + 50);"
else:
resting = expression(section, "restingTop")
churn = "compare(root.roomChanges, 0);\n compare(root.heightChanges, 0);"
drag = "compare(shade.height, before);"

replacements = {
"POSITION": position[1].replace("Style.", "style."),
"SHADETOP": expression(section, "shadeTop"),
"RESTING": resting,
"ROOM": expression(section, "room"),
"CHURN": churn,
"DRAG": drag,
}
template = Path(__file__).with_name("quicksettings-shade-layout.qml.in").read_text()
for placeholder, value in replacements.items():
if template.count(placeholder) != 1:
raise RuntimeError("Unexpected template placeholder " + placeholder)
template = template.replace(placeholder, value)
return template


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("source", type=Path)
parser.add_argument("--baseline", action="store_true")
args = parser.parse_args()
runner = (
shutil.which("qmltestrunner6")
or shutil.which("/usr/lib/qt6/bin/qmltestrunner")
or shutil.which("qmltestrunner")
)
if not runner:
print("quicksettings-shade-layout: no qmltestrunner")
return 77
qml = fixture(args.source.read_text(), args.baseline)

with tempfile.TemporaryDirectory(prefix="public-shade-") as directory:
root = Path(directory)
runtime = root / "runtime"
runtime.mkdir(mode=0o700)
test = root / "tst_shade.qml"
test.write_text(qml)

environment = os.environ.copy()
environment.update(
QT_QPA_PLATFORM="offscreen",
QT_QUICK_BACKEND="software",
QT_QPA_PLATFORMTHEME="generic",
GSETTINGS_BACKEND="memory",
XDG_RUNTIME_DIR=str(runtime),
)
environment.pop("QT_QPA_GENERIC_PLUGINS", None)
environment.pop("QT_PLUGIN_PATH", None)
result = subprocess.run(
[runner, "-input", str(test)],
env=environment,
capture_output=True,
text=True,
timeout=5,
)
print(result.stdout + result.stderr, end="")
return result.returncode


if __name__ == "__main__":
raise SystemExit(main())
136 changes: 136 additions & 0 deletions packages/omamobile-shell/test/quicksettings-shade-layout.qml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// SPDX-License-Identifier: MIT
import QtQuick
import QtTest

TestCase {
id: test
name: "PublicShadeViewport"
when: windowShown
visible: true
width: 120
height: 120
QtObject {
id: style
readonly property real gapsOut: 24
readonly property var spacing: ({
lg: 20
})
}
QtObject {
id: window
property real height: 935
}
Item {
id: root
property bool wide: false
property bool editing: false
property real reveal: 0
property real baseHeight: 400
property int roomChanges: 0
property int heightChanges: 0
QtObject {
id: drag
property real offset: 0
}
Item {
id: sheet
height: root.baseHeight
y: POSITION
}
Item {
id: shade
readonly property real shadeTop: SHADETOP
readonly property real restingTop: RESTING
readonly property real room: ROOM
property real natural: 900
y: shadeTop
height: Math.min(natural, room)
onRoomChanged: root.roomChanges++
onHeightChanged: root.heightChanges++
}
NumberAnimation {
id: slide
target: root
property: "reveal"
from: 0
to: 1
duration: 220
}
}
function init() {
slide.stop();
root.wide = false;
window.height = 935;
root.baseHeight = 400;
drag.offset = 0;
root.reveal = 0;
shade.natural = 900;
wait(10);
root.roomChanges = 0;
root.heightChanges = 0;
}
function test_animationLayoutChurn() {
slide.start();
tryVerify(function () {
return !slide.running;
}, 600);
console.log("REVEAL_GEOMETRY_UPDATES", root.roomChanges, root.heightChanges);
CHURN;
compare(shade.room, window.height - style.gapsOut - sheet.height - style.spacing.lg - style.gapsOut);
}
function test_endStateAndExpansion() {
root.reveal = 1;
var cases = [
{
wide: false,
h: 935,
sheet: 400,
n: 100
},
{
wide: false,
h: 935,
sheet: 400,
n: 900
},
{
wide: true,
h: 420,
sheet: 320,
n: 900
},
{
wide: false,
h: 300,
sheet: 280,
n: 900
}
];
for (var i = 0; i < cases.length; i++) {
var v = cases[i];
root.wide = v.wide;
window.height = v.h;
root.baseHeight = v.sheet;
shade.natural = v.n;
var room = v.h - (v.wide ? style.gapsOut : style.gapsOut + v.sheet + style.spacing.lg) - style.gapsOut;
compare(shade.room, room);
compare(shade.height, Math.min(v.n, room));
compare(shade.y, v.wide ? style.gapsOut : style.gapsOut + v.sheet + style.spacing.lg);
}
root.wide = false;
window.height = 935;
root.baseHeight = 400;
shade.natural = 900;
var old = shade.height;
root.baseHeight = 500;
verify(shade.height < old);
}
function test_dragKeepsLayout() {
root.reveal = 1;
var before = shade.height;
var y = shade.y;
drag.offset = -50;
compare(shade.y, y - 50);
DRAG;
}
}
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.108
0.2.109