| 
									
										
										
										
											2021-08-30 13:31:09 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Format.h>
 | 
					
						
							|  |  |  | #include <LibCore/EventLoop.h>
 | 
					
						
							|  |  |  | #include <LibCore/Timer.h>
 | 
					
						
							|  |  |  | #include <LibTest/TestCase.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_CASE(deferred_invoke) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-05-17 17:14:06 -07:00
										 |  |  |     IGNORE_USE_IN_ESCAPING_LAMBDA Core::EventLoop event_loop; | 
					
						
							| 
									
										
										
										
											2024-04-16 20:34:01 +02:00
										 |  |  |     auto reaper = Core::Timer::create_single_shot(250, [] { | 
					
						
							| 
									
										
										
										
											2021-08-30 13:31:09 +00:00
										 |  |  |         warnln("I waited for the deferred_invoke to happen, but it never did!"); | 
					
						
							|  |  |  |         VERIFY_NOT_REACHED(); | 
					
						
							| 
									
										
										
										
											2024-04-16 20:34:01 +02:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2021-08-30 13:31:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Core::deferred_invoke([&event_loop] { | 
					
						
							|  |  |  |         event_loop.quit(0); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     event_loop.exec(); | 
					
						
							|  |  |  | } |