Loading system/btif/test/btif_rc_test.cc +23 −22 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include "btif/include/btif_common.h" #include "common/message_loop_thread.h" #include "device/include/interop.h" #include "include/check.h" #include "include/hardware/bt_rc.h" #include "test/common/mock_functions.h" #include "test/mock/mock_osi_alarm.h" Loading Loading @@ -66,7 +65,7 @@ void AvrcpService::ServiceInterfaceImpl::SetBipClientStatus( bool AvrcpService::ServiceInterfaceImpl::Cleanup() { return true; }; AvrcpService* AvrcpService::Get() { CHECK(instance_ == nullptr); EXPECT_EQ(instance_, nullptr); instance_ = new AvrcpService(); return instance_; } Loading Loading @@ -144,7 +143,7 @@ TEST_F(BtifRcTest, get_element_attr_rsp) { btrc_element_attr_val_t p_attrs[BTRC_MAX_ELEM_ATTR_SIZE]; uint8_t num_attr = BTRC_MAX_ELEM_ATTR_SIZE + 1; CHECK(get_element_attr_rsp(kDeviceAddress, num_attr, p_attrs) == ASSERT_EQ(get_element_attr_rsp(kDeviceAddress, num_attr, p_attrs), BT_STATUS_SUCCESS); ASSERT_EQ(1, get_func_call_count("AVRC_BldResponse")); } Loading @@ -157,7 +156,7 @@ TEST_F(BtifRcTest, btif_rc_get_addr_by_handle) { btif_rc_cb.rc_multi_cb[0].rc_handle = 0; btif_rc_get_addr_by_handle(0, bd_addr); CHECK(kDeviceAddress == bd_addr); ASSERT_EQ(kDeviceAddress, bd_addr); } static btrc_ctrl_callbacks_t default_btrc_ctrl_callbacks = { Loading Loading @@ -268,10 +267,11 @@ TEST_F(BtifRcWithCallbacksTest, handle_rc_ctrl_features) { handle_rc_ctrl_features(&p_dev); ASSERT_EQ(1, get_func_call_count("AVRC_BldCommand")); CHECK(std::future_status::ready == future.wait_for(std::chrono::seconds(2))); ASSERT_EQ(std::future_status::ready, future.wait_for(std::chrono::seconds(2))); auto res = future.get(); log::info("FEATURES:{}", res.feature); CHECK(res.feature == (BTRC_FEAT_ABSOLUTE_VOLUME | BTRC_FEAT_METADATA | ASSERT_EQ(res.feature, (BTRC_FEAT_ABSOLUTE_VOLUME | BTRC_FEAT_METADATA | BTRC_FEAT_BROWSE | BTRC_FEAT_COVER_ARTWORK)); } Loading Loading @@ -318,9 +318,10 @@ TEST_F(BtifRcBrowseConnectionTest, handle_rc_browse_connect) { /* process unit test handle_rc_browse_connect */ handle_rc_browse_connect(&browse_data); CHECK(std::future_status::ready == future.wait_for(std::chrono::seconds(2))); ASSERT_EQ(std::future_status::ready, future.wait_for(std::chrono::seconds(2))); auto res = future.get(); CHECK(res.bt_state == true); ASSERT_TRUE(res.bt_state); } class BtifRcConnectionTest : public BtifRcTest { Loading Loading @@ -368,10 +369,10 @@ TEST_F(BtifRcConnectionTest, handle_rc_browse_connect) { /* process unit test handle_rc_browse_connect */ handle_rc_browse_connect(&browse_data); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(2))); auto res = g_btrc_connection_state_future.get(); CHECK(res.bt_state == true); ASSERT_TRUE(res.bt_state); } TEST_F(BtifRcConnectionTest, btif_rc_check_pending_cmd) { Loading @@ -386,10 +387,10 @@ TEST_F(BtifRcConnectionTest, btif_rc_check_pending_cmd) { btif_rc_check_pending_cmd(kDeviceAddress); ASSERT_EQ(1, get_func_call_count("AVRC_BldCommand")); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(3))); auto res = g_btrc_connection_state_future.get(); CHECK(res.rc_state == true); ASSERT_TRUE(res.rc_state); } TEST_F(BtifRcConnectionTest, bt_av_rc_open_evt) { Loading Loading @@ -419,14 +420,14 @@ TEST_F(BtifRcConnectionTest, bt_av_rc_open_evt) { btif_rc_handler(BTA_AV_RC_OPEN_EVT, &data); CHECK(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_connected == true); CHECK(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_state == ASSERT_TRUE(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_connected); ASSERT_EQ(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_state, BTRC_CONNECTION_STATE_CONNECTED); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(2))); auto res = g_btrc_connection_state_future.get(); CHECK(res.rc_state == true); ASSERT_TRUE(res.rc_state); } class BtifTrackChangeCBTest : public BtifRcTest { Loading system/osi/test/internal/semaphore_test.cc +10 −4 Original line number Diff line number Diff line #include "osi/semaphore.h" #include <base/logging.h> #include <gtest/gtest.h> #include <sys/select.h> #include <unistd.h> #include "common/message_loop_thread.h" #include "include/check.h" #include "osi/include/osi.h" #include "osi/include/reactor.h" Loading @@ -21,8 +19,16 @@ namespace { void sleep_then_increment_counter(void* context) { SemaphoreTestSequenceHelper* helper = reinterpret_cast<SemaphoreTestSequenceHelper*>(context); CHECK(helper); CHECK(helper->semaphore); EXPECT_NE(helper, nullptr); if (helper == nullptr) { return; } EXPECT_NE(helper->semaphore, nullptr); if (helper->semaphore == nullptr) { return; } sleep(1); ++helper->counter; semaphore_post(helper->semaphore); Loading system/osi/test/list_test.cc +4 −5 Original line number Diff line number Diff line #include "osi/include/list.h" #include <base/logging.h> #include <gtest/gtest.h> #include "osi/include/osi.h" Loading Loading @@ -143,8 +142,8 @@ TEST_F(ListTest, test_list_next) { } static bool list_callback_sum(void* data, void* context) { CHECK(data); CHECK(context); EXPECT_NE(data, nullptr); EXPECT_NE(context, nullptr); int* sum = (int*)context; int* value = (int*)data; *sum += *value; Loading @@ -152,8 +151,8 @@ static bool list_callback_sum(void* data, void* context) { } static bool list_callback_find_int(void* data, void* context) { CHECK(data); CHECK(context); EXPECT_NE(data, nullptr); EXPECT_NE(context, nullptr); return (*(int*)data != *(int*)context); } Loading system/osi/test/wakelock_test.cc +7 −12 Original line number Diff line number Diff line Loading @@ -16,16 +16,14 @@ * ******************************************************************************/ #include <gtest/gtest.h> #include "osi/include/wakelock.h" #include <base/logging.h> #include <fcntl.h> #include <gtest/gtest.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include "osi/include/wakelock.h" static bool is_wake_lock_acquired = false; static int acquire_wake_lock_cb(const char* lock_name) { Loading Loading @@ -53,10 +51,7 @@ class WakelockTest : public ::testing::Test { char* buffer = const_cast<char*>(tmp_dir_.c_str()); char* dtemp = mkdtemp(buffer); if (!dtemp) { perror("Can't make wake lock test directory: "); CHECK(false); } ASSERT_NE(dtemp, nullptr) << "Can't make wake lock test directory"; lock_path_ = tmp_dir_ + "/wake_lock"; unlock_path_ = tmp_dir_ + "/wake_unlock"; Loading Loading @@ -89,16 +84,16 @@ class WakelockTest : public ::testing::Test { bool acquired = false; int lock_fd = open(lock_path_.c_str(), O_RDONLY); CHECK(lock_fd >= 0); EXPECT_GE(lock_fd, 0); int unlock_fd = open(unlock_path_.c_str(), O_RDONLY); CHECK(unlock_fd >= 0); EXPECT_GE(unlock_fd, 0); struct stat lock_stat, unlock_stat; fstat(lock_fd, &lock_stat); fstat(unlock_fd, &unlock_stat); CHECK(lock_stat.st_size >= unlock_stat.st_size); EXPECT_GE(lock_stat.st_size, unlock_stat.st_size); void* lock_file = mmap(nullptr, lock_stat.st_size, PROT_READ, MAP_PRIVATE, lock_fd, 0); Loading @@ -111,7 +106,7 @@ class WakelockTest : public ::testing::Test { } else { // these files should always either be with a lock that has more, // or equal. CHECK(false); ADD_FAILURE(); } munmap(lock_file, lock_stat.st_size); Loading system/stack/test/a2dp/a2dp_vendor_ldac_decoder_test.cc +1 −4 Original line number Diff line number Diff line Loading @@ -16,13 +16,10 @@ #include "stack/include/a2dp_vendor_ldac_decoder.h" #include <base/logging.h> #include <gtest/gtest.h> #include <stdio.h> #include <cstdint> #include "include/check.h" #include "osi/include/allocator.h" #include "stack/include/bt_hdr.h" Loading Loading @@ -55,6 +52,6 @@ class A2dpStackTest : public ::testing::Test { TEST_F(A2dpStackTest, DecodePacket_ZeroLength) { const std::vector<uint8_t> data; BT_HDR* p_buf = AllocateL2capPacket(data); CHECK(!a2dp_vendor_ldac_decoder_decode_packet(p_buf)); ASSERT_FALSE(a2dp_vendor_ldac_decoder_decode_packet(p_buf)); osi_free(p_buf); } Loading
system/btif/test/btif_rc_test.cc +23 −22 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include "btif/include/btif_common.h" #include "common/message_loop_thread.h" #include "device/include/interop.h" #include "include/check.h" #include "include/hardware/bt_rc.h" #include "test/common/mock_functions.h" #include "test/mock/mock_osi_alarm.h" Loading Loading @@ -66,7 +65,7 @@ void AvrcpService::ServiceInterfaceImpl::SetBipClientStatus( bool AvrcpService::ServiceInterfaceImpl::Cleanup() { return true; }; AvrcpService* AvrcpService::Get() { CHECK(instance_ == nullptr); EXPECT_EQ(instance_, nullptr); instance_ = new AvrcpService(); return instance_; } Loading Loading @@ -144,7 +143,7 @@ TEST_F(BtifRcTest, get_element_attr_rsp) { btrc_element_attr_val_t p_attrs[BTRC_MAX_ELEM_ATTR_SIZE]; uint8_t num_attr = BTRC_MAX_ELEM_ATTR_SIZE + 1; CHECK(get_element_attr_rsp(kDeviceAddress, num_attr, p_attrs) == ASSERT_EQ(get_element_attr_rsp(kDeviceAddress, num_attr, p_attrs), BT_STATUS_SUCCESS); ASSERT_EQ(1, get_func_call_count("AVRC_BldResponse")); } Loading @@ -157,7 +156,7 @@ TEST_F(BtifRcTest, btif_rc_get_addr_by_handle) { btif_rc_cb.rc_multi_cb[0].rc_handle = 0; btif_rc_get_addr_by_handle(0, bd_addr); CHECK(kDeviceAddress == bd_addr); ASSERT_EQ(kDeviceAddress, bd_addr); } static btrc_ctrl_callbacks_t default_btrc_ctrl_callbacks = { Loading Loading @@ -268,10 +267,11 @@ TEST_F(BtifRcWithCallbacksTest, handle_rc_ctrl_features) { handle_rc_ctrl_features(&p_dev); ASSERT_EQ(1, get_func_call_count("AVRC_BldCommand")); CHECK(std::future_status::ready == future.wait_for(std::chrono::seconds(2))); ASSERT_EQ(std::future_status::ready, future.wait_for(std::chrono::seconds(2))); auto res = future.get(); log::info("FEATURES:{}", res.feature); CHECK(res.feature == (BTRC_FEAT_ABSOLUTE_VOLUME | BTRC_FEAT_METADATA | ASSERT_EQ(res.feature, (BTRC_FEAT_ABSOLUTE_VOLUME | BTRC_FEAT_METADATA | BTRC_FEAT_BROWSE | BTRC_FEAT_COVER_ARTWORK)); } Loading Loading @@ -318,9 +318,10 @@ TEST_F(BtifRcBrowseConnectionTest, handle_rc_browse_connect) { /* process unit test handle_rc_browse_connect */ handle_rc_browse_connect(&browse_data); CHECK(std::future_status::ready == future.wait_for(std::chrono::seconds(2))); ASSERT_EQ(std::future_status::ready, future.wait_for(std::chrono::seconds(2))); auto res = future.get(); CHECK(res.bt_state == true); ASSERT_TRUE(res.bt_state); } class BtifRcConnectionTest : public BtifRcTest { Loading Loading @@ -368,10 +369,10 @@ TEST_F(BtifRcConnectionTest, handle_rc_browse_connect) { /* process unit test handle_rc_browse_connect */ handle_rc_browse_connect(&browse_data); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(2))); auto res = g_btrc_connection_state_future.get(); CHECK(res.bt_state == true); ASSERT_TRUE(res.bt_state); } TEST_F(BtifRcConnectionTest, btif_rc_check_pending_cmd) { Loading @@ -386,10 +387,10 @@ TEST_F(BtifRcConnectionTest, btif_rc_check_pending_cmd) { btif_rc_check_pending_cmd(kDeviceAddress); ASSERT_EQ(1, get_func_call_count("AVRC_BldCommand")); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(3))); auto res = g_btrc_connection_state_future.get(); CHECK(res.rc_state == true); ASSERT_TRUE(res.rc_state); } TEST_F(BtifRcConnectionTest, bt_av_rc_open_evt) { Loading Loading @@ -419,14 +420,14 @@ TEST_F(BtifRcConnectionTest, bt_av_rc_open_evt) { btif_rc_handler(BTA_AV_RC_OPEN_EVT, &data); CHECK(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_connected == true); CHECK(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_state == ASSERT_TRUE(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_connected); ASSERT_EQ(btif_rc_cb.rc_multi_cb[data.rc_open.rc_handle].rc_state, BTRC_CONNECTION_STATE_CONNECTED); CHECK(std::future_status::ready == ASSERT_EQ(std::future_status::ready, g_btrc_connection_state_future.wait_for(std::chrono::seconds(2))); auto res = g_btrc_connection_state_future.get(); CHECK(res.rc_state == true); ASSERT_TRUE(res.rc_state); } class BtifTrackChangeCBTest : public BtifRcTest { Loading
system/osi/test/internal/semaphore_test.cc +10 −4 Original line number Diff line number Diff line #include "osi/semaphore.h" #include <base/logging.h> #include <gtest/gtest.h> #include <sys/select.h> #include <unistd.h> #include "common/message_loop_thread.h" #include "include/check.h" #include "osi/include/osi.h" #include "osi/include/reactor.h" Loading @@ -21,8 +19,16 @@ namespace { void sleep_then_increment_counter(void* context) { SemaphoreTestSequenceHelper* helper = reinterpret_cast<SemaphoreTestSequenceHelper*>(context); CHECK(helper); CHECK(helper->semaphore); EXPECT_NE(helper, nullptr); if (helper == nullptr) { return; } EXPECT_NE(helper->semaphore, nullptr); if (helper->semaphore == nullptr) { return; } sleep(1); ++helper->counter; semaphore_post(helper->semaphore); Loading
system/osi/test/list_test.cc +4 −5 Original line number Diff line number Diff line #include "osi/include/list.h" #include <base/logging.h> #include <gtest/gtest.h> #include "osi/include/osi.h" Loading Loading @@ -143,8 +142,8 @@ TEST_F(ListTest, test_list_next) { } static bool list_callback_sum(void* data, void* context) { CHECK(data); CHECK(context); EXPECT_NE(data, nullptr); EXPECT_NE(context, nullptr); int* sum = (int*)context; int* value = (int*)data; *sum += *value; Loading @@ -152,8 +151,8 @@ static bool list_callback_sum(void* data, void* context) { } static bool list_callback_find_int(void* data, void* context) { CHECK(data); CHECK(context); EXPECT_NE(data, nullptr); EXPECT_NE(context, nullptr); return (*(int*)data != *(int*)context); } Loading
system/osi/test/wakelock_test.cc +7 −12 Original line number Diff line number Diff line Loading @@ -16,16 +16,14 @@ * ******************************************************************************/ #include <gtest/gtest.h> #include "osi/include/wakelock.h" #include <base/logging.h> #include <fcntl.h> #include <gtest/gtest.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include "osi/include/wakelock.h" static bool is_wake_lock_acquired = false; static int acquire_wake_lock_cb(const char* lock_name) { Loading Loading @@ -53,10 +51,7 @@ class WakelockTest : public ::testing::Test { char* buffer = const_cast<char*>(tmp_dir_.c_str()); char* dtemp = mkdtemp(buffer); if (!dtemp) { perror("Can't make wake lock test directory: "); CHECK(false); } ASSERT_NE(dtemp, nullptr) << "Can't make wake lock test directory"; lock_path_ = tmp_dir_ + "/wake_lock"; unlock_path_ = tmp_dir_ + "/wake_unlock"; Loading Loading @@ -89,16 +84,16 @@ class WakelockTest : public ::testing::Test { bool acquired = false; int lock_fd = open(lock_path_.c_str(), O_RDONLY); CHECK(lock_fd >= 0); EXPECT_GE(lock_fd, 0); int unlock_fd = open(unlock_path_.c_str(), O_RDONLY); CHECK(unlock_fd >= 0); EXPECT_GE(unlock_fd, 0); struct stat lock_stat, unlock_stat; fstat(lock_fd, &lock_stat); fstat(unlock_fd, &unlock_stat); CHECK(lock_stat.st_size >= unlock_stat.st_size); EXPECT_GE(lock_stat.st_size, unlock_stat.st_size); void* lock_file = mmap(nullptr, lock_stat.st_size, PROT_READ, MAP_PRIVATE, lock_fd, 0); Loading @@ -111,7 +106,7 @@ class WakelockTest : public ::testing::Test { } else { // these files should always either be with a lock that has more, // or equal. CHECK(false); ADD_FAILURE(); } munmap(lock_file, lock_stat.st_size); Loading
system/stack/test/a2dp/a2dp_vendor_ldac_decoder_test.cc +1 −4 Original line number Diff line number Diff line Loading @@ -16,13 +16,10 @@ #include "stack/include/a2dp_vendor_ldac_decoder.h" #include <base/logging.h> #include <gtest/gtest.h> #include <stdio.h> #include <cstdint> #include "include/check.h" #include "osi/include/allocator.h" #include "stack/include/bt_hdr.h" Loading Loading @@ -55,6 +52,6 @@ class A2dpStackTest : public ::testing::Test { TEST_F(A2dpStackTest, DecodePacket_ZeroLength) { const std::vector<uint8_t> data; BT_HDR* p_buf = AllocateL2capPacket(data); CHECK(!a2dp_vendor_ldac_decoder_decode_packet(p_buf)); ASSERT_FALSE(a2dp_vendor_ldac_decoder_decode_packet(p_buf)); osi_free(p_buf); }