1 /*
2 * Copyright (c) 2024 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 <filesystem>
17 #include <fstream>
18 #include <gtest/gtest.h>
19
20 #include "ability_context_impl.h"
21 #include "accessibility_event_info.h"
22 #include "color_parser.h"
23 #include "mock_session.h"
24 #include "mock_uicontent.h"
25 #include "mock_window.h"
26 #include "parameters.h"
27 #include "window_helper.h"
28 #include "window_session_impl.h"
29 #include "wm_common.h"
30
31 using namespace testing;
32 using namespace testing::ext;
33
34 namespace OHOS {
35 namespace Rosen {
36 class WindowSessionImplLayoutTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp() override;
41 void TearDown() override;
42
43 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
44
45 private:
46 static constexpr uint32_t WAIT_SYNC_IN_NS = 50000;
47 };
48
SetUpTestCase()49 void WindowSessionImplLayoutTest::SetUpTestCase() {}
50
TearDownTestCase()51 void WindowSessionImplLayoutTest::TearDownTestCase() {}
52
SetUp()53 void WindowSessionImplLayoutTest::SetUp()
54 {
55 abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
56 }
57
TearDown()58 void WindowSessionImplLayoutTest::TearDown()
59 {
60 usleep(WAIT_SYNC_IN_NS);
61 abilityContext_ = nullptr;
62 }
63
64 namespace {
65 /**
66 * @tc.name: NotifySingleHandTransformChange_TestUIContent
67 * @tc.desc: NotifySingleHandTransformChange
68 * @tc.type: FUNC
69 */
70 HWTEST_F(WindowSessionImplLayoutTest, NotifySingleHandTransformChange_TestUIContent, Function | SmallTest | Level2)
71 {
72 GTEST_LOG_(INFO) << "WindowSessionImplLayoutTest: NotifySingleHandTransformChange_TestUIContent start";
73 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
74 option->SetWindowName("NotifySingleHandTransformChange_TestUIContent");
75 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
76 window->property_->SetPersistentId(2025);
77 std::string url = "";
78 window->SetUIContentInner(
79 url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, BackupAndRestoreType::NONE, nullptr);
80 SingleHandTransform testTransform;
81 testTransform.posX = 100;
82 window->NotifySingleHandTransformChange(testTransform);
83 ASSERT_EQ(testTransform.posX, window->singleHandTransform_.posX);
84 GTEST_LOG_(INFO) << "WindowSessionImplLayoutTest: NotifySingleHandTransformChange_TestUIContent end";
85 }
86 }
87 } // namespace Rosen
88 } // namespace OHOS
89