MCPcopy Create free account
hub / github.com/AGenUI/AGenUI / runDC001

Function runDC001

tests/cpp/integration/engine_destroy_chain_test.cpp:61–99  ·  view source on GitHub ↗

DC001 body: full lifecycle.

Source from the content-addressed store, hash-verified

59
60// DC001 body: full lifecycle.
61static void runDC001() {
62 auto* engine = ::agenui::getAGenUIEngine();
63 if (!engine) _exit(1);
64
65 ::agenui::testing::MockMessageListener listener;
66
67 auto* sm = engine->createSurfaceManager();
68 if (!sm) _exit(2);
69 // Must wait: init() runs on worker thread; without it the SM's
70 // internal modules (_dispatcher, _streamingContentParser) aren't
71 // created yet and streaming calls would hit null pointers.
72 ::agenui::testing::WaitForWorkerIdle();
73
74 sm->addSurfaceEventListener(&listener);
75
76 // Session 1: createSurface
77 sm->beginTextStream();
78 sm->receiveTextChunk(createSurfaceJson("dc001"));
79 sm->endTextStream();
80 // Wait between sessions so session 1 completes before session 2
81 // begins (beginTextStream resets parser state).
82 ::agenui::testing::WaitForWorkerIdle();
83
84 // Session 2: updateComponents
85 sm->beginTextStream();
86 sm->receiveTextChunk(updateComponentsJson("dc001"));
87 sm->endTextStream();
88 // No drain before destroy — engine->stop() drains the worker thread
89 // itself via ThreadManager::destroyThread(), which joins the thread
90 // and processes all pending tasks before any object is deleted.
91
92 sm->removeSurfaceEventListener(&listener);
93 engine->destroySurfaceManager(sm);
94
95 // Destroy engine directly — stop() will drain pending uninit() tasks.
96 ::agenui::destroyAGenUIEngine();
97
98 _exit(0);
99}
100
101// DC002 body: mid-stream destroy.
102static void runDC002() {

Callers 1

TEST_FFunction · 0.85

Calls 12

getAGenUIEngineFunction · 0.85
WaitForWorkerIdleFunction · 0.85
createSurfaceJsonFunction · 0.85
updateComponentsJsonFunction · 0.85
destroyAGenUIEngineFunction · 0.85
createSurfaceManagerMethod · 0.45
beginTextStreamMethod · 0.45
receiveTextChunkMethod · 0.45
endTextStreamMethod · 0.45
destroySurfaceManagerMethod · 0.45

Tested by

no test coverage detected