summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c
blob: e691d8e76b6d5f010faceff3d32aed54842e2d15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <zephyr/fff.h>
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>

#include "suite.h"
#include "usb_pd.h"
#include "usb_pd_flags.h"

#define TEST_PORT 0

ZTEST_USER(usb_common, test_pd_set_vbus_discharge)
{
	board_vbus_source_enabled_fake.return_val = 0;

	pd_set_vbus_discharge(TEST_PORT, true);
	zassert_equal(ppc_discharge_vbus_fake.arg0_history[0], TEST_PORT);
	zassert_equal(ppc_discharge_vbus_fake.arg1_history[0], 1);
}

ZTEST_USER(usb_common, test_pd_set_vbus_discharge_wrong_args)
{
	pd_set_vbus_discharge(100, true);
	zassert_equal(ppc_discharge_vbus_fake.call_count, 0);
}