1 /*
2 * Copyright (c) 2025 iSoftStone Information Technology (Group) 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 "gtest/gtest.h"
17
18 #define protected public
19 #define private public
20
21 #include "core/common/multi_thread_build_manager.h"
22 #include "core/components_ng/base/frame_node.h"
23 #include "core/components_ng/pattern/pattern.h"
24
25 using namespace testing;
26 using namespace testing::ext;
27
28 namespace OHOS::Ace {
29 class MultiThreadBuildManagerTest : public testing::Test {
30 public:
31 static void SetUpTestSuite();
32 static void TearDownTestSuite();
33 };
34
SetUpTestSuite()35 void MultiThreadBuildManagerTest::SetUpTestSuite()
36 {
37 }
38
TearDownTestSuite()39 void MultiThreadBuildManagerTest::TearDownTestSuite()
40 {
41 }
42
43 /**
44 * @tc.name: MultiThreadBuildManagerTest
45 * @tc.desc: Test cast to CheckNodeOnValidThread
46 * @tc.type: FUNC
47 */
48 HWTEST_F(MultiThreadBuildManagerTest, CheckNodeOnValidThread001, TestSize.Level1)
49 {
50 bool result = MultiThreadBuildManager::CheckNodeOnValidThread(nullptr);
51 EXPECT_FALSE(result);
52 bool isUIThread = MultiThreadBuildManager::isUIThread_;
53 auto frameNode =
54 NG::FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<NG::Pattern>(), true);
55 MultiThreadBuildManager::isUIThread_ = true;
56 result = MultiThreadBuildManager::CheckNodeOnValidThread(AceType::RawPtr(frameNode));
57 EXPECT_TRUE(result);
58 MultiThreadBuildManager::isUIThread_ = isUIThread;
59 }
60 } // namespace OHOS::Ace
61