aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Skluzacek <ext-christian.skluzacek@nokia.com>2010-09-07 15:28:29 +0200
committerDaniel d'Andrada <daniel.dandrada@nokia.com>2010-09-09 10:09:05 +0300
commitcee5e0b33afe04198fa8917968712868b933ab6a (patch)
tree9a20eeaeac10192ba7cce85a4014291c5daa8b73 /tests
parent21ed16b5991829a7f9baead2099771266f9cc9c1 (diff)
Fixes: NB#181047, Opening and closing Application Menu reenables any previously disabled Toolbar buttons
RevBy: Daniel d'Andrada Details: ToolBar widgets were not necessarily being returned to their active state before and after the ApplicationMenu was opened/closed. This checks the state of the action associated with the button and sets the state accordingly. Also add unit test for associated property change.
Diffstat (limited to 'tests')
-rw-r--r--tests/ut_mtoolbar/ut_mtoolbar.cpp38
-rw-r--r--tests/ut_mtoolbar/ut_mtoolbar.h1
2 files changed, 38 insertions, 1 deletions
diff --git a/tests/ut_mtoolbar/ut_mtoolbar.cpp b/tests/ut_mtoolbar/ut_mtoolbar.cpp
index 43b9bb52..08ce3334 100644
--- a/tests/ut_mtoolbar/ut_mtoolbar.cpp
+++ b/tests/ut_mtoolbar/ut_mtoolbar.cpp
@@ -31,7 +31,6 @@
#include <MWidgetAction>
#include "mtoolbar_p.h"
-
MApplication *app(NULL);
// TODO: remove this when unneeded in MTextEdit's constructor
MApplicationWindow *appWin(NULL);
@@ -356,4 +355,41 @@ void Ut_MToolBar::testNoLocation()
actionTextEdit->setLocation(MAction::NoLocation);
}
+
+void Ut_MToolBar::testPropertyChange()
+{
+ // Add an action then set the Property which is triggered by the AppMenu when it is opened and closed
+ m_subject->clearActions();
+ QVERIFY(m_subject->actions().count() == 0);
+
+ // Add a normal action
+ MAction *action = new MAction("action", m_subject);
+ action->setLocation(MAction::ToolBarLocation);
+ action->setEnabled(true);
+ action->setVisible(true);
+ m_subject->addAction(action);
+
+ // Retrieve the widget associated with the action
+ const MToolBarView *view = dynamic_cast<const MToolBarView *>(m_subject->view());
+ QVERIFY(view);
+ MWidget *widget = view->getWidget(action);
+ QVERIFY(widget);
+ QVERIFY(widget->isEnabled());
+
+ // Test that enabled state is restored, this is called i.e. when appmenu is opened
+ // widget/action starting as enabled
+ m_subject->setProperty(_M_IsEnabledPreservingSelection, QVariant(false));
+ QVERIFY(!widget->isEnabled());
+ m_subject->setProperty(_M_IsEnabledPreservingSelection, QVariant(true));
+ QVERIFY(widget->isEnabled());
+
+ // widget/action starting as disabled
+ action->setEnabled(false);
+ QVERIFY(!widget->isEnabled());
+ m_subject->setProperty(_M_IsEnabledPreservingSelection, QVariant(false));
+ QVERIFY(!widget->isEnabled());
+ m_subject->setProperty(_M_IsEnabledPreservingSelection, QVariant(true));
+ QVERIFY(!widget->isEnabled());
+}
+
QTEST_APPLESS_MAIN(Ut_MToolBar)
diff --git a/tests/ut_mtoolbar/ut_mtoolbar.h b/tests/ut_mtoolbar/ut_mtoolbar.h
index 1a0607d5..cfce61fe 100644
--- a/tests/ut_mtoolbar/ut_mtoolbar.h
+++ b/tests/ut_mtoolbar/ut_mtoolbar.h
@@ -50,6 +50,7 @@ private Q_SLOTS:
void testAddTabAction();
void testRemoveTabAction();
void testNoLocation();
+ void testPropertyChange();
void actionSlot(bool);