summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-04-29 17:20:58 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-04-29 20:52:27 +0100
commit4eed8e53313827f51cd97dcac7d2d437f53a2dbb (patch)
treecb28c9a4f4a56b5afd6248f513d84d394466388d
parent3801e50670afaf245e855e450817be8157deca08 (diff)
abhortive focus unit test - apparently we need visible windows for that.
Change-Id: I64999eb625a4b312997ba78698710bd1acaf8da7
-rw-r--r--vcl/qa/cppunit/lifecycle.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 4a0bebff8d0c..e23faa3cd3ef 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -16,6 +16,7 @@
#include <vcl/combobox.hxx>
#include <vcl/field.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/tabctrl.hxx>
class LifecycleTest : public test::BootstrapFixture
{
@@ -31,6 +32,7 @@ public:
void testParentedWidgets();
void testChildDispose();
void testPostDispose();
+ void testFocus();
CPPUNIT_TEST_SUITE(LifecycleTest);
CPPUNIT_TEST(testCast);
@@ -40,6 +42,7 @@ public:
CPPUNIT_TEST(testParentedWidgets);
CPPUNIT_TEST(testChildDispose);
CPPUNIT_TEST(testPostDispose);
+ CPPUNIT_TEST(testFocus);
CPPUNIT_TEST_SUITE_END();
};
@@ -143,6 +146,44 @@ void LifecycleTest::testPostDispose()
CPPUNIT_ASSERT(!xWin->GetWindow(0));
}
+class FocusCrashPostDispose : public TabControl
+{
+public:
+ FocusCrashPostDispose(vcl::Window *pParent) :
+ TabControl(pParent, 0)
+ {
+ }
+ virtual bool PreNotify( NotifyEvent& ) SAL_OVERRIDE
+ {
+ return false;
+ }
+ virtual bool Notify( NotifyEvent& ) SAL_OVERRIDE
+ {
+// CPPUNIT_ASSERT(false && "notify");
+ return false;
+ }
+ virtual void GetFocus() SAL_OVERRIDE
+ {
+ CPPUNIT_ASSERT(false && "get focus");
+ }
+ virtual void LoseFocus() SAL_OVERRIDE
+ {
+ CPPUNIT_ASSERT(false && "this should never be called");
+ }
+};
+
+void LifecycleTest::testFocus()
+{
+ ScopedVclPtrInstance<WorkWindow> xWin(nullptr, WB_APP|WB_STDWORK);
+ ScopedVclPtrInstance< FocusCrashPostDispose > xChild(xWin);
+ xWin->Show();
+ xChild->GrabFocus();
+ // process asynchronous ToTop
+ Scheduler::ProcessTaskScheduling(false);
+ // FIXME: really awful to test focus issues without showing windows.
+ // CPPUNIT_ASSERT(xChild->HasFocus());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(LifecycleTest);
CPPUNIT_PLUGIN_IMPLEMENT();