1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from __future__ import annotations 6 7import argparse 8from typing import Any 9 10from crossbench.action_runner.android_input_action_runner import \ 11 AndroidInputActionRunner 12from crossbench.action_runner.base import ActionRunner 13from crossbench.action_runner.basic_action_runner import BasicActionRunner 14from crossbench.action_runner.chromeos_input_action_runner import \ 15 ChromeOSInputActionRunner 16 17 18# TODO: migrate to full config.ConfigObject 19class ActionRunnerConfig: 20 21 @classmethod 22 def parse(cls, value: Any) -> ActionRunner: 23 if isinstance(value, ActionRunner): 24 return value 25 if value == "basic": 26 return BasicActionRunner() 27 if value == "android": 28 return AndroidInputActionRunner() 29 if value == "chromeos": 30 return ChromeOSInputActionRunner() 31 raise argparse.ArgumentTypeError( 32 f"Invalid choice '{value}', allowed values are 'basic', 'android', " 33 "'chromeos'" 34 ) 35