mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-22 22:41:00 +00:00
Differential configuration of sliding curve parameters
Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com> Differential configuration of sliding curve parameters Signed-off-by: wangziayo <wangziyao13@huawei.com>
This commit is contained in:
parent
a396c14716
commit
59beb71abb
@ -12,4 +12,5 @@
|
||||
# limitations under the License.
|
||||
|
||||
bootevent.wms.fullscreen.ready = foundation:foundation:0775
|
||||
bootevent.wms.ready = foundation:foundation:0775
|
||||
bootevent.wms.ready = foundation:foundation:0775
|
||||
persist.scrollable. = foundation:foundation:0775
|
@ -417,6 +417,14 @@ struct DisplayPhysicalResolution {
|
||||
uint32_t physicalHeight_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief scrollable param
|
||||
*/
|
||||
struct ScrollableParam {
|
||||
std::string velocityScale_;
|
||||
std::string friction_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief displayRect
|
||||
*/
|
||||
|
@ -101,6 +101,7 @@ ohos_shared_library("screen_session_manager") {
|
||||
"input:libmmi-napi",
|
||||
]
|
||||
deps = [
|
||||
"${window_base_path}/etc:wms_etc",
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/window_scene/common:window_scene_common",
|
||||
|
@ -42,6 +42,7 @@ private:
|
||||
void ChangeScreenDisplayModeInner(sptr<ScreenSession> screenSession, ScreenId offScreenId, ScreenId onScreenId);
|
||||
void ChangeScreenDisplayModeOnBootAnimation(sptr<ScreenSession> screenSession, ScreenId screenId);
|
||||
void ChangeScreenDisplayModeToCoordination();
|
||||
void ChangeScreenDisplayModeProc(sptr<ScreenSession> screenSession, FoldDisplayMode displayMode);
|
||||
void RecoverWhenBootAnimationExit();
|
||||
void TriggerScreenDisplayModeUpdate(FoldDisplayMode displayMode);
|
||||
FoldDisplayMode GetModeMatchStatus();
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
static bool IsSupportRotateWithSensor();
|
||||
static std::string GetExternalScreenDefaultMode();
|
||||
static std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalConfig();
|
||||
static std::map<FoldDisplayMode, ScrollableParam> GetAllScrollableParam();
|
||||
|
||||
private:
|
||||
static std::map<int32_t, std::string> xmlNodeMap_;
|
||||
@ -59,6 +60,7 @@ private:
|
||||
static bool isScreenCompressionEnableInLandscape_;
|
||||
static uint32_t curvedAreaInLandscape_;
|
||||
static std::vector<DisplayPhysicalResolution> displayPhysicalResolution_;
|
||||
static std::map<FoldDisplayMode, ScrollableParam> scrollableParams_;
|
||||
|
||||
static bool IsValidNode(const xmlNode& currNode);
|
||||
static void ReadEnableConfigInfo(const xmlNodePtr& currNode);
|
||||
@ -72,6 +74,7 @@ private:
|
||||
static bool IsNumber(std::string str);
|
||||
static DMRect CalcCutoutBoundaryRect(const std::string svgPath);
|
||||
static void ReadPhysicalDisplayConfigInfo(const xmlNodePtr& currNode);
|
||||
static void ReadScrollableParam(const xmlNodePtr& currNode);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_SCREEN_SCENE_CONFIG_H
|
||||
|
@ -291,6 +291,7 @@ public:
|
||||
void NotifyCastWhenScreenConnectChange(bool isConnected);
|
||||
void MultiScreenModeChange(const std::string& mainScreenId, const std::string& secondaryScreenId,
|
||||
const std::string& secondaryScreenMode);
|
||||
void SwitchScrollParam(FoldDisplayMode displayMode);
|
||||
void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent);
|
||||
void SetCoordinationFlag(bool isCoordinationFlag);
|
||||
DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
|
||||
|
@ -130,6 +130,22 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode)
|
||||
}
|
||||
SetdisplayModeChangeStatus(true);
|
||||
ReportFoldDisplayModeChange(displayMode);
|
||||
ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode);
|
||||
ChangeScreenDisplayModeProc(screenSession, displayMode);
|
||||
if (currentDisplayMode_ != displayMode) {
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||
currentDisplayMode_ = displayMode;
|
||||
lastDisplayMode_ = displayMode;
|
||||
}
|
||||
SetdisplayModeChangeStatus(false);
|
||||
}
|
||||
|
||||
void DualDisplayFoldPolicy::ChangeScreenDisplayModeProc(sptr<ScreenSession> screenSession,
|
||||
FoldDisplayMode displayMode)
|
||||
{
|
||||
switch (displayMode) {
|
||||
case FoldDisplayMode::SUB: {
|
||||
ChangeScreenDisplayModeInner(screenSession, SCREEN_ID_MAIN, SCREEN_ID_SUB);
|
||||
@ -147,15 +163,6 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentDisplayMode_ != displayMode) {
|
||||
ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode);
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock_mode(displayModeMutex_);
|
||||
currentDisplayMode_ = displayMode;
|
||||
lastDisplayMode_ = displayMode;
|
||||
}
|
||||
SetdisplayModeChangeStatus(false);
|
||||
}
|
||||
|
||||
void DualDisplayFoldPolicy::SendSensorResult(FoldStatus foldStatus)
|
||||
|
@ -107,6 +107,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod
|
||||
}
|
||||
SetdisplayModeChangeStatus(true);
|
||||
ReportFoldDisplayModeChange(displayMode);
|
||||
ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode);
|
||||
switch (displayMode) {
|
||||
case FoldDisplayMode::MAIN: {
|
||||
ChangeScreenDisplayModeToMain(screenSession);
|
||||
|
@ -108,7 +108,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp
|
||||
return;
|
||||
}
|
||||
ReportFoldDisplayModeChange(displayMode);
|
||||
|
||||
ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode);
|
||||
ChangeScreenDisplayModeProc(screenSession, displayMode);
|
||||
|
||||
if (currentDisplayMode_ != displayMode) {
|
||||
|
@ -35,6 +35,7 @@ namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0;
|
||||
constexpr uint32_t DISPLAY_PHYSICAL_SIZE = 2;
|
||||
constexpr uint32_t SCROLLABLE_PARAM_SIZE = 2;
|
||||
enum XmlNodeElement {
|
||||
DPI = 0,
|
||||
SUB_DPI,
|
||||
@ -56,7 +57,8 @@ enum XmlNodeElement {
|
||||
EXTERNAL_SCREEN_DEFAULT_MODE,
|
||||
CAST_BUNDLE_NAME,
|
||||
CAST_ABILITY_NAME,
|
||||
PHYSICAL_DISPLAY_RESOLUTION
|
||||
PHYSICAL_DISPLAY_RESOLUTION,
|
||||
SCROLLABLE_PARAM
|
||||
};
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ std::map<std::string, std::string> ScreenSceneConfig::stringConfig_;
|
||||
std::map<std::string, std::vector<std::string>> ScreenSceneConfig::stringListConfig_;
|
||||
std::map<uint64_t, std::vector<DMRect>> ScreenSceneConfig::cutoutBoundaryRectMap_;
|
||||
std::vector<DisplayPhysicalResolution> ScreenSceneConfig::displayPhysicalResolution_;
|
||||
std::map<FoldDisplayMode, ScrollableParam> ScreenSceneConfig::scrollableParams_;
|
||||
std::vector<DMRect> ScreenSceneConfig::subCutoutBoundaryRect_;
|
||||
bool ScreenSceneConfig::isWaterfallDisplay_ = false;
|
||||
bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
|
||||
@ -91,7 +94,8 @@ std::map<int32_t, std::string> ScreenSceneConfig::xmlNodeMap_ = {
|
||||
{EXTERNAL_SCREEN_DEFAULT_MODE, "externalScreenDefaultMode"},
|
||||
{CAST_BUNDLE_NAME, "castBundleName"},
|
||||
{CAST_ABILITY_NAME, "castAbilityName"},
|
||||
{PHYSICAL_DISPLAY_RESOLUTION, "physicalDisplayResolution"}
|
||||
{PHYSICAL_DISPLAY_RESOLUTION, "physicalDisplayResolution"},
|
||||
{SCROLLABLE_PARAM, "scrollableParam"}
|
||||
};
|
||||
|
||||
|
||||
@ -198,6 +202,8 @@ void ScreenSceneConfig::ParseNodeConfig(const xmlNodePtr& currNode)
|
||||
ReadStringListConfigInfo(currNode, nodeName);
|
||||
} else if (xmlNodeMap_[PHYSICAL_DISPLAY_RESOLUTION] == nodeName) {
|
||||
ReadPhysicalDisplayConfigInfo(currNode);
|
||||
} else if (xmlNodeMap_[SCROLLABLE_PARAM] == nodeName) {
|
||||
ReadScrollableParam(currNode);
|
||||
} else {
|
||||
TLOGI(WmsLogTag::DMS, "xml config node name is not match, nodeName:%{public}s", nodeName.c_str());
|
||||
}
|
||||
@ -289,6 +295,56 @@ std::vector<DisplayPhysicalResolution> ScreenSceneConfig::GetAllDisplayPhysicalC
|
||||
return displayPhysicalResolution_;
|
||||
}
|
||||
|
||||
void ScreenSceneConfig::ReadScrollableParam(const xmlNodePtr& currNode)
|
||||
{
|
||||
xmlChar* displayModeXml = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
if (displayModeXml == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name);
|
||||
return;
|
||||
}
|
||||
xmlChar* displayModeContext = xmlNodeGetContent(currNode);
|
||||
if (displayModeContext == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "[SsConfig] read xml nodeName:(%{public}s) context null", currNode->name);
|
||||
xmlFree(displayModeXml);
|
||||
return;
|
||||
}
|
||||
std::string scrollableParamStr = reinterpret_cast<const char*>(displayModeContext);
|
||||
if (scrollableParamStr.empty()) {
|
||||
xmlFree(displayModeContext);
|
||||
xmlFree(displayModeXml);
|
||||
return;
|
||||
}
|
||||
auto scrollableParamArray = Split(scrollableParamStr, ":");
|
||||
if (scrollableParamArray.size() != SCROLLABLE_PARAM_SIZE) {
|
||||
xmlFree(displayModeContext);
|
||||
xmlFree(displayModeXml);
|
||||
return;
|
||||
}
|
||||
FoldDisplayMode foldDisplayMode;
|
||||
if (!xmlStrcmp(displayModeXml, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_FULL"))) {
|
||||
foldDisplayMode = FoldDisplayMode::FULL;
|
||||
} else if (!xmlStrcmp(displayModeXml, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_MAIN"))) {
|
||||
foldDisplayMode = FoldDisplayMode::MAIN;
|
||||
} else if (!xmlStrcmp(displayModeXml, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_SUB"))) {
|
||||
foldDisplayMode = FoldDisplayMode::SUB;
|
||||
} else if (!xmlStrcmp(displayModeXml, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_COORDINATION"))) {
|
||||
foldDisplayMode = FoldDisplayMode::COORDINATION;
|
||||
} else {
|
||||
foldDisplayMode = FoldDisplayMode::UNKNOWN;
|
||||
}
|
||||
ScrollableParam scrollableParam;
|
||||
scrollableParam.velocityScale_ = scrollableParamArray[0];
|
||||
scrollableParam.friction_ = scrollableParamArray[1];
|
||||
scrollableParams_[foldDisplayMode] = scrollableParam;
|
||||
xmlFree(displayModeContext);
|
||||
xmlFree(displayModeXml);
|
||||
}
|
||||
|
||||
std::map<FoldDisplayMode, ScrollableParam> ScreenSceneConfig::GetAllScrollableParam()
|
||||
{
|
||||
return scrollableParams_;
|
||||
}
|
||||
|
||||
void ScreenSceneConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode)
|
||||
{
|
||||
xmlChar* enable = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("enable"));
|
||||
|
@ -5626,6 +5626,17 @@ void ScreenSessionManager::MultiScreenModeChange(ScreenId mainScreenId, ScreenId
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSessionManager::SwitchScrollParam(FoldDisplayMode displayMode)
|
||||
{
|
||||
std::map<FoldDisplayMode, ScrollableParam> scrollableParams = ScreenSceneConfig::GetAllScrollableParam();
|
||||
std::string srollVelocityScale = scrollableParams.count(displayMode) != 0 ?
|
||||
scrollableParams[displayMode].velocityScale_ : "0";
|
||||
std::string srollFriction = scrollableParams.count(displayMode) != 0 ?
|
||||
scrollableParams[displayMode].friction_ : "0";
|
||||
system::SetParameter("persist.scrollable.velocityScale", srollVelocityScale);
|
||||
system::SetParameter("persist.scrollable.friction", srollFriction);
|
||||
}
|
||||
|
||||
void ScreenSessionManager::MultiScreenModeChange(const std::string& firstScreenIdStr,
|
||||
const std::string& secondaryScreenIdStr, const std::string& secondaryChandeMode)
|
||||
{
|
||||
|
@ -444,6 +444,7 @@ ohos_unittest("ws_screen_session_manager_test") {
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -753,6 +753,131 @@ HWTEST_F(ScreenSceneConfigTest, ReadPhysicalDisplayConfigInfo08, Function | Smal
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_FULL:abc:def"));
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam01
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam01, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam02
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam02, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_FULL:1.5:0.5"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam03
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam03, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_MAIN:1.5:0.5"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam04
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam04, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_SUB:1.5:0.5"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam05
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam05, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("UNKNOWN:1.5:0.5"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam06
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam06, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_FULL:1.5:"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam07
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam07, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>(" "));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam08
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam08, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("UNKNOWN:!!:aa"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadScrollableParam09
|
||||
* @tc.desc: ReadScrollableParam
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSceneConfigTest, ReadScrollableParam09, Function | SmallTest | Level3)
|
||||
{
|
||||
xmlNodePtr currNode = xmlNewNode(nullptr, reinterpret_cast<const xmlChar*>("displayMode"));
|
||||
ASSERT_NE(currNode, nullptr);
|
||||
xmlNodeSetContent(currNode, reinterpret_cast<const xmlChar*>("FOLD_DISPLAY_MODE_COORDINATION:1.5:0.5"));
|
||||
ScreenSceneConfig::ReadScrollableParam(currNode);
|
||||
xmlFreeNode(currNode);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
148
window_scene/test/dms_unittest/screen_session_manager_test2.cpp
Normal file
148
window_scene/test/dms_unittest/screen_session_manager_test2.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <parameter.h>
|
||||
#include <parameters.h>
|
||||
|
||||
#include "screen_session_manager/include/screen_session_manager.h"
|
||||
#include "screen_scene_config.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms
|
||||
}
|
||||
class ScreenSessionManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
static sptr<ScreenSessionManager> ssm_;
|
||||
};
|
||||
|
||||
sptr<ScreenSessionManager> ScreenSessionManagerTest::ssm_ = nullptr;
|
||||
|
||||
void ScreenSessionManagerTest::SetUpTestCase()
|
||||
{
|
||||
ssm_ = new ScreenSessionManager();
|
||||
}
|
||||
|
||||
void ScreenSessionManagerTest::TearDownTestCase()
|
||||
{
|
||||
ssm_ = nullptr;
|
||||
}
|
||||
|
||||
void ScreenSessionManagerTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenSessionManagerTest::TearDown()
|
||||
{
|
||||
usleep(SLEEP_TIME_IN_US);
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: SwitchScrollParam01
|
||||
* @tc.desc: SwitchScrollParam test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSessionManagerTest, SwitchScrollParam01, Function | SmallTest | Level3)
|
||||
{
|
||||
ScreenSceneConfig::scrollableParams_.clear();
|
||||
vector<FoldDisplayMode> displayModeALL = {
|
||||
FoldDisplayMode::SUB,
|
||||
FoldDisplayMode::MAIN,
|
||||
FoldDisplayMode::FULL,
|
||||
FoldDisplayMode::UNKNOWN,
|
||||
FoldDisplayMode::COORDINATION,
|
||||
};
|
||||
std::map<FoldDisplayMode, std::string> scrollVelocityScaleParam = {
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::SUB, "1.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::MAIN, "1.1"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::FULL, "1.2"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::UNKNOWN, "1.3"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::COORDINATION, "1.4")
|
||||
};
|
||||
std::map<FoldDisplayMode, std::string> scrollFrictionParam = {
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::SUB, "1.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::MAIN, "2.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::FULL, "3.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::UNKNOWN, "4.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::COORDINATION, "5.0"),
|
||||
};
|
||||
ScreenSessionManager* ssm = new ScreenSessionManager();
|
||||
ASSERT_NE(ssm, nullptr);
|
||||
std::string ret1, ret2;
|
||||
for (FoldDisplayMode displayMode : displayModeALL) {
|
||||
ScrollableParam scrollableParam;
|
||||
scrollableParam.velocityScale_ = scrollVelocityScaleParam.count(displayMode) ?
|
||||
scrollVelocityScaleParam[displayMode] : "";
|
||||
scrollableParam.friction_ = scrollFrictionParam.count(displayMode) ?
|
||||
scrollFrictionParam[displayMode] : "";
|
||||
ssm->SwitchScrollParam(displayMode);
|
||||
ret1 = system::GetParameter("persist.scrollable.velocityScale", "0");
|
||||
ret2 = system::GetParameter("persist.scrollable.friction", "0");
|
||||
EXPECT_EQ(ret1, scrollVelocityScaleParam[displayMode]);
|
||||
EXPECT_EQ(ret2, scrollFrictionParam[displayMode]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SwitchScrollParam02
|
||||
* @tc.desc: SwitchScrollParam test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenSessionManagerTest, SwitchScrollParam02, Function | SmallTest | Level3)
|
||||
{
|
||||
ScreenSceneConfig::scrollableParams_.clear();
|
||||
vector<FoldDisplayMode> displayModeALL = {
|
||||
FoldDisplayMode::SUB,
|
||||
FoldDisplayMode::MAIN,
|
||||
FoldDisplayMode::FULL,
|
||||
FoldDisplayMode::UNKNOWN,
|
||||
FoldDisplayMode::COORDINATION,
|
||||
};
|
||||
std::map<FoldDisplayMode, std::string> scrollVelocityScaleParam = {
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::FULL, "2.0"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::MAIN, "main"),
|
||||
pair<FoldDisplayMode, std::string>(FoldDisplayMode::UNKNOWN, "!!"),
|
||||
};
|
||||
std::map<FoldDisplayMode, std::string> scrollFrictionParam;
|
||||
ScreenSessionManager* ssm = new ScreenSessionManager();
|
||||
ASSERT_NE(ssm, nullptr);
|
||||
std::string ret1, ret2;
|
||||
for (FoldDisplayMode displayMode : displayModeALL) {
|
||||
ScrollableParam scrollableParam;
|
||||
scrollableParam.velocityScale_ = scrollVelocityScaleParam.count(displayMode) ?
|
||||
scrollVelocityScaleParam[displayMode] : "";
|
||||
scrollableParam.friction_ = scrollFrictionParam.count(displayMode) ?
|
||||
scrollFrictionParam[displayMode] : "";
|
||||
ssm->SwitchScrollParam(displayMode);
|
||||
ret1 = system::GetParameter("persist.scrollable.velocityScale", "0");
|
||||
ret2 = system::GetParameter("persist.scrollable.friction", "0");
|
||||
EXPECT_EQ(ret1, scrollVelocityScaleParam[displayMode]);
|
||||
EXPECT_EQ(ret2, scrollFrictionParam[displayMode]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user