mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
chore: add workspace write property example
This commit is contained in:
parent
81fc2a0ab6
commit
857dbbc8c7
@ -18,7 +18,12 @@ Workspace::Workspace(QQmlEngine *engine)
|
||||
|
||||
int Workspace::currentDesktop()
|
||||
{
|
||||
return m_kwinImpl->property("currentDesktop").toInt();
|
||||
return m_kwinImpl->property("currentDesktop").value<int>();
|
||||
}
|
||||
|
||||
void Workspace::setCurrentDesktop(int desktop)
|
||||
{
|
||||
m_kwinImpl->setProperty("currentDesktop", QVariant::fromValue(desktop));
|
||||
}
|
||||
|
||||
namespace Test
|
||||
@ -41,6 +46,26 @@ TEST_CASE("Workspace Properties Read")
|
||||
CHECK(result == 42);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Workspace Properties Write")
|
||||
{
|
||||
auto engine = QQmlEngine();
|
||||
auto mockWorkspace = MockWorkspaceJS();
|
||||
|
||||
engine.globalObject().setProperty(QStringLiteral("workspace"), engine.newQObject(&mockWorkspace));
|
||||
|
||||
auto plasmaApi = ::PlasmaApi::PlasmaApi(&engine);
|
||||
auto workspace = plasmaApi.workspace();
|
||||
|
||||
workspace.setCurrentDesktop(67);
|
||||
|
||||
SUBCASE("currentDesktop")
|
||||
{
|
||||
auto result = workspace.currentDesktop();
|
||||
CHECK(result == 67);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ struct Workspace {
|
||||
Workspace(QQmlEngine *engine);
|
||||
|
||||
int currentDesktop();
|
||||
void setCurrentDesktop(int desktop);
|
||||
|
||||
private:
|
||||
QQmlEngine *m_engine;
|
||||
|
Loading…
Reference in New Issue
Block a user