| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -10,6 +10,7 @@ from common.basedir import BASEDIR | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from common.params import Params | 
					 | 
					 | 
					 | 
					from common.params import Params | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.controls.lib.events import Alert, EVENTS, ET | 
					 | 
					 | 
					 | 
					from selfdrive.controls.lib.events import Alert, EVENTS, ET | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from selfdrive.controls.lib.alertmanager import set_offroad_alert | 
					 | 
					 | 
					 | 
					from selfdrive.controls.lib.alertmanager import set_offroad_alert | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from selfdrive.test.process_replay.process_replay import FakeSubMaster, CONFIGS | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					AlertSize = log.ControlsState.AlertSize | 
					 | 
					 | 
					 | 
					AlertSize = log.ControlsState.AlertSize | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -19,8 +20,7 @@ OFFROAD_ALERTS_PATH = os.path.join(BASEDIR, "selfdrive/controls/lib/alerts_offro | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					ALERTS = [] | 
					 | 
					 | 
					 | 
					ALERTS = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					for event_types in EVENTS.values(): | 
					 | 
					 | 
					 | 
					for event_types in EVENTS.values(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for alert in event_types.values(): | 
					 | 
					 | 
					 | 
					  for alert in event_types.values(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if isinstance(alert, Alert): | 
					 | 
					 | 
					 | 
					    ALERTS.append(alert) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ALERTS.append(alert) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					class TestAlerts(unittest.TestCase): | 
					 | 
					 | 
					 | 
					class TestAlerts(unittest.TestCase): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -30,6 +30,11 @@ class TestAlerts(unittest.TestCase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    with open(OFFROAD_ALERTS_PATH) as f: | 
					 | 
					 | 
					 | 
					    with open(OFFROAD_ALERTS_PATH) as f: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      cls.offroad_alerts = json.loads(f.read()) | 
					 | 
					 | 
					 | 
					      cls.offroad_alerts = json.loads(f.read()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      # Create fake objects for callback | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      cls.CP = car.CarParams.new_message() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      cfg = [c for c in CONFIGS if c.proc_name == 'controlsd'][0] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      cls.sm = FakeSubMaster(cfg.pub_sub.keys()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def test_events_defined(self): | 
					 | 
					 | 
					 | 
					  def test_events_defined(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Ensure all events in capnp schema are defined in events.py | 
					 | 
					 | 
					 | 
					    # Ensure all events in capnp schema are defined in events.py | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    events = car.CarEvent.EventName.schema.enumerants | 
					 | 
					 | 
					 | 
					    events = car.CarEvent.EventName.schema.enumerants | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -59,6 +64,9 @@ class TestAlerts(unittest.TestCase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for alert in ALERTS: | 
					 | 
					 | 
					 | 
					    for alert in ALERTS: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if not isinstance(alert, Alert): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        alert = alert(self.CP, self.sm, metric=False, soft_disable_time=100) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # for full size alerts, both text fields wrap the text, | 
					 | 
					 | 
					 | 
					      # for full size alerts, both text fields wrap the text, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # so it's unlikely that they  would go past the max width | 
					 | 
					 | 
					 | 
					      # so it's unlikely that they  would go past the max width | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if alert.alert_size in (AlertSize.none, AlertSize.full): | 
					 | 
					 | 
					 | 
					      if alert.alert_size in (AlertSize.none, AlertSize.full): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |