1 /*
2  * Copyright (c) 2022-2023 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_extension_utils.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace AAFwk {
25 class UIExtensionUtilsTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void UIExtensionUtilsTest::SetUpTestCase()
34 {}
35 
TearDownTestCase()36 void UIExtensionUtilsTest::TearDownTestCase()
37 {}
38 
SetUp()39 void UIExtensionUtilsTest::SetUp()
40 {}
41 
TearDown()42 void UIExtensionUtilsTest::TearDown()
43 {}
44 
45 /**
46  * @tc.name: IsUIExtension_0100
47  * @tc.desc: IsUIExtension Test
48  * @tc.type: FUNC
49  * @tc.require: issueI7HOM3
50  */
51 HWTEST_F(UIExtensionUtilsTest, IsUIExtension_0100, TestSize.Level0)
52 {
53     AppExecFwk::ExtensionAbilityType extensionAbilityType = AppExecFwk::ExtensionAbilityType::UI;
54     bool result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
55     EXPECT_TRUE(result);
56 
57     extensionAbilityType = AppExecFwk::ExtensionAbilityType::SYSPICKER_MEDIACONTROL;
58     result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
59     EXPECT_TRUE(result);
60 
61     extensionAbilityType = AppExecFwk::ExtensionAbilityType::SYSDIALOG_USERAUTH;
62     result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
63     EXPECT_TRUE(result);
64 
65     extensionAbilityType = AppExecFwk::ExtensionAbilityType::WINDOW;
66     result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
67     EXPECT_FALSE(result);
68 
69     extensionAbilityType = AppExecFwk::ExtensionAbilityType::ACTION;
70     result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
71     EXPECT_TRUE(result);
72 }
73 
74 /**
75  * @tc.name: IsWindowExtension_0100
76  * @tc.desc: IsWindowExtension Test
77  * @tc.type: FUNC
78  * @tc.require: issueI7HOM3
79  */
80 HWTEST_F(UIExtensionUtilsTest, IsWindowExtension_0100, TestSize.Level0)
81 {
82     AppExecFwk::ExtensionAbilityType extensionAbilityType = AppExecFwk::ExtensionAbilityType::UI;
83     bool result = UIExtensionUtils::IsWindowExtension(extensionAbilityType);
84     EXPECT_FALSE(result);
85 
86     extensionAbilityType = AppExecFwk::ExtensionAbilityType::WINDOW;
87     result = UIExtensionUtils::IsWindowExtension(extensionAbilityType);
88     EXPECT_TRUE(result);
89 
90     extensionAbilityType = AppExecFwk::ExtensionAbilityType::SHARE;
91     result = UIExtensionUtils::IsUIExtension(extensionAbilityType);
92     EXPECT_TRUE(result);
93 }
94 }  // namespace AAFwk
95 }  // namespace OHOS
96