1 /* 2 * Copyright (c) 2024 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 "batch_log_printer_test.h" 17 #include "batch_log_printer.h" 18 19 20 using namespace std; 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace ResourceSchedule { 25 namespace { 26 constexpr int32_t TEST_SUBMIT_NUM = 50; 27 constexpr int32_t TEST_PRINT_NUM = 64; 28 const string TEST_LOG = "test log"; 29 } // namespace 30 SetUpTestCase()31void BatchLogPrinterTest::SetUpTestCase() {} 32 TearDownTestCase()33void BatchLogPrinterTest::TearDownTestCase() {} 34 SetUp()35void BatchLogPrinterTest::SetUp() {} 36 TearDown()37void BatchLogPrinterTest::TearDown() {} 38 39 40 /** 41 * @tc.name: BatchLogPrinterTest SubmitLogTest_001 42 * @tc.desc: test SubmitLog 43 * @tc.type: FUNC 44 * @tc.require: issueIAZWOS 45 */ 46 HWTEST_F(BatchLogPrinterTest, SubmitLogTest_001, Function | MediumTest | Level0) 47 { 48 for (int i = 0;i < TEST_SUBMIT_NUM; ++i) { 49 BatchLogPrinter::GetInstance().SubmitLog(TEST_LOG); 50 } 51 sleep(1); 52 EXPECT_EQ(BatchLogPrinter::GetInstance().allLogs_.size(), TEST_SUBMIT_NUM); 53 for (int i = 0;i < TEST_PRINT_NUM - TEST_SUBMIT_NUM; ++i) { 54 BatchLogPrinter::GetInstance().SubmitLog(TEST_LOG); 55 } 56 sleep(1); 57 EXPECT_EQ(BatchLogPrinter::GetInstance().allLogs_.size(), 0); 58 } 59 } // namespace ResourceSchedule 60 } // namespace OHOS 61