1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <memory>
#include <gmock/gmock.h>
#include <glib.h>
#include "Nux/Nux.h"
#include "NuxGraphics/GraphicsDisplay.h"
using namespace testing;
using namespace nux;
namespace {
struct TestGraphicsDisplay : Test
{
TestGraphicsDisplay()
: graphic_display_(nullptr)
{}
virtual void SetUp()
{
nux::NuxInitialize(0);
wnd_thread.reset(nux::CreateNuxWindow("nux::TestGraphicsDisplay", 300, 200, nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL));
graphic_display_ = nux::GetGraphicsDisplay();
ASSERT_NE(graphic_display_, nullptr);
}
std::unique_ptr<nux::WindowThread> wnd_thread;
GraphicsDisplay* graphic_display_;
};
#if defined(USE_X11)
TEST_F(TestGraphicsDisplay, X11TimestampOnButtonPress)
{
XEvent xevent;
xevent.type = ButtonPress;
xevent.xany.display = graphic_display_->GetX11Display();
xevent.xbutton.time = g_random_int();
graphic_display_->ProcessXEvent(xevent, true);
auto event_time = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
EXPECT_EQ(xevent.xbutton.time, event_time);
}
#endif
}
|