autotests: add a test for autorotation with different panel orientations

CCBUG: 494761
wilder/Plasma/6.3
Xaver Hugl 1 year ago
parent fb97ecce73
commit b0bde6398a
  1. 2
      autotests/integration/CMakeLists.txt
  2. 1
      autotests/integration/kwin_wayland_test.cpp
  3. 1
      autotests/integration/kwin_wayland_test.h
  4. 62
      autotests/integration/outputchanges_test.cpp
  5. 2
      src/backends/virtual/virtual_backend.cpp
  6. 1
      src/backends/virtual/virtual_backend.h
  7. 3
      src/backends/virtual/virtual_output.cpp
  8. 2
      src/backends/virtual/virtual_output.h

@ -120,7 +120,7 @@ integrationTest(NAME testActivation SRCS activation_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testInputMethod SRCS inputmethod_test.cpp LIBS XKB::XKB)
integrationTest(NAME testScreens SRCS screens_test.cpp)
integrationTest(NAME testScreenEdges SRCS screenedges_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testOutputChanges SRCS outputchanges_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testOutputChanges SRCS outputchanges_test.cpp LIBS XCB::ICCCM Qt::Sensors)
integrationTest(NAME testTiles SRCS tiles_test.cpp)
integrationTest(NAME testFractionalScaling SRCS fractional_scaling_test.cpp)
integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM)

@ -300,6 +300,7 @@ void Test::setOutputConfig(const QList<OutputInfo> &infos)
.internal = info.internal,
.physicalSizeInMM = info.physicalSizeInMM,
.modes = info.modes,
.panelOrientation = info.panelOrientation,
};
});
static_cast<VirtualBackend *>(kwinApp()->outputBackend())->setVirtualOutputs(converted);

@ -931,6 +931,7 @@ struct OutputInfo
bool internal = false;
QSize physicalSizeInMM;
QList<std::tuple<QSize, uint64_t, OutputMode::Flags>> modes;
OutputTransform panelOrientation = OutputTransform::Kind::Normal;
};
void setOutputConfig(const QList<QRect> &geometries);
void setOutputConfig(const QList<OutputInfo> &infos);

@ -18,6 +18,7 @@
#include "x11window.h"
#include <KWayland/Client/surface.h>
#include <QOrientationSensor>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
@ -62,6 +63,8 @@ private Q_SLOTS:
void testLaptopLidClosed();
void testGenerateConfigs_data();
void testGenerateConfigs();
void testAutorotate_data();
void testAutorotate();
};
void OutputChangesTest::initTestCase()
@ -1290,6 +1293,65 @@ void OutputChangesTest::testGenerateConfigs()
QCOMPARE(*outputConfig->scale, defaultScale);
}
void OutputChangesTest::testAutorotate_data()
{
QTest::addColumn<OutputTransform::Kind>("panelOrientation");
QTest::addColumn<QOrientationReading::Orientation>("orientation");
QTest::addColumn<OutputTransform::Kind>("expectedRotation");
QTest::addRow("panel orientation normal, no rotation") << OutputTransform::Kind::Normal << QOrientationReading::Orientation::TopUp << OutputTransform::Kind::Normal;
QTest::addRow("panel orientation normal, rotated 90° right") << OutputTransform::Kind::Normal << QOrientationReading::Orientation::LeftUp << OutputTransform::Kind::Rotate90;
QTest::addRow("panel orientation normal, rotated 180°") << OutputTransform::Kind::Normal << QOrientationReading::Orientation::TopDown << OutputTransform::Kind::Rotate180;
QTest::addRow("panel orientation normal, rotated 90° left") << OutputTransform::Kind::Normal << QOrientationReading::Orientation::RightUp << OutputTransform::Kind::Rotate270;
QTest::addRow("panel orientation left up, no rotation") << OutputTransform::Kind::Rotate90 << QOrientationReading::Orientation::TopUp << OutputTransform::Kind::Rotate90;
QTest::addRow("panel orientation left up, rotated 90° right") << OutputTransform::Kind::Rotate90 << QOrientationReading::Orientation::LeftUp << OutputTransform::Kind::Rotate180;
QTest::addRow("panel orientation left up, rotated 180°") << OutputTransform::Kind::Rotate90 << QOrientationReading::Orientation::TopDown << OutputTransform::Kind::Rotate270;
QTest::addRow("panel orientation left up, rotated 90° left") << OutputTransform::Kind::Rotate90 << QOrientationReading::Orientation::RightUp << OutputTransform::Kind::Normal;
QTest::addRow("panel orientation upside down, no rotation") << OutputTransform::Kind::Rotate180 << QOrientationReading::Orientation::TopUp << OutputTransform::Kind::Rotate180;
QTest::addRow("panel orientation upside down, rotated 90° right") << OutputTransform::Kind::Rotate180 << QOrientationReading::Orientation::LeftUp << OutputTransform::Kind::Rotate270;
QTest::addRow("panel orientation upside down, rotated 180°") << OutputTransform::Kind::Rotate180 << QOrientationReading::Orientation::TopDown << OutputTransform::Kind::Normal;
QTest::addRow("panel orientation upside down, rotated 90° left") << OutputTransform::Kind::Rotate180 << QOrientationReading::Orientation::RightUp << OutputTransform::Kind::Rotate90;
QTest::addRow("panel orientation right up, no rotation") << OutputTransform::Kind::Rotate270 << QOrientationReading::Orientation::TopUp << OutputTransform::Kind::Rotate270;
QTest::addRow("panel orientation right up, rotated 90° right") << OutputTransform::Kind::Rotate270 << QOrientationReading::Orientation::LeftUp << OutputTransform::Kind::Normal;
QTest::addRow("panel orientation right up, rotated 180°") << OutputTransform::Kind::Rotate270 << QOrientationReading::Orientation::TopDown << OutputTransform::Kind::Rotate90;
QTest::addRow("panel orientation right up, rotated 90° left") << OutputTransform::Kind::Rotate270 << QOrientationReading::Orientation::RightUp << OutputTransform::Kind::Rotate180;
}
void OutputChangesTest::testAutorotate()
{
// delete the previous config to avoid clashes between test runs
QFile(QStandardPaths::locate(QStandardPaths::ConfigLocation, QStringLiteral("kwinoutputconfig.json"))).remove();
QFETCH(OutputTransform::Kind, panelOrientation);
Test::setOutputConfig({Test::OutputInfo{
.geometry = QRect(0, 0, 1280, 1024),
.internal = true,
.physicalSizeInMM = QSize(598, 336),
.modes = {ModeInfo(QSize(1280, 1024), 60000, OutputMode::Flag::Preferred)},
.panelOrientation = panelOrientation,
}});
QFETCH(QOrientationReading::Orientation, orientation);
QOrientationReading sensorReading;
sensorReading.setOrientation(orientation);
const auto outputs = kwinApp()->outputBackend()->outputs();
OutputConfigurationStore configs;
auto cfg = configs.queryConfig(outputs, false, &sensorReading, true);
QVERIFY(cfg.has_value());
const auto [config, order, type] = *cfg;
const auto outputConfig = config.constChangeSet(outputs.front());
QCOMPARE(outputConfig->autoRotationPolicy, Output::AutoRotationPolicy::InTabletMode);
QFETCH(OutputTransform::Kind, expectedRotation);
QVERIFY(outputConfig->transform.has_value());
QCOMPARE(outputConfig->transform->kind(), expectedRotation);
}
} // namespace KWin
WAYLANDTEST_MAIN(KWin::OutputChangesTest)

@ -102,7 +102,7 @@ Outputs VirtualBackend::outputs() const
VirtualOutput *VirtualBackend::createOutput(const OutputInfo &info)
{
VirtualOutput *output = new VirtualOutput(this, info.internal, info.physicalSizeInMM);
VirtualOutput *output = new VirtualOutput(this, info.internal, info.physicalSizeInMM, info.panelOrientation);
output->init(info.geometry.topLeft(), info.geometry.size() * info.scale, info.scale, info.modes);
m_outputs.append(output);
Q_EMIT outputAdded(output);

@ -40,6 +40,7 @@ public:
bool internal = false;
QSize physicalSizeInMM;
QList<std::tuple<QSize, uint64_t, OutputMode::Flags>> modes;
OutputTransform panelOrientation = OutputTransform::Kind::Normal;
};
Output *addOutput(const OutputInfo &info);
void setVirtualOutputs(const QList<OutputInfo> &infos);

@ -19,7 +19,7 @@
namespace KWin
{
VirtualOutput::VirtualOutput(VirtualBackend *parent, bool internal, const QSize &physicalSizeInMM)
VirtualOutput::VirtualOutput(VirtualBackend *parent, bool internal, const QSize &physicalSizeInMM, OutputTransform panelOrientation)
: Output(parent)
, m_backend(parent)
, m_renderLoop(std::make_unique<RenderLoop>(this))
@ -32,6 +32,7 @@ VirtualOutput::VirtualOutput(VirtualBackend *parent, bool internal, const QSize
setInformation(Information{
.name = QStringLiteral("Virtual-%1").arg(identifier),
.physicalSize = physicalSizeInMM,
.panelOrientation = panelOrientation,
.internal = internal,
});
}

@ -25,7 +25,7 @@ class VirtualOutput : public Output
Q_OBJECT
public:
explicit VirtualOutput(VirtualBackend *parent, bool internal, const QSize &physicalSizeInMM);
explicit VirtualOutput(VirtualBackend *parent, bool internal, const QSize &physicalSizeInMM, OutputTransform panelOrientation);
~VirtualOutput() override;
RenderLoop *renderLoop() const override;

Loading…
Cancel
Save