Commit 718af37b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Add test checking when we connect an external monitor while the device is rotated

It didn't help me fix any bug but it makes sense to me to have it
nevertheless.
parent cc832fd4
Pipeline #177150 passed with stage
in 2 minutes and 6 seconds
{
"screen" :
{
"id" : 1,
"maxSize" : {
"width" : 8192,
"height" : 8192
},
"minSize" : {
"width" : 320,
"height" : 200
},
"currentSize" : {
"width" : 3200,
"height" : 1880
},
"maxActiveOutputsCount": 2
},
"outputs" :
[
{
"id" : 1,
"name" : "LVDS1",
"type" : "LVDS",
"modes" :
[
{
"id" : 3,
"name" : "1280x800",
"refreshRate" : 59.9,
"size" : {
"width" : 1280,
"height" : 800
}
},
{
"id" : 2,
"name" : "1024x768",
"refreshRate" : 59.9,
"size" : {
"width" : 1024,
"height" : 768
}
},
{
"id" : 1,
"name" : "800x600",
"refreshRate" : 60,
"size" : {
"width" : 800,
"height" : 600
}
}
],
"pos" : {
"x" : 0,
"y" : 0
},
"currentModeId" : 3,
"preferredModes" : [3],
"rotation" : 8,
"connected" : true,
"enabled" : true,
"primary" : true,
"edid" : "AP///////wBMLcMFMzJGRQkUAQMOMx14Ku6Ro1RMmSYPUFQjCACBAIFAgYCVAKlAswABAQEBAjqAGHE4LUBYLEUA/h8RAAAeAAAA/QA4PB5REQAKICAgICAgAAAA/ABTeW5jTWFzdGVyCiAgAAAA/wBIOU1aMzAyMTk2CiAgAC4="
},
{
"id" : 2,
"name" : "HDMI1",
"type" : "HDMI",
"modes" :
[
{
"id" : 5,
"name" : "1920x1080",
"refreshRate" : 60,
"size" : {
"width" : 1920,
"height" : 1080
}
},
{
"id" : 4,
"name" : "1600x1200",
"refreshRate" : 60,
"size" : {
"width" : 1600,
"height" : 1200
}
},
{
"id" : 3,
"name" : "1024x768",
"refreshRate" : 70.9,
"size" : {
"width" : 1024,
"height" : 768
}
},
{
"id" : 2,
"name" : "1024x768",
"refreshRate" : 59.9,
"size" : {
"width" : 1024,
"height" : 768
}
},
{
"id" : 1,
"name" : "800x600",
"refreshRate" : 59.9,
"size" : {
"width" : 800,
"height" : 600
}
}
],
"pos" : {
"x" : 1280,
"y" : 0
},
"preferredModes" : [5],
"rotation" : 1,
"connected" : true,
"enabled" : false,
"primary" : false,
"edid" : "AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg=="
}
]
}
......@@ -42,6 +42,7 @@ private Q_SLOTS:
void workstationFallbackMode();
void workstationTwoExternalDiferentSize();
void switchDisplayTwoScreens();
void switchDisplayTwoScreensOneRotated();
void globalOutputData();
void outputPreset();
};
......@@ -436,6 +437,84 @@ void testScreenConfig::switchDisplayTwoScreens()
QCOMPARE(external->pos(), QPoint(1280, 0));
}
void testScreenConfig::switchDisplayTwoScreensOneRotated()
{
const ConfigPtr currentConfig = loadConfig("switchDisplayTwoScreensOneRotated.json");
QVERIFY(currentConfig);
Generator *generator = Generator::self();
generator->setCurrentConfig(currentConfig);
generator->setForceLaptop(true);
generator->setForceNotLaptop(false);
generator->setForceDocked(false);
generator->setForceLidClosed(false);
QCOMPARE(currentConfig->outputs().value(1)->rotation(), KScreen::Output::Right);
{
auto config = Generator::self()->idealConfig(currentConfig);
OutputPtr laptop = config->outputs().value(1);
OutputPtr external = config->outputs().value(2);
QCOMPARE(laptop->pos(), QPoint(0, 0));
QCOMPARE(external->pos(), QPoint(800, 0));
}
// Skipping cloning for now, I am not sure what's the best way forward here.
// We probably should not offer the option to clone if both displays have a different ratio?
// Extend to left
ConfigPtr config = generator->displaySwitch(Generator::ExtendToLeft);
OutputPtr laptop = config->outputs().value(1);
OutputPtr external = config->outputs().value(2);
QCOMPARE(laptop->currentModeId(), QLatin1String("3"));
QCOMPARE(laptop->isPrimary(), true);
QCOMPARE(laptop->isEnabled(), true);
QCOMPARE(laptop->pos(), QPoint(1920, 0));
QCOMPARE(laptop->rotation(), KScreen::Output::Right);
QCOMPARE(external->currentModeId(), QLatin1String("5"));
QCOMPARE(external->isPrimary(), false);
QCOMPARE(external->isEnabled(), true);
QCOMPARE(external->pos(), QPoint(0, 0));
// Disable embedded,. enable external
config = generator->displaySwitch(Generator::TurnOffEmbedded);
laptop = config->outputs().value(1);
external = config->outputs().value(2);
;
QCOMPARE(laptop->isEnabled(), false);
QCOMPARE(external->currentModeId(), QLatin1String("5"));
QCOMPARE(external->isPrimary(), true);
QCOMPARE(external->isEnabled(), true);
QCOMPARE(external->pos(), QPoint(0, 0));
// Enable embedded, disable external
config = generator->displaySwitch(Generator::TurnOffExternal);
laptop = config->outputs().value(1);
external = config->outputs().value(2);
;
QCOMPARE(laptop->currentModeId(), QLatin1String("3"));
QCOMPARE(laptop->isPrimary(), true);
QCOMPARE(laptop->isEnabled(), true);
QCOMPARE(laptop->pos(), QPoint(0, 0));
QCOMPARE(laptop->rotation(), KScreen::Output::Right);
;
QCOMPARE(external->isEnabled(), false);
// Extend to right
config = generator->displaySwitch(Generator::ExtendToRight);
laptop = config->outputs().value(1);
external = config->outputs().value(2);
QCOMPARE(laptop->currentModeId(), QLatin1String("3"));
QCOMPARE(laptop->isPrimary(), true);
QCOMPARE(laptop->isEnabled(), true);
QCOMPARE(laptop->pos(), QPoint(0, 0));
QCOMPARE(laptop->rotation(), KScreen::Output::Right);
QCOMPARE(external->currentModeId(), QLatin1String("5"));
QCOMPARE(external->isPrimary(), false);
QCOMPARE(external->isEnabled(), true);
QCOMPARE(external->pos(), QPoint(800, 0));
}
void testScreenConfig::switchDisplayTwoScreensNoCommonMode()
{
const ConfigPtr currentConfig = loadConfig("switchDisplayTwoScreensNoCommonMode.json");
......@@ -443,7 +522,6 @@ void testScreenConfig::switchDisplayTwoScreensNoCommonMode()
Generator *generator = Generator::self();
generator->setCurrentConfig(currentConfig);
qDebug() << "MEH MOH";
ConfigPtr config = generator->displaySwitch(Generator::Clone);
OutputPtr laptop = config->outputs().value(1);
OutputPtr external = config->outputs().value(2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment