• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 #include "utils/window_options_utils.h"
18 #include "hilog_tag_wrapper.h"
19 using namespace testing;
20 using namespace testing::ext;
21 using OHOS::AppExecFwk::ExtensionAbilityType;
22 
23 namespace OHOS {
24 namespace AAFwk {
25 class WindowOptionsUtilsTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase()33 void WindowOptionsUtilsTest::SetUpTestCase() {}
34 
TearDownTestCase()35 void WindowOptionsUtilsTest::TearDownTestCase() {}
36 
SetUp()37 void WindowOptionsUtilsTest::SetUp() {}
38 
TearDown()39 void WindowOptionsUtilsTest::TearDown() {}
40 /*
41  * Feature: WindowOptionsUtils
42  * Function: SetWindowPositionAndSize
43  * SubFunction: NA
44  * FunctionPoints: AbilityManagerService SetWindowPositionAndSize
45  */
46 HWTEST_F(WindowOptionsUtilsTest, SetWindowPositionAndSize_001, TestSize.Level1)
47 {
48     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest SetWindowPositionAndSize_001 start");
49     Want want;
50     sptr<IRemoteObject> callerToken;
51     StartOptions startOptions;
52     auto Window_ = std::make_shared<WindowOptionsUtils>();
53     Window_->SetWindowPositionAndSize(want, callerToken, startOptions);
54     EXPECT_NE(nullptr, Window_);
55     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest SetWindowPositionAndSize_001 end");
56 }
57 
58 /*
59  * Feature: WindowOptionsUtils
60  * Function: SetWindowPositionAndSize
61  * SubFunction: NA
62  * FunctionPoints: AbilityManagerService SetWindowPositionAndSize
63  */
64 HWTEST_F(WindowOptionsUtilsTest, SetWindowPositionAndSize_002, TestSize.Level1)
65 {
66     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest SetWindowPositionAndSize_002 start");
67     Want want;
68     sptr<IRemoteObject> callerToken;
69     StartOptions startOptions;
70     const int32_t minLength = 300;
71     const int32_t maxLength = 500;
72     startOptions.SetMinWindowWidth(minLength);
73     startOptions.minWindowWidthUsed_ = true;
74     startOptions.SetMinWindowHeight(minLength);
75     startOptions.minWindowHeightUsed_ = true;
76     startOptions.SetMaxWindowWidth(maxLength);
77     startOptions.maxWindowWidthUsed_ = true;
78     startOptions.SetMaxWindowHeight(maxLength);
79     startOptions.maxWindowHeightUsed_ = true;
80     auto Window_ = std::make_shared<WindowOptionsUtils>();
81     ASSERT_NE(nullptr, Window_);
82     Window_->SetWindowPositionAndSize(want, callerToken, startOptions);
83     EXPECT_EQ(startOptions.GetMinWindowWidth(), minLength);
84     EXPECT_EQ(startOptions.GetMinWindowHeight(), minLength);
85     EXPECT_EQ(startOptions.GetMaxWindowWidth(), maxLength);
86     EXPECT_EQ(startOptions.GetMaxWindowHeight(), maxLength);
87     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest SetWindowPositionAndSize_002 end");
88 }
89 
90 /*
91  * Feature: WindowOptionsUtils
92  * Function: WindowModeMap
93  * SubFunction: NA
94  * FunctionPoints: AbilityManagerService WindowModeMap
95  */
96 HWTEST_F(WindowOptionsUtilsTest, WindowModeMap_001, TestSize.Level1)
97 {
98     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_001 start");
99     WindowOptionsUtils  Window_;
100     int32_t windowMode = MULTI_WINDOW_DISPLAY_FULLSCREEN;
101     auto result = Window_.WindowModeMap(windowMode);
102     EXPECT_TRUE(result.first);
103     EXPECT_EQ(result.second, AppExecFwk::SupportWindowMode::FULLSCREEN);
104     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_001 end");
105 }
106 /*
107  * Feature: WindowModeMap
108  * Function: SetWindowPositionAndSize
109  * SubFunction: NA
110  * FunctionPoints: AbilityManagerService WindowModeMap
111  */
112 HWTEST_F(WindowOptionsUtilsTest, WindowModeMap_002, TestSize.Level1)
113 {
114     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_002 start");
115     WindowOptionsUtils  Window_;
116     int32_t windowMode = MULTI_WINDOW_DISPLAY_PRIMARY;
117     auto result = Window_.WindowModeMap(windowMode);
118     EXPECT_TRUE(result.first);
119     EXPECT_EQ(result.second, AppExecFwk::SupportWindowMode::SPLIT);
120     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_002 end");
121 }
122 /*
123  * Feature: WindowOptionsUtils
124  * Function: WindowModeMap
125  * SubFunction: NA
126  * FunctionPoints: AbilityManagerService WindowModeMap
127  */
128 HWTEST_F(WindowOptionsUtilsTest, WindowModeMap_003, TestSize.Level1)
129 {
130     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_003 start");
131     WindowOptionsUtils  Window_;
132     int32_t windowMode = MULTI_WINDOW_DISPLAY_SECONDARY;
133     auto result = Window_.WindowModeMap(windowMode);
134     EXPECT_TRUE(result.first);
135     EXPECT_EQ(result.second, AppExecFwk::SupportWindowMode::SPLIT);
136     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_003 end");
137 }
138 /*
139  * Feature: WindowOptionsUtils
140  * Function: WindowModeMap
141  * SubFunction: NA
142  * FunctionPoints: AbilityManagerService WindowModeMap
143  */
144 HWTEST_F(WindowOptionsUtilsTest, WindowModeMap_004, TestSize.Level1)
145 {
146     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_004 start");
147     WindowOptionsUtils  Window_;
148     int32_t windowMode = MULTI_WINDOW_DISPLAY_FLOATING;
149     auto result = Window_.WindowModeMap(windowMode);
150     EXPECT_TRUE(result.first);
151     EXPECT_EQ(result.second, AppExecFwk::SupportWindowMode::FLOATING);
152     TAG_LOGI(AAFwkTag::TEST, "WindowOptionsUtilsTest WindowModeMap_004 end");
153 }
154 } // namespace AAFwk
155 } // namespace OHOS
156