1/* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include <gtest/gtest.h> 17 18#include "client_map.h" 19#include "service_entry.h" 20 21using namespace testing::ext; 22 23namespace { 24class ClientMapTest : public testing::Test { 25public: 26 static void SetUpTestCase() {} 27 28 static void TearDownTestCase() {} 29 void SetUp() {} 30 void TearDown() {} 31}; 32 33/** 34 * @tc.name: Service 35 * @tc.desc: Client map performance. 36 * @tc.type: FUNC 37 */ 38HWTEST_F(ClientMapTest, ClientSocket, TestSize.Level1) 39{ 40 ServiceEntry serviceEntry; 41 ServiceEntry serviceTest; 42 ASSERT_EQ(ClientMap::GetInstance().PutClientSocket(1, serviceEntry), 1); 43 ClientMap::GetInstance().PutClientSocket(2, serviceTest); 44 ASSERT_EQ(ClientMap::GetInstance().PutClientSocket(2, serviceTest), -1); 45 ASSERT_EQ(ClientMap::GetInstance().AutoRelease(), 1); 46 ClientMap::GetInstance().socketClients_[2]->clientState_ = CLIENT_STAT_THREAD_EXITED; 47 ASSERT_EQ(ClientMap::GetInstance().AutoRelease(), 1); 48 ASSERT_EQ(ClientMap::GetInstance().ClearClientSocket(), 0); 49 ASSERT_EQ(ClientMap::GetInstance().AutoRelease(), 1); 50} 51} // namespace