1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 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 <thread> 17 18 #include <gtest/gtest.h> 19 20 #include "netmanager_hitrace.h" 21 22 namespace OHOS { 23 namespace NetManagerStandard { 24 namespace { 25 using namespace testing::ext; 26 constexpr uint32_t TEST_DELAY_TIME = 1; 27 constexpr const char *TEST_VALUE = "TEST_VALUE"; 28 constexpr int32_t TEST_TASK_ID = 10054; 29 } // namespace 30 31 class NetManagerHiTraceTest : public testing::Test { 32 public: 33 static void SetUpTestCase(); 34 static void TearDownTestCase(); 35 void SetUp(); 36 void TearDown(); 37 }; 38 SetUpTestCase()39void NetManagerHiTraceTest::SetUpTestCase() {} 40 TearDownTestCase()41void NetManagerHiTraceTest::TearDownTestCase() {} 42 SetUp()43void NetManagerHiTraceTest::SetUp() {} 44 TearDown()45void NetManagerHiTraceTest::TearDown() {} 46 47 HWTEST_F(NetManagerHiTraceTest, AllTest001, TestSize.Level1) 48 { 49 NetmanagerHiTrace::NetmanagerStartSyncTrace(TEST_VALUE); 50 std::this_thread::sleep_for(std::chrono::seconds(TEST_DELAY_TIME)); 51 NetmanagerHiTrace::NetmanagerFinishSyncTrace(TEST_VALUE); __anonf4d47c4a0202() 52 std::thread thread([this]() { 53 NetmanagerHiTrace::NetmanagerStartAsyncTrace(TEST_VALUE, TEST_TASK_ID); 54 std::this_thread::sleep_for(std::chrono::seconds(TEST_DELAY_TIME)); 55 NetmanagerHiTrace::NetmanagerFinishAsyncTrace(TEST_VALUE, TEST_TASK_ID); 56 }); 57 thread.join(); 58 } 59 } // namespace NetManagerStandard 60 } // namespace OHOS