DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get());
__zone = policyAreaPriv->getZone();
- if (__zone == nullptr) {
- DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea);
- return false;
- }
-
- __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1));
- __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1));
- __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1));
+ if (__zone) {
+ __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1));
+ __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1));
+ __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1));
- __windowList = __zone->getWindowList();
+ __windowList = __zone->getWindowList();
+ return true;
+ }
- return true;
+ DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea);
+ return false;
}
void DSTraceInfo::__onEventIdleEnterer(void *data)
void DSTraceInfo::printWindowsInfo()
{
+ stPosition pos{0,0};
+ stSize sz{0,0};
+ DSWaylandSurface *dwlSurface{nullptr};
+ DSWaylandClient *dwClient{nullptr};
+ pid_t pid = -1;
+
DSLOG_INF("DSTraceInfo", "--------------Top level windows: %d--------------", __windowList.size());
DSLOG_INF("DSTraceInfo", " No Win_ID PID w h x y (S)kipFoc has(F)ocus (U)serGeom (V)kbdFloating Parent Title");
for (std::shared_ptr<DSWindow> w : __windowList)
{
- stPosition pos = w->getPosition();
- stSize sz = w->getSize();
- DSWaylandSurface *dwlSurface = w->surface();
- DSWaylandClient *dwClient = dwlSurface->getClient();
- pid_t pid = dwClient->pid();
+ pos = w->getPosition();
+ sz = w->getSize();
+ dwlSurface = w->surface();
+ if (dwlSurface) {
+ dwClient = dwlSurface->getClient();
+ if (dwClient) pid = dwClient->pid();
+ }
+
DSLOG_INF("DSTraceInfo", " %d: %p %d %4d %4d %4d %4d %c %c %c %c %p %s", w->getZOrder(), w.get(), pid, \
sz.w, sz.h, pos.x, pos.y, w->getSkipFocus()?'S':' ', w->hasFocus()?'F':' ', w->isAllowUserGeometry()?'U':' ', w->getVkbdFloating()?'V':' ', \
w->getParent(), (w->getTitle().compare("") == 0)?"No Title":w->getTitle().c_str());
__windowUpdated = true;
}
+std::shared_ptr<DSZone> DSTraceInfo::getZone()
+{
+ return __zone;
+}
+
}
\ No newline at end of file
public:
void SetUp(void) override
{
+ Ecore_Timer *timer = nullptr;
+
+ DSWaylandCompositor::getInstance();
+ eventLoop = DSEventLoop::getInstance();
+ double delayInSecond = 0.5;
+ auto timerCb = [](void *data) -> Eina_Bool {
+ DSEventLoop *loop = (DSEventLoop *)data;
+ EXPECT_TRUE(loop->quit() == true);
+ return EINA_FALSE;
+ };
+
+ timer = ecore_timer_loop_add(delayInSecond, timerCb, eventLoop);
+ EXPECT_TRUE(timer != nullptr);
+
+ eventLoop->run();
+
char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR");
setenv("XDG_RUNTIME_DIR", xdir, 1);
}
void TearDown(void) override
{
+ eventLoop->quit();
+ DSEventLoop::releaseInstance();
+ DSWaylandCompositor::releaseInstance();
+
unsetenv("XDG_RUNTIME_DIR");
}
+ DSEventLoop *eventLoop;
+private:
+
};
TEST_F(DSTraceInfoTest, NewTraceInfo)
TEST_F(DSTraceInfoTest, printWindowsInfo)
{
+ std::shared_ptr<DSZone> zone(nullptr);
+
auto traceInfo = std::make_unique<DSTraceInfo>();
EXPECT_TRUE(traceInfo != nullptr);
auto policyArea = std::make_shared<DSPolicyArea>();
EXPECT_TRUE(policyArea != nullptr);
- traceInfo->printWindowsInfo();
+ if (traceInfo->attachPolicyArea(policyArea))
+ {
+ std::string title1{"TestWindow1"};
+ std::string title2{"TestWindow2"};
+ zone = traceInfo->getZone();
+
+ auto dswlSurface1 = std::make_shared<DSWaylandSurface>();
+ EXPECT_TRUE(zone->testCreateWindow(dswlSurface1));
+
+ auto dswlSurface2 = std::make_shared<DSWaylandSurface>();
+ EXPECT_TRUE(zone->testCreateWindow(dswlSurface2));
+
+ usleep(100000);
+ eventLoop->testEmitIdleEntererFuncs(nullptr);
+
+ zone->raiseWindow(dswlSurface1.get());
+ eventLoop->testEmitIdleEntererFuncs(nullptr);
+
+ EXPECT_TRUE(zone->testDestroyWindow(dswlSurface1));
+ eventLoop->testEmitIdleEntererFuncs(nullptr);
+
+ EXPECT_TRUE(zone->testDestroyWindow(dswlSurface2));
+ eventLoop->testEmitIdleEntererFuncs(nullptr);
+ }
}