diff options
author | cutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475> | 2020-01-03 19:05:16 +0000 |
---|---|---|
committer | cutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475> | 2020-01-03 19:05:16 +0000 |
commit | 2ae2a551a6290f46734307bbfdafea4b1a2cf2ba (patch) | |
tree | ba2f0b468640e44899fed3df2d4cc58795f4a003 /tests/cursorSetVisible.cpp | |
download | irrlicht-2ae2a551a6290f46734307bbfdafea4b1a2cf2ba.tar.xz |
Merging r5975 through r6036 from trunk to ogl-es branch.
GLES drivers adapted, but only did make compile-tests.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6038 dfc29bdd-3216-0410-991c-e03cc46cb475
Diffstat (limited to 'tests/cursorSetVisible.cpp')
-rw-r--r-- | tests/cursorSetVisible.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/cursorSetVisible.cpp b/tests/cursorSetVisible.cpp new file mode 100644 index 0000000..bf08cdf --- /dev/null +++ b/tests/cursorSetVisible.cpp @@ -0,0 +1,70 @@ +// Copyright (C) 2008-2012 Colin MacDonald
+// No rights reserved: this software is in the public domain.
+
+#include "testUtils.h"
+
+using namespace irr;
+using namespace core;
+
+struct TrapMouseMoves : IEventReceiver
+{
+ int MouseMovesReceived;
+
+ TrapMouseMoves() : MouseMovesReceived(0) { }
+
+ virtual bool OnEvent(const SEvent & event)
+ {
+ if(event.EventType == EET_MOUSE_INPUT_EVENT
+ && event.MouseInput.Event == EMIE_MOUSE_MOVED)
+ MouseMovesReceived++;
+
+ return false;
+ }
+};
+
+/** This test verifies that setting the cursor visibility
+ only generates a mouse message when it actually changes */
+bool cursorSetVisible(void)
+{
+ IrrlichtDevice * device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(1, 1));
+ TrapMouseMoves moveTrapper;
+ device->setEventReceiver(&moveTrapper);
+
+ device->run();
+
+ gui::ICursorControl * cursor = device->getCursorControl();
+
+ // Move the cursor inside the Irrlicht window so that we get messages for it.
+ cursor->setPosition(0, 0);
+ device->run(); // Receive any messages
+
+ cursor->setVisible(false); // Should generate a mouse move
+ device->run(); // Receive any messages
+
+ cursor->setVisible(false); // Should not generate a mouse move
+ device->run(); // Receive any messages
+
+ cursor->setVisible(true); // Should generate a mouse move
+ device->run(); // Receive any messages
+
+ cursor->setVisible(true); // Should not generate a mouse move
+ device->run(); // Receive any messages
+
+
+ // We should get at most 3 messages: one for the setPosition(), and one for
+ // each actual change of visibility.
+ bool result = (moveTrapper.MouseMovesReceived <= 3);
+
+ device->closeDevice();
+ device->run();
+ device->drop();
+
+ if(!result)
+ {
+ logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived);
+ assert_log(false);
+ }
+
+ return result;
+}
+
|