• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gtest/gtest.h>
17 
18 #include "application_context.h"
19 #include "input_event.h"
20 #include "key_event.h"
21 #include "mock/mock_session_stage.h"
22 #include "pointer_event.h"
23 
24 #include "session/host/include/main_session.h"
25 #include "session/host/include/keyboard_session.h"
26 #define PRIVATE public
27 #define PROTECTED public
28 #include "session/host/include/scene_session.h"
29 #undef PRIVATE
30 #undef PROTECTED
31 #include "session/host/include/sub_session.h"
32 #include "session/host/include/system_session.h"
33 #include "ui/rs_surface_node.h"
34 #include "window_helper.h"
35 #include "wm_common.h"
36 
37 using namespace testing;
38 using namespace testing::ext;
39 namespace OHOS {
40 namespace Rosen {
41 class SceneSessionRotationTest : public testing::Test {
42 public:
43     static void SetUpTestCase();
44     static void TearDownTestCase();
45     void SetUp() override;
46     void TearDown() override;
47 };
48 
SetUpTestCase()49 void SceneSessionRotationTest::SetUpTestCase() {}
50 
TearDownTestCase()51 void SceneSessionRotationTest::TearDownTestCase() {}
52 
SetUp()53 void SceneSessionRotationTest::SetUp() {}
54 
TearDown()55 void SceneSessionRotationTest::TearDown() {}
56 
57 namespace {
58 /**
59  * @tc.name: SetDefaultRequestedOrientation
60  * @tc.desc: SetDefaultRequestedOrientation
61  * @tc.type: FUNC
62  */
63 HWTEST_F(SceneSessionRotationTest, SetDefaultRequestedOrientation, TestSize.Level1)
64 {
65     SessionInfo info;
66     info.abilityName_ = "SetDefaultRequestedOrientation";
67     info.bundleName_ = "SetDefaultRequestedOrientation";
68     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
69     EXPECT_NE(sceneSession, nullptr);
70     Orientation orientation = Orientation::AUTO_ROTATION_UNSPECIFIED;
71     sceneSession->SetDefaultRequestedOrientation(orientation);
72     Orientation ret = sceneSession->GetRequestedOrientation();
73     ASSERT_EQ(orientation, ret);
74 
75     orientation = Orientation::USER_ROTATION_PORTRAIT;
76     sceneSession->SetDefaultRequestedOrientation(orientation);
77     ret = sceneSession->GetRequestedOrientation();
78     ASSERT_EQ(orientation, ret);
79 
80     orientation = Orientation::USER_ROTATION_LANDSCAPE;
81     sceneSession->SetDefaultRequestedOrientation(orientation);
82     ret = sceneSession->GetRequestedOrientation();
83     ASSERT_EQ(orientation, ret);
84 
85     orientation = Orientation::USER_ROTATION_PORTRAIT_INVERTED;
86     sceneSession->SetDefaultRequestedOrientation(orientation);
87     ret = sceneSession->GetRequestedOrientation();
88     ASSERT_EQ(orientation, ret);
89 
90     orientation = Orientation::USER_ROTATION_LANDSCAPE_INVERTED;
91     sceneSession->SetDefaultRequestedOrientation(orientation);
92     ret = sceneSession->GetRequestedOrientation();
93     ASSERT_EQ(orientation, ret);
94 
95     orientation = Orientation::FOLLOW_DESKTOP;
96     sceneSession->SetDefaultRequestedOrientation(orientation);
97     ret = sceneSession->GetRequestedOrientation();
98     ASSERT_EQ(orientation, ret);
99 }
100 } // namespace
101 } // namespace Rosen
102 } // namespace OHOS