1 /*
2 * Copyright (c) 2025 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 "task_unittest.h"
17 namespace OHOS {
18 namespace Media {
19 using namespace testing::ext;
20 const uint32_t NUM_TEST = 0;
21
SetUpTestCase(void)22 void TaskUnitTest::SetUpTestCase(void) {}
TearDownTestCase(void)23 void TaskUnitTest::TearDownTestCase(void) {}
SetUp(void)24 void TaskUnitTest::SetUp(void) {}
TearDown(void)25 void TaskUnitTest::TearDown(void) {}
26
27 /**
28 * @tc.name : Test SetEnableStateChangeLog UpdateThreadPriority API
29 * @tc.number: SetEnableStateChangeLog_001
30 * @tc.desc : Test SetEnableStateChangeLog all
31 * Test UpdateThreadPriority taskInner_ == nullptr
32 */
33 HWTEST_F(TaskUnitTest, SetEnableStateChangeLog_001, TestSize.Level0)
34 {
35 // Test UpdateThreadPriority
36 auto taskPtr = std::make_shared<Task>("testName");
37 ASSERT_NE(taskPtr, nullptr);
38 taskPtr->taskInner_ = nullptr;
39 uint32_t newPriority = NUM_TEST;
40 std::string strBundleName = "testName";
41 taskPtr->UpdateThreadPriority(newPriority, strBundleName);
42
43 // Test SetEnableStateChangeLog
44 taskPtr->taskInner_ =
45 std::make_shared<TaskInner>("testName2", "", TaskType::SINGLETON, TaskPriority::NORMAL, true);
46 taskPtr = std::make_shared<Task>("testName2");
47 ASSERT_NE(taskPtr, nullptr);
48 bool isSupport = true;
49 taskPtr->SetEnableStateChangeLog(isSupport);
50 EXPECT_EQ(taskPtr->taskInner_->isStateLogEnabled_, isSupport);
51 }
52 } // namespace Media
53 } // namespace OHOS