void KisActionManagerTest::testUpdateGUI()
{
    KisDoc2* doc = createEmptyDocument();
    KoMainWindow* shell = new KoMainWindow(doc->documentPart()->componentData());
    KisView2* view = new KisView2(static_cast<KisPart2*>(doc->documentPart()), static_cast<KisDoc2*>(doc), shell);
    doc->documentPart()->addView(view);

    KisAction* action = new KisAction("dummy", this);
    action->setActivationFlags(KisAction::ACTIVE_DEVICE);
    view->actionManager()->addAction("dummy", action, view->actionCollection());

    KisAction* action2 = new KisAction("dummy", this);
    action2->setActivationFlags(KisAction::ACTIVE_SHAPE_LAYER);
    view->actionManager()->addAction("dummy", action2, view->actionCollection());
    
    view->actionManager()->updateGUI();
    QVERIFY(!action->isEnabled());
    QVERIFY(!action2->isEnabled());

    KisPaintLayerSP paintLayer1 = new KisPaintLayer(doc->image(), "paintlayer1", OPACITY_OPAQUE_U8);
    doc->image()->addNode(paintLayer1);

    view->actionManager()->updateGUI();
    QVERIFY(action->isEnabled());
    QVERIFY(!action2->isEnabled());
}
void KisActionManagerTest::testCondition()
{
    KisDoc2* doc = createEmptyDocument();
    KoMainWindow* shell = new KoMainWindow(doc->documentPart()->componentData());
    KisView2* view = new KisView2(static_cast<KisPart2*>(doc->documentPart()), static_cast<KisDoc2*>(doc), shell);
    doc->documentPart()->addView(view);

    KisAction* action = new KisAction("dummy", this);
    action->setActivationFlags(KisAction::ACTIVE_DEVICE);
    action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
    view->actionManager()->addAction("dummy", action, view->actionCollection());

    KisPaintLayerSP paintLayer1 = new KisPaintLayer(doc->image(), "paintlayer1", OPACITY_OPAQUE_U8);
    doc->image()->addNode(paintLayer1);

    view->actionManager()->updateGUI();
    QVERIFY(action->isEnabled());

    // visible
    paintLayer1->setVisible(false);
    view->actionManager()->updateGUI();
    QVERIFY(!action->isEnabled());

    paintLayer1->setVisible(true);
    view->actionManager()->updateGUI();
    QVERIFY(action->isEnabled());

    // locked
    paintLayer1->setUserLocked(true);
    view->actionManager()->updateGUI();
    QVERIFY(!action->isEnabled());

    paintLayer1->setUserLocked(false);
    view->actionManager()->updateGUI();
    QVERIFY(action->isEnabled());
}