bt_device_unittest.cc revision fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9e
10d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 20d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// Use of this source code is governed by a BSD-style license that can be 30d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// found in the LICENSE file. 40d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 50d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include <gtest/gtest.h> 60d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 70d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoextern "C" { 80d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_bt_io.h" 90d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_bt_device.h" 100d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_iodev.h" 110664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao#include "cras_main_message.h" 120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#define FAKE_OBJ_PATH "/obj/path" 140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic struct cras_iodev *cras_bt_io_create_profile_ret; 170d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic struct cras_iodev *cras_bt_io_append_btio_val; 18971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chaostatic struct cras_ionode* cras_bt_io_get_profile_ret; 190d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_create_called; 200d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_append_called; 210d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_remove_called; 220d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_destroy_called; 230d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic enum cras_bt_device_profile cras_bt_io_create_profile_val; 240d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic enum cras_bt_device_profile cras_bt_io_append_profile_val; 25b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chaostatic unsigned int cras_bt_io_try_remove_ret; 260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 270664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic cras_main_message *cras_main_message_send_msg; 280664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic cras_message_callback cras_main_message_add_handler_callback; 290664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic void *cras_main_message_add_handler_callback_data; 30e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 310d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid ResetStubData() { 32971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao cras_bt_io_get_profile_ret = NULL; 330d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_called = 0; 340d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_called = 0; 350d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_remove_called = 0; 360d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_destroy_called = 0; 37b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = 0; 380d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 390d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 400d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaonamespace { 410d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 420d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoclass BtDeviceTestSuite : public testing::Test { 430d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao protected: 440d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao virtual void SetUp() { 450d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao ResetStubData(); 46e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev1.direction = CRAS_STREAM_OUTPUT; 47e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev1.is_open = is_open; 48e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev1.update_active_node = update_active_node; 49e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev2.direction = CRAS_STREAM_INPUT; 50e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev2.is_open = is_open; 51e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev2.update_active_node = update_active_node; 520d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d1_.direction = CRAS_STREAM_OUTPUT; 530d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d1_.is_open = is_open; 54e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d1_.update_active_node = update_active_node; 550d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d2_.direction = CRAS_STREAM_OUTPUT; 560d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d2_.is_open = is_open; 57e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d2_.update_active_node = update_active_node; 58e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d3_.direction = CRAS_STREAM_INPUT; 59e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d3_.is_open = is_open; 60e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d3_.update_active_node = update_active_node; 610d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao } 620d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao static int is_open(const cras_iodev* iodev) { 630d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return is_open_; 640d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao } 65bb28140f38fdf6627ec26696c943dfa4f9188450Hsin-Yu Chao static void update_active_node(struct cras_iodev *iodev, 660def72b968591065f56e88d67e5c83234184811bHsin-Yu Chao unsigned node_idx, 670def72b968591065f56e88d67e5c83234184811bHsin-Yu Chao unsigned dev_enabled) { 68e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao } 690d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 700d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev bt_iodev1; 71e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_iodev bt_iodev2; 72e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_iodev d3_; 730d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev d2_; 740d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev d1_; 750d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao static int is_open_; 760d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao}; 770d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 780d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint BtDeviceTestSuite::is_open_; 790d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 800d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu ChaoTEST(BtDeviceSuite, CreateBtDevice) { 810d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device; 820d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 830d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 840d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_NE((void *)NULL, device); 850d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 860d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_get(FAKE_OBJ_PATH); 870d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_NE((void *)NULL, device); 880d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 890d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_destroy(device); 900d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_get(FAKE_OBJ_PATH); 910d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ((void *)NULL, device); 920d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 930d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 940d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu ChaoTEST_F(BtDeviceTestSuite, AppendRmIodev) { 950d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device; 960d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 970d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao bt_iodev1.nodes = reinterpret_cast<struct cras_ionode*>(0x123); 980d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev1; 990d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_append_iodev(device, &d1_, 1000d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 1010d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_create_called); 1020d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(0, cras_bt_io_append_called); 1030d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE, 1040d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_val); 1058401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao cras_bt_device_set_active_profile(device, 1068401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 1070d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 1080d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_append_iodev(device, &d2_, 1090d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 1100d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_create_called); 1110d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_append_called); 1120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY, 1130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_profile_val); 1140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(&bt_iodev1, cras_bt_io_append_btio_val); 1150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 116b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao /* Test HFP disconnected and switch to A2DP. */ 117971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao cras_bt_io_get_profile_ret = bt_iodev1.nodes; 118b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE; 119b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_device_set_active_profile( 120b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao device, CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 1210d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_rm_iodev(device, &d2_); 1220d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_remove_called); 123b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao 124b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao /* Test A2DP disconnection will cause bt_io destroy. */ 125b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = 0; 1260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_rm_iodev(device, &d1_); 127b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_remove_called); 1280d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_destroy_called); 1298401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao EXPECT_EQ(0, cras_bt_device_get_active_profile(device)); 1300d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1310d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 132e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu ChaoTEST_F(BtDeviceTestSuite, SwitchProfile) { 133e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_bt_device *device; 134e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 135e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao ResetStubData(); 136e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 137e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev1; 138e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_append_iodev(device, &d1_, 139e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 140e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev2; 141e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_append_iodev(device, &d3_, 142e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 143e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 144e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_start_monitor(); 145e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_switch_profile_on_open(device, &bt_iodev1); 146e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 147e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* Two bt iodevs were all active. */ 1480664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1490664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1500664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 151e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 152e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* One bt iodev was active, the other was not. */ 153e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_switch_profile_on_open(device, &bt_iodev2); 1540664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1550664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1560664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 157e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 158e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* Output bt iodev wasn't active, close the active input iodev. */ 159e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_switch_profile_on_close(device, &bt_iodev2); 1600664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1610664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1620664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 163e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao} 164e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 1650d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* Stubs */ 1660d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoextern "C" { 1670d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 1680d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_io */ 1690d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostruct cras_iodev *cras_bt_io_create( 1700d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device, 1710d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev, 1720d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao enum cras_bt_device_profile profile) 1730d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1740d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_called++; 1750d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_val = profile; 1760d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return cras_bt_io_create_profile_ret; 1770d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1780d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid cras_bt_io_destroy(struct cras_iodev *bt_iodev) 1790d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1800d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_destroy_called++; 1810d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 182971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chaostruct cras_ionode* cras_bt_io_get_profile( 183971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao struct cras_iodev *bt_iodev, 184971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao enum cras_bt_device_profile profile) 1850d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 186971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao return cras_bt_io_get_profile_ret; 1870d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1880d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint cras_bt_io_append(struct cras_iodev *bt_iodev, 1890d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev, 1900d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao enum cras_bt_device_profile profile) 1910d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1920d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_called++; 1930d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_profile_val = profile; 1940d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_btio_val = bt_iodev; 1950d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return 0; 1960d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 197ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chaoint cras_bt_io_on_profile(struct cras_iodev *bt_iodev, 198ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao enum cras_bt_device_profile profile) 199ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao{ 200ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao return 0; 201ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao} 2025f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chaoint cras_bt_io_update_buffer_size(struct cras_iodev *bt_iodev) 2035f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao{ 2045f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao return 0; 2055f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao} 206b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chaounsigned int cras_bt_io_try_remove(struct cras_iodev *bt_iodev, 207b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao struct cras_iodev *dev) 208b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao{ 209b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao return cras_bt_io_try_remove_ret; 210b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao} 2110d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint cras_bt_io_remove(struct cras_iodev *bt_iodev, 2120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev) 2130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_remove_called++; 2150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return 0; 2160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2170d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 2180d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_adapter */ 2190d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostruct cras_bt_adapter *cras_bt_adapter_get(const char *object_path) 2200d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2210d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return NULL; 2220d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2230d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoconst char *cras_bt_adapter_address(const struct cras_bt_adapter *adapter) 2240d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2250d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return NULL; 2260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2270d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 2281668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chaoint cras_bt_adapter_on_usb(struct cras_bt_adapter *adapter) 2291668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao{ 2301668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao return 1; 2311668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao} 2321668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao 2330d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_profile */ 2340d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid cras_bt_profile_on_device_disconnected(struct cras_bt_device *device) 2350d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2360d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 237e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 2385b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao/* From hfp_ag_profile */ 2395b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chaostruct hfp_slc_handle *cras_hfp_ag_get_slc(struct cras_bt_device *device) 2405b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao{ 2415b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao return NULL; 2425b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao} 2435b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao 2445b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao/* From hfp_slc */ 2455b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chaoint hfp_event_speaker_gain(struct hfp_slc_handle *handle, int gain) 2465b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao{ 2475b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao return 0; 2485b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao} 2495b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao 250e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao/* From iodev_list */ 2510174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 25224cd7e982a045254b20e9a84830072ffa8f18180Hsin-Yu Chaoint cras_iodev_open(struct cras_iodev *dev, unsigned int cb_level) { 2534021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2544021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2554021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 2564021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reidint cras_iodev_close(struct cras_iodev *dev) { 2574021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2584021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2594021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 2600174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaoint cras_iodev_list_dev_is_enabled(struct cras_iodev *dev) 2610174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2620174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao return 0; 2630174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2640174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2650174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_disable_dev(struct cras_iodev *dev) 2660174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2670174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2680174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2690174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_enable_dev(struct cras_iodev *dev) 2700174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2710174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2720174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 273fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chaovoid cras_iodev_list_notify_node_volume(struct cras_ionode *node) 274fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao{ 275fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao} 276fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao 2770664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_send(struct cras_main_message *msg) 278e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao{ 2790664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg = msg; 2800664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao return 0; 2810664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao} 2820664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao 2830664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_add_handler(enum CRAS_MAIN_MESSAGE_TYPE type, 2840664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_message_callback callback, 2850664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao void *callback_data) 2860664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao{ 2870664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback = callback; 2880664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data = callback_data; 289e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao return 0; 290e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao} 291e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 292268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_system_state */ 293268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaostruct cras_tm *cras_system_state_get_tm() 294268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 295268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao return NULL; 296268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 297268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 298268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_tm */ 2990e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chaostruct cras_timer *cras_tm_create_timer( 3000e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao struct cras_tm *tm, 3010e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao unsigned int ms, 3020e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void (*cb)(struct cras_timer *t, void *data), 3030e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void *cb_data) 3040e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao{ 3050e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao return NULL; 3060e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao} 3070e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao 308268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaovoid cras_tm_cancel_timer(struct cras_tm *tm, struct cras_timer *t) 309268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 310268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 311268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 3120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // extern "C" 3130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // namespace 3140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint main(int argc, char **argv) { 3160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao ::testing::InitGoogleTest(&argc, argv); 3170d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return RUN_ALL_TESTS(); 3180d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 3190d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3200d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 321