Performs the setup function, then waits for it to call the exit function provided, then calls handleResult
| 107 | /// Performs the setup function, then waits for it to call the exit function provided, |
| 108 | /// then calls handleResult |
| 109 | static 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 | |
| 139 | inline void testPlatform (choc::test::TestProgress& progress) |
no test coverage detected