mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-10 17:55:40 +02:00
tests: avoid initializing the ViewCoordinator root view
This doesn't make much sense with our current test structure, and will add a StackView component on top of the UUT. Change-Id: Ice3425bfea0b5229c87caf3fa22b181ce6aa520d
This commit is contained in:
parent
b38e216721
commit
07e0b10478
6 changed files with 72 additions and 22 deletions
|
@ -55,6 +55,7 @@ ApplicationWindow {
|
|||
|
||||
Loader {
|
||||
id: loader
|
||||
|
||||
source: Qt.resolvedUrl(testComponentURI)
|
||||
onStatusChanged: {
|
||||
console.log("Status changed to:", loader.status)
|
||||
|
@ -66,7 +67,6 @@ ApplicationWindow {
|
|||
// If any of the dimensions are not set, set them to the appWindow's dimensions
|
||||
item.width = item.width || Qt.binding(() => appWindow.width);
|
||||
item.height = item.height || Qt.binding(() => appWindow.height);
|
||||
viewCoordinator.init(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,14 +273,46 @@ ItemDelegate {
|
|||
popup: Popup {
|
||||
id: itemPopup
|
||||
|
||||
y: isVertical ? -(implicitHeight - root.height) / 2 - 18 : -implicitHeight - 12
|
||||
y: {
|
||||
// Determine the y position based on the orientation.
|
||||
if (isVertical) {
|
||||
// For a vertical layout, adjust the y position to center the item vertically
|
||||
// relative to the root's height, with an additional upward offset of 18 pixels.
|
||||
y = -(implicitHeight - root.height) / 2 - 18;
|
||||
} else {
|
||||
// For non-vertical layouts, position the item fully above its normal position
|
||||
// with an upward offset of 12 pixels from its implicit height.
|
||||
y = -implicitHeight - 12;
|
||||
}
|
||||
}
|
||||
|
||||
x: {
|
||||
if (isVertical)
|
||||
return -implicitWidth - 12;
|
||||
// Initialize the x position based on the orientation.
|
||||
if (isVertical) {
|
||||
// If the layout is vertical, position the item to the left of its implicit width
|
||||
// with an additional offset of 12 pixels.
|
||||
x = -implicitWidth - 12;
|
||||
} else {
|
||||
// Note: isn't some of this logic built into the Popup?
|
||||
|
||||
// Calculate an initial x value aiming to center the item horizontally
|
||||
// relative to the root's width, with an additional offset.
|
||||
var xValue = -(implicitWidth - root.width) / 2 - 18;
|
||||
var mainPoint = mapToItem(viewCoordinator.rootView, xValue, y);
|
||||
var diff = mainPoint.x + itemListView.implicitWidth - viewCoordinator.rootView.width;
|
||||
return diff > 0 ? xValue - diff - 24 : xValue;
|
||||
|
||||
// Map the adjusted x value to the coordinate space of the callOverlay to
|
||||
// determine the actual position of the item within the overlay.
|
||||
var pointMappedContainer = mapToItem(callOverlay, xValue, y);
|
||||
|
||||
// Calculate the difference between the right edge of the itemListView
|
||||
// (considering its position within callOverlay) and the right edge of the callOverlay.
|
||||
// This checks if the item extends outside the overlay.
|
||||
var diff = pointMappedContainer.x + itemListView.implicitWidth - callOverlay.width;
|
||||
|
||||
// If the item extends beyond the overlay, adjust x value to the left to ensure
|
||||
// it fits within the overlay, with an extra leftward margin of 24 pixels.
|
||||
x = diff > 0 ? xValue - diff - 24 : xValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
implicitWidth: contentItem.implicitWidth
|
||||
|
|
|
@ -190,6 +190,7 @@ Rectangle {
|
|||
opacity: hidden ? callOverlay.mainOverlayOpacity : 1
|
||||
|
||||
// Allow hiding the preview (available when anchored)
|
||||
readonly property bool hovered: hoverHandler.hovered
|
||||
readonly property bool anchored: state !== "unanchored"
|
||||
property bool hidden: false
|
||||
readonly property real hiddenHandleSize: 32
|
||||
|
@ -226,7 +227,7 @@ Rectangle {
|
|||
]
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
opacity: (localPreview.anchored && hoverHandler.hovered) || localPreview.hidden
|
||||
opacity: (localPreview.anchored && localPreview.hovered) || localPreview.hidden
|
||||
Behavior on opacity { NumberAnimation { duration: 250; easing.type: Easing.OutExpo }}
|
||||
visible: opacity > 0
|
||||
background: Rectangle {
|
||||
|
|
|
@ -74,6 +74,11 @@ public Q_SLOTS:
|
|||
*/
|
||||
void applicationAvailable()
|
||||
{
|
||||
QLoggingCategory::setFilterRules("\n"
|
||||
"*.debug=false\n"
|
||||
"libclient.debug=false\n"
|
||||
"\n");
|
||||
|
||||
connectivityMonitor_.reset(new ConnectivityMonitor(this));
|
||||
settingsManager_.reset(new AppSettingsManager(this));
|
||||
systemTray_.reset(new SystemTray(settingsManager_.get(), this));
|
||||
|
|
|
@ -39,6 +39,7 @@ Item {
|
|||
spy.target = signalObject;
|
||||
spy.signalName = signalName;
|
||||
// Perform the action that should emit the signal.
|
||||
if (action)
|
||||
action();
|
||||
// Wait a maximum of 1 second for the signal to be emitted.
|
||||
spy.wait(1000);
|
||||
|
@ -52,8 +53,6 @@ Item {
|
|||
when: QTestRootObject.windowShown
|
||||
}
|
||||
|
||||
Component.onCompleted: viewCoordinator.init(this)
|
||||
|
||||
property int visibility: 0
|
||||
Binding {
|
||||
tw.visibility: uut.Window.window.visibility
|
||||
|
|
|
@ -106,6 +106,9 @@ TestWrapper {
|
|||
"visibleChanged",
|
||||
() => localPreview.stop(),
|
||||
() => !localPreview.visible));
|
||||
|
||||
// Move the mouse to the center of the call screen.
|
||||
mouseMove(uut);
|
||||
}
|
||||
|
||||
function test_localPreviewAnchoring() {
|
||||
|
@ -113,7 +116,7 @@ TestWrapper {
|
|||
const container = localPreview.parent;
|
||||
|
||||
// First check that the preview is anchored.
|
||||
verify(localPreview.state.indexOf("unanchored") === -1);
|
||||
verify(localPreview.anchored);
|
||||
|
||||
const containerCenter = Qt.point(container.width / 2, container.height / 2);
|
||||
function moveAndVerifyState(dx, dy, expectedState) {
|
||||
|
@ -139,7 +142,7 @@ TestWrapper {
|
|||
// Verify that during a drag process, the preview is unanchored.
|
||||
mousePress(localPreview);
|
||||
mouseMove(localPreview, 100, 100);
|
||||
verify(localPreview.state.indexOf("unanchored") !== -1);
|
||||
verify(!localPreview.anchored);
|
||||
mouseRelease(localPreview);
|
||||
});
|
||||
}
|
||||
|
@ -147,23 +150,33 @@ TestWrapper {
|
|||
function test_localPreviewHiding() {
|
||||
localPreviewTestWrapper(function(localPreview) {
|
||||
// Make sure the preview is anchored.
|
||||
verify(localPreview.state.indexOf("unanchored") === -1);
|
||||
verify(localPreview.anchored);
|
||||
|
||||
// It should also not be hidden.
|
||||
compare(localPreview.hidden, false);
|
||||
|
||||
// We presume that the preview is anchored and that once we hover over the
|
||||
// local preview, that the hide button will become visible.
|
||||
// Note: There is currently an issue where the CallOverlay is detecting hover
|
||||
// events, but child controls are not. This should be addressed as it seems
|
||||
// to affect MouseArea, HoverHandler, Buttons, and other controls that rely
|
||||
// on hover events. For now, we'll manually trigger the onClicked event.
|
||||
const hidePreviewButton = findChild(localPreview, "hidePreviewButton");
|
||||
hidePreviewButton.onClicked();
|
||||
// This is required when the opacity has an animation.
|
||||
if (hidePreviewButton.visible) {
|
||||
verify(waitForSignalAndCheck(hidePreviewButton,
|
||||
"visibleChanged",
|
||||
undefined,
|
||||
() => !hidePreviewButton.visible));
|
||||
}
|
||||
compare(hidePreviewButton.visible, false);
|
||||
verify(waitForSignalAndCheck(hidePreviewButton,
|
||||
"visibleChanged",
|
||||
() => mouseMove(localPreview),
|
||||
() => hidePreviewButton.visible));
|
||||
|
||||
// Click the hide button to hide the preview.
|
||||
mouseClick(hidePreviewButton);
|
||||
compare(localPreview.hidden, true);
|
||||
|
||||
// "Click" the hide button again to unhide the preview.
|
||||
hidePreviewButton.onClicked();
|
||||
// Click the hide button again to show the preview.
|
||||
mouseClick(hidePreviewButton);
|
||||
compare(localPreview.hidden, false);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue