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 <gtest/gtest.h>
17
18 #include "ui_effect_controller_common.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22
23 namespace OHOS::Rosen {
24 class UIEffectControllerCommonTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp() override;
29 void TearDown() override;
30 };
31
SetUpTestCase()32 void UIEffectControllerCommonTest::SetUpTestCase() {}
33
TearDownTestCase()34 void UIEffectControllerCommonTest::TearDownTestCase() {}
35
SetUp()36 void UIEffectControllerCommonTest::SetUp() {}
37
TearDown()38 void UIEffectControllerCommonTest::TearDown() {}
39
TearDownTestCase()40 void UIEffectControllerCommonTest::TearDownTestCase() {}
41 namespace {
42 /**
43 * @tc.name: WriteAndReadParcelable
44 * @tc.desc: WriteAndReadParcelable test
45 * @tc.type: FUNC
46 */
47 HWTEST_F(UIEffectControllerCommonTest, WriteAndReadParcelable, TestSize.Level1)
48 {
49 UIEffectParams params;
50 Parcel parcelWrite;
51 EXPECT_EQ(params.Marshalling(parcel), false);
52 params.backgroundFilter_ = sptr<Filter>::MakeSptr();
53 EXPECT_EQ(params.Marshalling(parcel), false);
54 params.effect_ = sptr<VisualEffect>::MakeSptr();
55 EXPECT_EQ(params.Marshalling(parcel), true);
56 EXPECT_EQ(UIEffectParams::Unmarshalling(parcelRead), nullptr);
57 sptr<Filter> backgroundFilter = sptr<Filter>::MakeSptr();
58 parcelRead.WriteStrongParcelable(backgroundFilter);
59 EXPECT_EQ(UIEffectParams::Unmarshalling(parcelRead), nullptr);
60 pstr<VisualEffect> effect = sptr<VisualEffect>::MakeSptr();
61 parcelRead.WriteStrongParcelable(effect);
62 EXPECT_NE(UIEffectParams::Unmarshalling(parcelRead), nullptr);
63 }
64
65 /**
66 * @tc.name: WrapObjectDestruction
67 * @tc.desc: WrapObjectDestruction test
68 * @tc.type: FUNC
69 */
70 HWTEST_F(UIEffectControllerCommonTest, WrapObjectDestruction, TestSize.Level1)
71 {
72 int* data = new int(10);
73 WrapObjectDestructor(nullptr, data, nullptr);
74 EXPECT_EQ(data, nullptr);
75 int* data2 = nullptr;
76 WrapObjectDestructor(nullptr, data, nullptr);
77 EXPECT_EQ(data, nullptr);
78 }
79 }
80 } // namespace OHOS::Rosen