diff --git a/services/native/test/unittest/src/coordination_softbus_adapter_test.cpp b/services/native/test/unittest/src/coordination_softbus_adapter_test.cpp index 325b4959a..33938acda 100644 --- a/services/native/test/unittest/src/coordination_softbus_adapter_test.cpp +++ b/services/native/test/unittest/src/coordination_softbus_adapter_test.cpp @@ -74,7 +74,7 @@ void CoordinationSoftbusAdapterTest::TearDown() {} HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest001, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->StartRemoteCoordination(LOCAL_NETWORKID, REMOTE_NETWORKID, false); EXPECT_TRUE(ret == RET_ERR); } @@ -87,7 +87,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest001, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest002, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->StartRemoteCoordination(LOCAL_NETWORKID, REMOTE_NETWORKID, false); @@ -106,7 +106,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest002, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest003, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->StartRemoteCoordinationResult(REMOTE_NETWORKID, true, REMOTE_NETWORKID, 0, 0); EXPECT_TRUE(ret == RET_ERR); } @@ -119,7 +119,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest003, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest004, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->StartRemoteCoordinationResult(REMOTE_NETWORKID, true, REMOTE_NETWORKID, 0, 0); @@ -138,7 +138,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest004, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest005, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->StopRemoteCoordination(REMOTE_NETWORKID, true); EXPECT_TRUE(ret == RET_ERR); } @@ -151,7 +151,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest005, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest006, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->StopRemoteCoordination(REMOTE_NETWORKID, true); @@ -170,7 +170,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest006, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest007, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->StopRemoteCoordinationResult(REMOTE_NETWORKID, true); EXPECT_TRUE(ret == RET_ERR); } @@ -183,7 +183,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest007, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest008, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->StopRemoteCoordinationResult(REMOTE_NETWORKID, true); @@ -202,7 +202,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest008, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest009, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->StartCoordinationOtherResult(ORIGIN_NETWORKID, REMOTE_NETWORKID); EXPECT_TRUE(ret == RET_ERR); } @@ -215,7 +215,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest009, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest010, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[ORIGIN_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->StartCoordinationOtherResult(ORIGIN_NETWORKID, REMOTE_NETWORKID); @@ -234,7 +234,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest010, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest011, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->NotifyFilterAdded(REMOTE_NETWORKID); EXPECT_TRUE(ret == RET_ERR); } @@ -247,7 +247,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest011, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest012, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; g_sendable = false; int32_t ret = g_adapter->NotifyFilterAdded(REMOTE_NETWORKID); @@ -266,7 +266,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest012, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest013, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_adapter->sessionDevs_[REMOTE_NETWORKID] = SESSION_ID; int32_t ret = g_adapter->OpenInputSoftbus(REMOTE_NETWORKID); EXPECT_EQ(ret, RET_OK); @@ -282,7 +282,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest013, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest014, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_init = false; int32_t ret = g_adapter->OpenInputSoftbus(REMOTE_NETWORKID); EXPECT_EQ(ret, RET_ERR); @@ -297,7 +297,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest014, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest015, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_init = true; int32_t ret = g_adapter->OpenInputSoftbus(REMOTE_NETWORKID); EXPECT_EQ(ret, RET_ERR); @@ -312,7 +312,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest015, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest016, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); g_init = true; g_cond = false; int32_t ret = g_adapter->OpenInputSoftbus(REMOTE_NETWORKID); @@ -328,7 +328,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest016, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest017, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->OnSessionOpened(SESSION_ID, RET_ERR); EXPECT_EQ(ret, RET_OK); g_adapter->OnSessionClosed(SESSION_ID); @@ -342,7 +342,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest017, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest018, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); int32_t ret = g_adapter->OnSessionOpened(SESSION_ID, RET_OK); EXPECT_EQ(ret, RET_OK); g_adapter->OnSessionClosed(SESSION_ID); @@ -356,7 +356,7 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest018, Test HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest019, TestSize.Level0) { CALL_TEST_DEBUG; - ASSERT_TRUE(g_adapter != nullptr); + ASSERT_NE(g_adapter, nullptr); std::string data = "TestSendData"; g_adapter->sessionDevs_[DEVICE_ID] = SESSION_ID; int32_t ret = g_adapter->SendData(DEVICE_ID, CoordinationSoftbusAdapter::MIN_ID, const_cast(data.c_str()), @@ -364,6 +364,38 @@ HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest019, Test EXPECT_EQ(ret, RET_ERR); g_adapter->sessionDevs_.clear(); } + +/** + * @tc.name: CoordinationSoftbusAdapterTest020 + * @tc.desc: Test func named NotifyUnchainedResult, sessionDevs_ is null + * @tc.type: FUNC + */ +HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest020, TestSize.Level0) +{ + CALL_TEST_DEBUG; + ASSERT_NE(g_adapter, nullptr); + int32_t ret = g_adapter->NotifyUnchainedResult(LOCAL_NETWORKID, REMOTE_NETWORKID, true); + EXPECT_TRUE(ret == RET_ERR); +} + +/** + * @tc.name: CoordinationSoftbusAdapterTest021 + * @tc.desc: Test func named NotifyUnchainedResult, sessionDevs_ is not null, sendMsg is err or ok + * @tc.type: FUNC + */ +HWTEST_F(CoordinationSoftbusAdapterTest, CoordinationSoftbusAdapterTest021, TestSize.Level0) +{ + CALL_TEST_DEBUG; + ASSERT_NE(g_adapter, nullptr); + g_adapter->sessionDevs_[REMOTE_NETWORKID] = 1; + g_sendable = false; + int32_t ret = g_adapter->NotifyUnchainedResult(LOCAL_NETWORKID, REMOTE_NETWORKID, true); + EXPECT_TRUE(ret == RET_ERR); + g_sendable = true; + ret = g_adapter->NotifyUnchainedResult(LOCAL_NETWORKID, REMOTE_NETWORKID, true); + EXPECT_TRUE(ret == RET_OK); + g_adapter->sessionDevs_.clear(); +} } // namespace DeviceStatus } // namespace Msdp } // namespace OHOS \ No newline at end of file