MCPcopy Create free account
hub / github.com/Tracktion/choc / runTestOnMessageThread

Function runTestOnMessageThread

tests/choc_tests.h:109–136  ·  view source on GitHub ↗

Performs the setup function, then waits for it to call the exit function provided, then calls handleResult

Source from the content-addressed store, hash-verified

107/// Performs the setup function, then waits for it to call the exit function provided,
108/// then calls handleResult
109static void runTestOnMessageThread (std::function<void(const std::function<void()>&)> setup,
110 std::function<void()> handleResult = {})
111{
112 std::atomic_bool finished { false };
113 std::function<void()> setFinished = [&] { finished = true; };
114
115 choc::messageloop::postMessage ([&]
116 {
117 setup (setFinished);
118 });
119
120 while (! finished)
121 std::this_thread::yield();
122
123 if (handleResult)
124 {
125 finished = false;
126
127 choc::messageloop::postMessage ([&]
128 {
129 handleResult();
130 finished = true;
131 });
132
133 while (! finished)
134 std::this_thread::yield();
135 }
136}
137
138
139inline void testPlatform (choc::test::TestProgress& progress)

Callers 3

testJavascriptPlatformFunction · 0.85
testWebviewFunction · 0.85
testTimersFunction · 0.85

Calls 1

postMessageFunction · 0.85

Tested by

no test coverage detected