10#include "virtualdesktops.h" 
   12#include <KConfigGroup> 
   53    void navigationWrapsAround_data();
 
   54    void navigationWrapsAround();
 
   57    void currentChangeOnCountChange_data();
 
   58    void currentChangeOnCountChange();
 
   71    void updateGrid_data();
 
   73    void updateLayout_data();
 
   77    void switchToShortcuts();
 
   83    void addDirectionColumns();
 
 
   87void TestVirtualDesktops::init()
 
   89    VirtualDesktopManager::create();
 
   92void TestVirtualDesktops::cleanup()
 
   94    delete VirtualDesktopManager::self();
 
   97static const uint s_countInitValue = 2;
 
   99void TestVirtualDesktops::count_data()
 
  101    QTest::addColumn<uint>(
"request");
 
  102    QTest::addColumn<uint>(
"result");
 
  103    QTest::addColumn<bool>(
"signal");
 
  104    QTest::addColumn<bool>(
"removedSignal");
 
  106    QTest::newRow(
"Minimum") << (uint)1 << (uint)1 << 
true << 
true;
 
  107    QTest::newRow(
"Below Minimum") << (uint)0 << (uint)1 << 
true << 
true;
 
  108    QTest::newRow(
"Normal Value") << (uint)10 << (uint)10 << 
true << 
false;
 
  111    QTest::newRow(
"Unchanged") << s_countInitValue << s_countInitValue << 
false << 
false;
 
  114void TestVirtualDesktops::count()
 
  117    QCOMPARE(vds->
count(), (uint)0);
 
  124    auto vdToRemove = vds->
desktops().last();
 
  126    QFETCH(uint, request);
 
  127    QFETCH(uint, result);
 
  128    QFETCH(
bool, signal);
 
  129    QFETCH(
bool, removedSignal);
 
  131    QCOMPARE(vds->
count(), result);
 
  132    QCOMPARE(spy.isEmpty(), !signal);
 
  133    if (!spy.isEmpty()) {
 
  134        QList<QVariant> arguments = spy.takeFirst();
 
  135        QCOMPARE(arguments.count(), 2);
 
  136        QCOMPARE(arguments.at(0).type(), QVariant::UInt);
 
  137        QCOMPARE(arguments.at(1).type(), QVariant::UInt);
 
  138        QCOMPARE(arguments.at(0).toUInt(), s_countInitValue);
 
  139        QCOMPARE(arguments.at(1).toUInt(), result);
 
  141    QCOMPARE(desktopsRemoved.isEmpty(), !removedSignal);
 
  142    if (!desktopsRemoved.isEmpty()) {
 
  143        QList<QVariant> arguments = desktopsRemoved.takeFirst();
 
  144        QCOMPARE(arguments.count(), 1);
 
  149void TestVirtualDesktops::navigationWrapsAround_data()
 
  151    QTest::addColumn<bool>(
"init");
 
  152    QTest::addColumn<bool>(
"request");
 
  153    QTest::addColumn<bool>(
"result");
 
  154    QTest::addColumn<bool>(
"signal");
 
  156    QTest::newRow(
"enable") << 
false << 
true << 
true << 
true;
 
  157    QTest::newRow(
"disable") << 
true << 
false << 
false << 
true;
 
  158    QTest::newRow(
"keep enabled") << 
true << 
true << 
true << 
false;
 
  159    QTest::newRow(
"keep disabled") << 
false << 
false << 
false << 
false;
 
  162void TestVirtualDesktops::navigationWrapsAround()
 
  167    QFETCH(
bool, request);
 
  168    QFETCH(
bool, result);
 
  169    QFETCH(
bool, signal);
 
  178    QCOMPARE(spy.isEmpty(), !signal);
 
  181void TestVirtualDesktops::current_data()
 
  183    QTest::addColumn<uint>(
"count");
 
  184    QTest::addColumn<uint>(
"init");
 
  185    QTest::addColumn<uint>(
"request");
 
  186    QTest::addColumn<uint>(
"result");
 
  187    QTest::addColumn<bool>(
"signal");
 
  189    QTest::newRow(
"lower") << (uint)4 << (uint)3 << (uint)2 << (uint)2 << 
true;
 
  190    QTest::newRow(
"higher") << (uint)4 << (uint)1 << (uint)2 << (uint)2 << 
true;
 
  191    QTest::newRow(
"maximum") << (uint)4 << (uint)1 << (uint)4 << (uint)4 << 
true;
 
  192    QTest::newRow(
"above maximum") << (uint)4 << (uint)1 << (uint)5 << (uint)1 << 
false;
 
  193    QTest::newRow(
"minimum") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << 
true;
 
  194    QTest::newRow(
"below minimum") << (uint)4 << (uint)2 << (uint)0 << (uint)2 << 
false;
 
  195    QTest::newRow(
"unchanged") << (uint)4 << (uint)2 << (uint)2 << (uint)2 << 
false;
 
  198void TestVirtualDesktops::current()
 
  201    QCOMPARE(vds->
current(), (uint)0);
 
  206    QCOMPARE(vds->
current(), init);
 
  210    QFETCH(uint, request);
 
  211    QFETCH(uint, result);
 
  212    QFETCH(
bool, signal);
 
  214    QCOMPARE(vds->
current(), result);
 
  215    QCOMPARE(spy.isEmpty(), !signal);
 
  216    if (!spy.isEmpty()) {
 
  217        QList<QVariant> arguments = spy.takeFirst();
 
  218        QCOMPARE(arguments.count(), 2);
 
  228void TestVirtualDesktops::currentChangeOnCountChange_data()
 
  230    QTest::addColumn<uint>(
"initCount");
 
  231    QTest::addColumn<uint>(
"initCurrent");
 
  232    QTest::addColumn<uint>(
"request");
 
  233    QTest::addColumn<uint>(
"current");
 
  234    QTest::addColumn<bool>(
"signal");
 
  236    QTest::newRow(
"increment") << (uint)4 << (uint)2 << (uint)5 << (uint)2 << 
false;
 
  237    QTest::newRow(
"increment on last") << (uint)4 << (uint)4 << (uint)5 << (uint)4 << 
false;
 
  238    QTest::newRow(
"decrement") << (uint)4 << (uint)2 << (uint)3 << (uint)2 << 
false;
 
  239    QTest::newRow(
"decrement on second last") << (uint)4 << (uint)3 << (uint)3 << (uint)3 << 
false;
 
  240    QTest::newRow(
"decrement on last") << (uint)4 << (uint)4 << (uint)3 << (uint)3 << 
true;
 
  241    QTest::newRow(
"multiple decrement") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << 
true;
 
  244void TestVirtualDesktops::currentChangeOnCountChange()
 
  247    QFETCH(uint, initCount);
 
  248    QFETCH(uint, initCurrent);
 
  254    QFETCH(uint, request);
 
  255    QFETCH(uint, current);
 
  256    QFETCH(
bool, signal);
 
  259    QCOMPARE(vds->
current(), current);
 
  260    QCOMPARE(spy.isEmpty(), !signal);
 
  263void TestVirtualDesktops::addDirectionColumns()
 
  265    QTest::addColumn<uint>(
"initCount");
 
  266    QTest::addColumn<uint>(
"initCurrent");
 
  267    QTest::addColumn<bool>(
"wrap");
 
  268    QTest::addColumn<uint>(
"result");
 
  274    QFETCH(uint, initCount);
 
  275    QFETCH(uint, initCurrent);
 
  280    QFETCH(uint, result);
 
  285    QAction *action = vds->findChild<QAction *>(actionName);
 
  288    QCOMPARE(vds->
current(), result);
 
  289    QCOMPARE(vds->
inDirection(initCurrent, direction, wrap), result);
 
  292void TestVirtualDesktops::next_data()
 
  294    addDirectionColumns();
 
  296    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  297    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  298    QTest::newRow(
"desktops, wrap") << (uint)4 << (uint)1 << 
true << (uint)2;
 
  299    QTest::newRow(
"desktops, no wrap") << (uint)4 << (uint)1 << 
false << (uint)2;
 
  300    QTest::newRow(
"desktops at end, wrap") << (uint)4 << (uint)4 << 
true << (uint)1;
 
  301    QTest::newRow(
"desktops at end, no wrap") << (uint)4 << (uint)4 << 
false << (uint)4;
 
  304void TestVirtualDesktops::next()
 
  306    testDirection(QStringLiteral(
"Switch to Next Desktop"), VirtualDesktopManager::Direction::Next);
 
  309void TestVirtualDesktops::previous_data()
 
  311    addDirectionColumns();
 
  313    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  314    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  315    QTest::newRow(
"desktops, wrap") << (uint)4 << (uint)3 << 
true << (uint)2;
 
  316    QTest::newRow(
"desktops, no wrap") << (uint)4 << (uint)3 << 
false << (uint)2;
 
  317    QTest::newRow(
"desktops at start, wrap") << (uint)4 << (uint)1 << 
true << (uint)4;
 
  318    QTest::newRow(
"desktops at start, no wrap") << (uint)4 << (uint)1 << 
false << (uint)1;
 
  321void TestVirtualDesktops::previous()
 
  323    testDirection(QStringLiteral(
"Switch to Previous Desktop"), VirtualDesktopManager::Direction::Previous);
 
  326void TestVirtualDesktops::left_data()
 
  328    addDirectionColumns();
 
  329    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  330    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  331    QTest::newRow(
"desktops, wrap, 1st row") << (uint)4 << (uint)2 << 
true << (uint)1;
 
  332    QTest::newRow(
"desktops, no wrap, 1st row") << (uint)4 << (uint)2 << 
false << (uint)1;
 
  333    QTest::newRow(
"desktops, wrap, 2nd row") << (uint)4 << (uint)4 << 
true << (uint)3;
 
  334    QTest::newRow(
"desktops, no wrap, 2nd row") << (uint)4 << (uint)4 << 
false << (uint)3;
 
  336    QTest::newRow(
"desktops at start, wrap, 1st row") << (uint)4 << (uint)1 << 
true << (uint)2;
 
  337    QTest::newRow(
"desktops at start, no wrap, 1st row") << (uint)4 << (uint)1 << 
false << (uint)1;
 
  338    QTest::newRow(
"desktops at start, wrap, 2nd row") << (uint)4 << (uint)3 << 
true << (uint)4;
 
  339    QTest::newRow(
"desktops at start, no wrap, 2nd row") << (uint)4 << (uint)3 << 
false << (uint)3;
 
  341    QTest::newRow(
"non symmetric, start") << (uint)5 << (uint)5 << 
false << (uint)4;
 
  342    QTest::newRow(
"non symmetric, end, no wrap") << (uint)5 << (uint)4 << 
false << (uint)4;
 
  343    QTest::newRow(
"non symmetric, end, wrap") << (uint)5 << (uint)4 << 
true << (uint)5;
 
  346void TestVirtualDesktops::left()
 
  348    testDirection(QStringLiteral(
"Switch One Desktop to the Left"), VirtualDesktopManager::Direction::Left);
 
  351void TestVirtualDesktops::right_data()
 
  353    addDirectionColumns();
 
  354    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  355    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  356    QTest::newRow(
"desktops, wrap, 1st row") << (uint)4 << (uint)1 << 
true << (uint)2;
 
  357    QTest::newRow(
"desktops, no wrap, 1st row") << (uint)4 << (uint)1 << 
false << (uint)2;
 
  358    QTest::newRow(
"desktops, wrap, 2nd row") << (uint)4 << (uint)3 << 
true << (uint)4;
 
  359    QTest::newRow(
"desktops, no wrap, 2nd row") << (uint)4 << (uint)3 << 
false << (uint)4;
 
  361    QTest::newRow(
"desktops at start, wrap, 1st row") << (uint)4 << (uint)2 << 
true << (uint)1;
 
  362    QTest::newRow(
"desktops at start, no wrap, 1st row") << (uint)4 << (uint)2 << 
false << (uint)2;
 
  363    QTest::newRow(
"desktops at start, wrap, 2nd row") << (uint)4 << (uint)4 << 
true << (uint)3;
 
  364    QTest::newRow(
"desktops at start, no wrap, 2nd row") << (uint)4 << (uint)4 << 
false << (uint)4;
 
  366    QTest::newRow(
"non symmetric, start") << (uint)5 << (uint)4 << 
false << (uint)5;
 
  367    QTest::newRow(
"non symmetric, end, no wrap") << (uint)5 << (uint)5 << 
false << (uint)5;
 
  368    QTest::newRow(
"non symmetric, end, wrap") << (uint)5 << (uint)5 << 
true << (uint)4;
 
  371void TestVirtualDesktops::right()
 
  373    testDirection(QStringLiteral(
"Switch One Desktop to the Right"), VirtualDesktopManager::Direction::Right);
 
  376void TestVirtualDesktops::above_data()
 
  378    addDirectionColumns();
 
  379    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  380    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  381    QTest::newRow(
"desktops, wrap, 1st column") << (uint)4 << (uint)3 << 
true << (uint)1;
 
  382    QTest::newRow(
"desktops, no wrap, 1st column") << (uint)4 << (uint)3 << 
false << (uint)1;
 
  383    QTest::newRow(
"desktops, wrap, 2nd column") << (uint)4 << (uint)4 << 
true << (uint)2;
 
  384    QTest::newRow(
"desktops, no wrap, 2nd column") << (uint)4 << (uint)4 << 
false << (uint)2;
 
  386    QTest::newRow(
"desktops at start, wrap, 1st column") << (uint)4 << (uint)1 << 
true << (uint)3;
 
  387    QTest::newRow(
"desktops at start, no wrap, 1st column") << (uint)4 << (uint)1 << 
false << (uint)1;
 
  388    QTest::newRow(
"desktops at start, wrap, 2nd column") << (uint)4 << (uint)2 << 
true << (uint)4;
 
  389    QTest::newRow(
"desktops at start, no wrap, 2nd column") << (uint)4 << (uint)2 << 
false << (uint)2;
 
  392void TestVirtualDesktops::above()
 
  394    testDirection(QStringLiteral(
"Switch One Desktop Up"), VirtualDesktopManager::Direction::Up);
 
  397void TestVirtualDesktops::below_data()
 
  399    addDirectionColumns();
 
  400    QTest::newRow(
"one desktop, wrap") << (uint)1 << (uint)1 << 
true << (uint)1;
 
  401    QTest::newRow(
"one desktop, no wrap") << (uint)1 << (uint)1 << 
false << (uint)1;
 
  402    QTest::newRow(
"desktops, wrap, 1st column") << (uint)4 << (uint)1 << 
true << (uint)3;
 
  403    QTest::newRow(
"desktops, no wrap, 1st column") << (uint)4 << (uint)1 << 
false << (uint)3;
 
  404    QTest::newRow(
"desktops, wrap, 2nd column") << (uint)4 << (uint)2 << 
true << (uint)4;
 
  405    QTest::newRow(
"desktops, no wrap, 2nd column") << (uint)4 << (uint)2 << 
false << (uint)4;
 
  407    QTest::newRow(
"desktops at start, wrap, 1st column") << (uint)4 << (uint)3 << 
true << (uint)1;
 
  408    QTest::newRow(
"desktops at start, no wrap, 1st column") << (uint)4 << (uint)3 << 
false << (uint)3;
 
  409    QTest::newRow(
"desktops at start, wrap, 2nd column") << (uint)4 << (uint)4 << 
true << (uint)2;
 
  410    QTest::newRow(
"desktops at start, no wrap, 2nd column") << (uint)4 << (uint)4 << 
false << (uint)4;
 
  413void TestVirtualDesktops::below()
 
  415    testDirection(QStringLiteral(
"Switch One Desktop Down"), VirtualDesktopManager::Direction::Down);
 
  418void TestVirtualDesktops::updateGrid_data()
 
  420    QTest::addColumn<uint>(
"initCount");
 
  421    QTest::addColumn<QSize>(
"size");
 
  422    QTest::addColumn<QPoint>(
"coords");
 
  423    QTest::addColumn<uint>(
"desktop");
 
  425    QTest::newRow(
"one desktop, h") << (uint)1 << QSize(1, 1) << QPoint(0, 0) << (uint)1;
 
  426    QTest::newRow(
"one desktop, h, 0") << (uint)1 << QSize(1, 1) << QPoint(1, 0) << (uint)0;
 
  428    QTest::newRow(
"two desktops, h, 1") << (uint)2 << QSize(2, 1) << QPoint(0, 0) << (uint)1;
 
  429    QTest::newRow(
"two desktops, h, 2") << (uint)2 << QSize(2, 1) << QPoint(1, 0) << (uint)2;
 
  430    QTest::newRow(
"two desktops, h, 3") << (uint)2 << QSize(2, 1) << QPoint(0, 1) << (uint)0;
 
  431    QTest::newRow(
"two desktops, h, 4") << (uint)2 << QSize(2, 1) << QPoint(2, 0) << (uint)0;
 
  433    QTest::newRow(
"four desktops, h, one row, 1") << (uint)4 << QSize(4, 1) << QPoint(0, 0) << (uint)1;
 
  434    QTest::newRow(
"four desktops, h, one row, 2") << (uint)4 << QSize(4, 1) << QPoint(1, 0) << (uint)2;
 
  435    QTest::newRow(
"four desktops, h, one row, 3") << (uint)4 << QSize(4, 1) << QPoint(2, 0) << (uint)3;
 
  436    QTest::newRow(
"four desktops, h, one row, 4") << (uint)4 << QSize(4, 1) << QPoint(3, 0) << (uint)4;
 
  438    QTest::newRow(
"four desktops, h, grid, 1") << (uint)4 << QSize(2, 2) << QPoint(0, 0) << (uint)1;
 
  439    QTest::newRow(
"four desktops, h, grid, 2") << (uint)4 << QSize(2, 2) << QPoint(1, 0) << (uint)2;
 
  440    QTest::newRow(
"four desktops, h, grid, 3") << (uint)4 << QSize(2, 2) << QPoint(0, 1) << (uint)3;
 
  441    QTest::newRow(
"four desktops, h, grid, 4") << (uint)4 << QSize(2, 2) << QPoint(1, 1) << (uint)4;
 
  442    QTest::newRow(
"four desktops, h, grid, 0/3") << (uint)4 << QSize(2, 2) << QPoint(0, 3) << (uint)0;
 
  444    QTest::newRow(
"three desktops, h, grid, 1") << (uint)3 << QSize(2, 2) << QPoint(0, 0) << (uint)1;
 
  445    QTest::newRow(
"three desktops, h, grid, 2") << (uint)3 << QSize(2, 2) << QPoint(1, 0) << (uint)2;
 
  446    QTest::newRow(
"three desktops, h, grid, 3") << (uint)3 << QSize(2, 2) << QPoint(0, 1) << (uint)3;
 
  447    QTest::newRow(
"three desktops, h, grid, 4") << (uint)3 << QSize(2, 2) << QPoint(1, 1) << (uint)0;
 
  450void TestVirtualDesktops::updateGrid()
 
  453    QFETCH(uint, initCount);
 
  458    QCOMPARE(vds->
desktops().count(), 
int(initCount));
 
  460    QCOMPARE(grid.
size(), size);
 
  461    QCOMPARE(grid.
width(), size.width());
 
  462    QCOMPARE(grid.
height(), size.height());
 
  463    QFETCH(QPoint, coords);
 
  464    QFETCH(uint, desktop);
 
  471void TestVirtualDesktops::updateLayout_data()
 
  473    QTest::addColumn<uint>(
"desktop");
 
  474    QTest::addColumn<QSize>(
"result");
 
  476    QTest::newRow(
"01") << (uint)1 << QSize(1, 1);
 
  477    QTest::newRow(
"02") << (uint)2 << QSize(1, 2);
 
  478    QTest::newRow(
"03") << (uint)3 << QSize(2, 2);
 
  479    QTest::newRow(
"04") << (uint)4 << QSize(2, 2);
 
  480    QTest::newRow(
"05") << (uint)5 << QSize(3, 2);
 
  481    QTest::newRow(
"06") << (uint)6 << QSize(3, 2);
 
  482    QTest::newRow(
"07") << (uint)7 << QSize(4, 2);
 
  483    QTest::newRow(
"08") << (uint)8 << QSize(4, 2);
 
  484    QTest::newRow(
"09") << (uint)9 << QSize(5, 2);
 
  485    QTest::newRow(
"10") << (uint)10 << QSize(5, 2);
 
  486    QTest::newRow(
"11") << (uint)11 << QSize(6, 2);
 
  487    QTest::newRow(
"12") << (uint)12 << QSize(6, 2);
 
  488    QTest::newRow(
"13") << (uint)13 << QSize(7, 2);
 
  489    QTest::newRow(
"14") << (uint)14 << QSize(7, 2);
 
  490    QTest::newRow(
"15") << (uint)15 << QSize(8, 2);
 
  491    QTest::newRow(
"16") << (uint)16 << QSize(8, 2);
 
  492    QTest::newRow(
"17") << (uint)17 << QSize(9, 2);
 
  493    QTest::newRow(
"18") << (uint)18 << QSize(9, 2);
 
  494    QTest::newRow(
"19") << (uint)19 << QSize(10, 2);
 
  495    QTest::newRow(
"20") << (uint)20 << QSize(10, 2);
 
  498void TestVirtualDesktops::updateLayout()
 
  503    QFETCH(uint, desktop);
 
  504    QFETCH(QSize, result);
 
  506    QCOMPARE(vds->
grid().
size(), result);
 
  507    QCOMPARE(spy.count(), 1);
 
  508    const QVariantList &arguments = spy.at(0);
 
  509    QCOMPARE(arguments.at(0).toInt(), result.width());
 
  510    QCOMPARE(arguments.at(1).toInt(), result.height());
 
  513    QCOMPARE(vds->
grid().
size(), result);
 
  514    QCOMPARE(spy.count(), 2);
 
  515    const QVariantList &arguments2 = spy.at(1);
 
  516    QCOMPARE(arguments2.at(0).toInt(), result.width());
 
  517    QCOMPARE(arguments2.at(1).toInt(), result.height());
 
  520void TestVirtualDesktops::name_data()
 
  522    QTest::addColumn<uint>(
"initCount");
 
  523    QTest::addColumn<uint>(
"desktop");
 
  524    QTest::addColumn<QString>(
"desktopName");
 
  526    QTest::newRow(
"desktop 1") << (uint)5 << (uint)1 << 
"Desktop 1";
 
  527    QTest::newRow(
"desktop 2") << (uint)5 << (uint)2 << 
"Desktop 2";
 
  528    QTest::newRow(
"desktop 3") << (uint)5 << (uint)3 << 
"Desktop 3";
 
  529    QTest::newRow(
"desktop 4") << (uint)5 << (uint)4 << 
"Desktop 4";
 
  530    QTest::newRow(
"desktop 5") << (uint)5 << (uint)5 << 
"Desktop 5";
 
  533void TestVirtualDesktops::name()
 
  536    QFETCH(uint, initCount);
 
  538    QFETCH(uint, desktop);
 
  541    QTEST(vd->
name(), 
"desktopName");
 
  544void TestVirtualDesktops::switchToShortcuts()
 
  551    const QString toDesktop = QStringLiteral(
"Switch to Desktop %1");
 
  552    for (uint i = 1; i <= vds->
maximum(); ++i) {
 
  553        const QString desktop(toDesktop.arg(i));
 
  554        QAction *action = vds->findChild<QAction *>(desktop);
 
  555        QVERIFY2(action, desktop.toUtf8().constData());
 
  560    QMetaObject::invokeMethod(vds, 
"slotSwitchTo");
 
  565void TestVirtualDesktops::changeRows()
 
  571    QCOMPARE(vds->
rows(), 4);
 
  574    QCOMPARE(vds->
rows(), 4);
 
  577    QCOMPARE(vds->
rows(), 2);
 
  580void TestVirtualDesktops::load()
 
  585    QCOMPARE(vds->
count(), (uint)0);
 
  587    KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
 
  590    QCOMPARE(vds->
count(), (uint)1);
 
  592    config->group(QStringLiteral(
"Desktops")).writeEntry(
"Number", 4);
 
  594    QCOMPARE(vds->
count(), (uint)4);
 
  597    config->group(QStringLiteral(
"Desktops")).writeEntry(
"Number", 5);
 
  599    QCOMPARE(vds->
count(), (uint)5);
 
  602void TestVirtualDesktops::save()
 
  608    KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
 
  612    QCOMPARE(config->hasGroup(QStringLiteral(
"Desktops")), 
false);
 
  614    QCOMPARE(config->hasGroup(QStringLiteral(
"Desktops")), 
true);
 
  615    KConfigGroup desktops = config->group(QStringLiteral(
"Desktops"));
 
  616    QCOMPARE(desktops.readEntry<
int>(
"Number", 1), 4);
 
  617    QCOMPARE(desktops.hasKey(
"Name_1"), 
false);
 
  618    QCOMPARE(desktops.hasKey(
"Name_2"), 
false);
 
  619    QCOMPARE(desktops.hasKey(
"Name_3"), 
false);
 
  620    QCOMPARE(desktops.hasKey(
"Name_4"), 
false);
 
  624#include "test_virtual_desktops.moc" 
Two dimensional grid containing the ID of the virtual desktop at a specific position in the grid.
void update(const QSize &size, const QList< VirtualDesktop * > &desktops)
QPoint gridCoords(uint id) const
VirtualDesktop * at(const QPoint &coords) const
const QSize & size() const
Manages the number of available virtual desktops, the layout of those and which virtual desktop is th...
const VirtualDesktopGrid & grid() const
void layoutChanged(int columns, int rows)
void setConfig(KSharedConfig::Ptr config)
void countChanged(uint previousCount, uint newCount)
QList< VirtualDesktop * > desktops() const
VirtualDesktop * inDirection(VirtualDesktop *desktop, Direction direction, bool wrap=true)
void navigationWrappingAroundChanged()
void currentChanged(KWin::VirtualDesktop *previousDesktop, KWin::VirtualDesktop *newDesktop)
void setCount(uint count)
VirtualDesktop * desktopForX11Id(uint id) const
void setNavigationWrappingAround(bool enabled)
bool setCurrent(uint current)
void desktopRemoved(KWin::VirtualDesktop *desktop)
bool isNavigationWrappingAround() const
PointerAxisDirection
The direction in which a pointer axis is moved.
SwipeDirection
Directions for swipe gestures.
QTEST_MAIN(OnScreenNotificationTest)