mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
23 lines
644 B
C++
23 lines
644 B
C++
#include "gtest/gtest.h"
|
|
#include "tkc/socket_pair.h"
|
|
#include "tkc/event_source_fd.h"
|
|
|
|
static uint32_t s_fd_times = 0;
|
|
static ret_t event_source_on_data(event_source_t* source) {
|
|
s_fd_times++;
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
TEST(EventSourceFd, basic) {
|
|
event_source_t* event_source = event_source_fd_create(1, event_source_on_data, NULL);
|
|
|
|
ASSERT_EQ(event_source_get_fd(event_source), 1);
|
|
ASSERT_EQ(event_source_check(event_source), RET_OK);
|
|
ASSERT_EQ(event_source_get_wakeup_time(event_source), 0xffffu);
|
|
ASSERT_EQ(event_source_dispatch(event_source), RET_OK);
|
|
ASSERT_EQ(s_fd_times, 1u);
|
|
|
|
tk_object_unref(TK_OBJECT(event_source));
|
|
}
|