* @brief Test fixture class for advanced TaskScheduler features * * Provides setup and teardown for advanced feature tests, ensuring * clean state between tests and utility methods for complex scenarios. */
| 294 | * clean state between tests and utility methods for complex scenarios. |
| 295 | */ |
| 296 | class AdvancedSchedulerTest : public ::testing::Test { |
| 297 | protected: |
| 298 | /** |
| 299 | * @brief Set up test environment for advanced features |
| 300 | * |
| 301 | * Clears all test state and initializes timing system. |
| 302 | * Prepares environment for testing complex feature interactions. |
| 303 | */ |
| 304 | void SetUp() override { |
| 305 | clearAdvancedTestOutput(); |
| 306 | advanced_callback_counter = 0; |
| 307 | status_received = false; |
| 308 | last_status_code = 0; |
| 309 | timeout_occurred = false; |
| 310 | task_self_destructed = false; |
| 311 | global_status_request = nullptr; |
| 312 | millis(); // Initialize timing |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * @brief Clean up test environment after advanced feature tests |
| 317 | * |
| 318 | * Ensures no test artifacts affect subsequent tests. |
| 319 | * Critical for maintaining test isolation in complex scenarios. |
| 320 | */ |
| 321 | void TearDown() override { |
| 322 | clearAdvancedTestOutput(); |
| 323 | advanced_callback_counter = 0; |
| 324 | status_received = false; |
| 325 | last_status_code = 0; |
| 326 | timeout_occurred = false; |
| 327 | task_self_destructed = false; |
| 328 | global_status_request = nullptr; |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * @brief Helper to run scheduler until condition or timeout for advanced tests |
| 333 | * |
| 334 | * Enhanced version that handles complex conditions involving multiple |
| 335 | * tasks, status requests, and timeout scenarios. |
| 336 | */ |
| 337 | bool runAdvancedSchedulerUntil(Scheduler& ts, std::function<bool()> condition, unsigned long timeout_ms = 2000) { |
| 338 | return waitForCondition([&]() { |
| 339 | ts.execute(); |
| 340 | return condition(); |
| 341 | }, timeout_ms); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * @brief Clear advanced test output buffer |
| 346 | */ |
| 347 | void clearAdvancedTestOutput() { |
| 348 | advanced_test_output.clear(); |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * @brief Get count of advanced test output entries |
| 353 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected