summaryrefslogtreecommitdiff
path: root/include/mock
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2020-12-07 17:39:09 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-15 15:39:18 +0000
commit0a561def48d4e673c834f4d01506ba8b9886cdd4 (patch)
treecbca0104ac3fe7058c0d58d14abd95decb39da6e /include/mock
parent160208413d16840428e42ecae18457e862e6ed49 (diff)
downloadchrome-ec-0a561def48d4e673c834f4d01506ba8b9886cdd4.tar.gz
mock: Clean up TCPMv2 mocks
Place mock functions in the mock libraries corresponding to the layers of the real implementations. Broadly, move towards one layer of the TCPM stack as a UUT, with mocks for the other layers as needed. There should be a one-to-one correspondence between real modules and mock modules. usb_pd_mock.c does not correspond to any real implementation module or TCPM stack layer, so remove it and move its contents to the layers corresponding to their real implementations. Also clean up some redundant or misplaced mocks inside tests. BUG=b:153071799,b:173791979 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ic44df8675de2b9f1f8c7669cd97dcdc296bf107f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578200 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'include/mock')
-rw-r--r--include/mock/usb_pd_mock.h23
-rw-r--r--include/mock/usb_tc_sm_mock.h3
2 files changed, 3 insertions, 23 deletions
diff --git a/include/mock/usb_pd_mock.h b/include/mock/usb_pd_mock.h
deleted file mode 100644
index 353437d3e3..0000000000
--- a/include/mock/usb_pd_mock.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-/* Mock USB PD */
-
-#ifndef __MOCK_USB_PD_MOCK_H
-#define __MOCK_USB_PD_MOCK_H
-
-#include "common.h"
-#include "usb_pd.h"
-
-/* Defaults should all be 0 values. */
-struct mock_pd_port_t {
- enum pd_data_role data_role;
- enum pd_power_role power_role;
-};
-
-extern struct mock_pd_port_t mock_pd_port[CONFIG_USB_PD_PORT_MAX_COUNT];
-
-void mock_pd_reset(void);
-
-#endif /* __MOCK_USB_PD_MOCK_H */
diff --git a/include/mock/usb_tc_sm_mock.h b/include/mock/usb_tc_sm_mock.h
index f5c599ca1f..1120ea850b 100644
--- a/include/mock/usb_tc_sm_mock.h
+++ b/include/mock/usb_tc_sm_mock.h
@@ -9,6 +9,7 @@
#include "common.h"
#include "usb_tc_sm.h"
+#include "usb_pd.h"
struct mock_tc_port_t {
int rev;
@@ -20,6 +21,8 @@ struct mock_tc_port_t {
int attached_snk;
int attached_src;
bool vconn_src;
+ enum pd_data_role data_role;
+ enum pd_power_role power_role;
};
extern struct mock_tc_port_t mock_tc_port[CONFIG_USB_PD_PORT_MAX_COUNT];