diff options
author | Paul Fagerburg <pfagerburg@google.com> | 2020-08-14 17:20:04 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-31 17:06:13 +0000 |
commit | 33db71602297092026bb714f8b038ac0e7ac593d (patch) | |
tree | 4f40eb0fbcc63acd5d8f4387f7d2d554f80ae6b4 /common/mock/usb_pd_mock.c | |
parent | bd018841f6f2856c949dcf9b6dd462872cd18d7f (diff) | |
download | chrome-ec-33db71602297092026bb714f8b038ac0e7ac593d.tar.gz |
usb_pe_drp: new unit test with mocks
Add a new unit test for usb_pe_drp with mocks for the various
subsystems that it will use.
The fake_prl module is already essentially a mock for the PRL layer,
so just move it into the mocks directory and make it available as
mock to other tests.
BUG=b:163421994
BRANCH=None
TEST=`make runhosttests` succeeds
Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'common/mock/usb_pd_mock.c')
-rw-r--r-- | common/mock/usb_pd_mock.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/common/mock/usb_pd_mock.c b/common/mock/usb_pd_mock.c index 3d3e895d6f..653c98c78e 100644 --- a/common/mock/usb_pd_mock.c +++ b/common/mock/usb_pd_mock.c @@ -13,6 +13,12 @@ struct mock_pd_port_t mock_pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; +void mock_pd_reset(void) +{ + /* Reset all values to 0. */ + memset(mock_pd_port, 0, sizeof(mock_pd_port)); +} + enum pd_dual_role_states pd_get_dual_role(int port) { return PD_DRP_TOGGLE_ON; @@ -33,9 +39,6 @@ enum pd_cc_states pd_get_task_cc_state(int port) return PD_CC_NONE; } -/* TODO remove when usbc_fake is cleaned up */ -#if !defined(CONFIG_USB_DRP_ACC_TRYSRC) && \ - !defined(CONFIG_USB_CTVPD) int pd_is_connected(int port) { return 1; @@ -45,19 +48,18 @@ bool pd_is_disconnected(int port) { return false; } -#endif /* !CONFIG_USB_DRP_ACC_TRYSRC && !CONFIG_USB_CTVPD */ -const uint32_t * const pd_get_src_caps(int port) +__overridable const uint32_t * const pd_get_src_caps(int port) { return NULL; } -uint8_t pd_get_src_cap_cnt(int port) +__overridable uint8_t pd_get_src_cap_cnt(int port) { return 0; } -void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) +__overridable void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) { } @@ -75,3 +77,21 @@ void pd_set_suspend(int port, int suspend) { } +enum tcpc_cc_polarity pd_get_polarity(int port) +{ + return POLARITY_CC1; +} + +void pd_request_data_swap(int port) +{} + +void pd_request_vconn_swap_off(int port) +{} + +void pd_request_vconn_swap_on(int port) +{} + +bool pd_alt_mode_capable(int port) +{ + return false; +} |