summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qmenu/qmenu.pro6
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp92
-rw-r--r--tests/auto/qmenu/tst_qmenu_mac_helpers.h55
-rw-r--r--tests/auto/qmenu/tst_qmenu_mac_helpers.mm57
4 files changed, 210 insertions, 0 deletions
diff --git a/tests/auto/qmenu/qmenu.pro b/tests/auto/qmenu/qmenu.pro
index acb07fb..74408f0 100644
--- a/tests/auto/qmenu/qmenu.pro
+++ b/tests/auto/qmenu/qmenu.pro
@@ -1,5 +1,11 @@
load(qttest_p4)
SOURCES += tst_qmenu.cpp
+macx {
+ LIBS += -framework AppKit
+ OBJECTIVE_SOURCES += tst_qmenu_mac_helpers.mm
+ HEADERS += tst_qmenu_mac_helpers.h
+}
+
contains(QT_CONFIG, qt3support): QT += qt3support
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 4bca6c1..d196c79 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -57,6 +57,10 @@
#include <qstyle.h>
#include <qdebug.h>
+#ifdef QT_MAC_USE_COCOA
+#include "tst_qmenu_mac_helpers.h"
+#endif
+
#include "../../shared/util.h"
//TESTED_CLASS=
@@ -108,6 +112,11 @@ private slots:
void QTBUG7907_submenus_autoselect();
void QTBUG7411_submenus_activate();
void QTBUG_10735_crashWithDialog();
+ void QTBUG_25544_macMenuState();
+ void QTBUG_25544_macMenuActionState();
+ void QTBUG_26399_macMenuActionVisible();
+ void QTBUG_7538_macAddItemToDisabledMenu();
+
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -1025,6 +1034,89 @@ void tst_QMenu::QTBUG_10735_crashWithDialog()
}
+void tst_QMenu::QTBUG_25544_macMenuState()
+{
+#ifndef QT_MAC_USE_COCOA
+ QSKIP("Applicable only on OS X Cocoa", SkipAll);
+#else
+ QMenuBar mb;
+ MyMenu2 menu;
+ menu.setTitle("Test menu");
+ menu.addAction("foo");
+ mb.addMenu(&menu);
+
+ menu.setEnabled(false);
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ QVERIFY(!menu.isNativeMenuEnabled());
+
+ menu.setEnabled(true);
+ QVERIFY(menu.isNativeMenuEnabled());
+#endif
+}
+
+void tst_QMenu::QTBUG_25544_macMenuActionState()
+{
+#ifndef QT_MAC_USE_COCOA
+ QSKIP("Applicable only on OS X Cocoa", SkipAll);
+#else
+ QMenuBar menubar;
+ MyMenu2 menu;
+ menu.setTitle("Test menu");
+ menu.addAction("foo");
+ menubar.addMenu(&menu);
+
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+
+ menu.menuAction()->setEnabled(false);
+ QVERIFY(!menu.isNativeMenuEnabled());
+
+ menu.menuAction()->setEnabled(true);
+ QVERIFY(menu.isNativeMenuEnabled());
+#endif
+}
+
+void tst_QMenu::QTBUG_26399_macMenuActionVisible()
+{
+#ifndef QT_MAC_USE_COCOA
+ QSKIP("Applicable only on OS X Cocoa", SkipAll);
+#else
+ QMenuBar menubar;
+ MyMenu2 menu;
+ menu.setTitle("Test menu");
+ menu.addAction("foo");
+ menubar.addMenu(&menu);
+
+ menu.show();
+ menu.menuAction()->setVisible(false);
+ QTest::qWaitForWindowShown(&menu);
+
+ QVERIFY(!menu.isNativeMenuEnabled());
+
+ menu.menuAction()->setVisible(true);
+ QVERIFY(menu.isNativeMenuEnabled());
+#endif
+}
+
+void tst_QMenu::QTBUG_7538_macAddItemToDisabledMenu()
+{
+#ifndef QT_MAC_USE_COCOA
+ QSKIP("Applicable only on OS X Cocoa", SkipAll);
+#else
+ QMenuBar menubar;
+ MyMenu2 menu;
+ menu.setTitle("Test menu");
+ menu.addAction("foo");
+ menubar.addMenu(&menu);
+
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ menu.setEnabled(false);
+ QAction *act = menu.addAction("bar");
+ QVERIFY(!menu.isNativeMenuItemEnabled(act));
+#endif
+}
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/qmenu/tst_qmenu_mac_helpers.h b/tests/auto/qmenu/tst_qmenu_mac_helpers.h
new file mode 100644
index 0000000..a5c8d21
--- /dev/null
+++ b/tests/auto/qmenu/tst_qmenu_mac_helpers.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TST_QMENU_MAC_HELPERS_H
+#define TST_QMENU_MAC_HELPERS_H
+
+#include <QMenu>
+
+class MyMenu2 : public QMenu
+{
+ Q_OBJECT
+public:
+ bool isNativeMenuEnabled();
+ bool isNativeMenuItemEnabled(QAction *act);
+};
+
+#endif // TST_QMENU_MAC_HELPERS_H
diff --git a/tests/auto/qmenu/tst_qmenu_mac_helpers.mm b/tests/auto/qmenu/tst_qmenu_mac_helpers.mm
new file mode 100644
index 0000000..22b45d7
--- /dev/null
+++ b/tests/auto/qmenu/tst_qmenu_mac_helpers.mm
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#import <AppKit/NSMenuItem.h>
+#include <private/qmenu_p.h>
+#include "tst_qmenu_mac_helpers.h"
+
+bool MyMenu2::isNativeMenuEnabled()
+{
+ QMenuPrivate *p = static_cast<QMenuPrivate*>(d_ptr.data());
+ return [[[p->mac_menu->menu supermenu] itemWithTag:(long)menuAction()] isEnabled];
+}
+
+bool MyMenu2::isNativeMenuItemEnabled(QAction *act)
+{
+ QMenuPrivate *p = static_cast<QMenuPrivate*>(d_ptr.data());
+ QMacMenuAction *macMenu = p->mac_menu->findAction(act);
+ return [macMenu->menuItem isEnabled];
+}