mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-28 01:21:13 +00:00
Modify display_change systemtest and code check
Signed-off-by: shiyueeee <nieshiyue@huawei.com> Change-Id: I6f9766093de0aff24fe1009897f1a4f68fd3fa51
This commit is contained in:
parent
9f380b9afe
commit
48c518839e
@ -372,8 +372,7 @@ void DisplayManager::NotifyDisplayStateChanged(DisplayId id, DisplayState state)
|
||||
|
||||
void DisplayManager::NotifyDisplayChangedEvent(const sptr<DisplayInfo> info, DisplayChangeEvent event)
|
||||
{
|
||||
WLOGI("NotifyDisplayChangedEvent event:%{public}u, size:%{public}zu", event,
|
||||
pImpl_->displayListeners_.size());
|
||||
WLOGI("NotifyDisplayChangedEvent event:%{public}u, size:%{public}zu", event, pImpl_->displayListeners_.size());
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
for (auto& listener : pImpl_->displayListeners_) {
|
||||
listener->OnChange(info->id_, event);
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
bool CheckDisplayChangeEventCallback(bool valueExpected);
|
||||
bool ScreenSizeEqual(const sptr<Screen> screen, const sptr<SupportedScreenModes> curInfo);
|
||||
bool DisplaySizeEqual(const sptr<Display> display, const sptr<SupportedScreenModes> curInfo);
|
||||
inline bool CheckModeSizeChange(const sptr<SupportedScreenModes> usedInfo,
|
||||
const sptr<SupportedScreenModes> curInfo) const;
|
||||
|
||||
static DisplayId defaultDisplayId_;
|
||||
static sptr<DisplayChangeEventListener> listener_;
|
||||
@ -141,6 +143,13 @@ bool DisplayChangeTest::DisplaySizeEqual(const sptr<Display> display, const sptr
|
||||
return ((curInfo->width_ == dWidth) && (curInfo->height_ == dHeight));
|
||||
}
|
||||
|
||||
|
||||
inline bool DisplayChangeTest::CheckModeSizeChange(const sptr<SupportedScreenModes> usedInfo,
|
||||
const sptr<SupportedScreenModes> curInfo) const
|
||||
{
|
||||
return (usedInfo->width_ != curInfo->width_ || usedInfo->height_ != curInfo->height_);
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: RegisterDisplayChangeListener01
|
||||
@ -233,13 +242,14 @@ HWTEST_F(DisplayChangeTest, CheckDisplayStateChange02, Function | SmallTest | Le
|
||||
ASSERT_NE(nullptr, screen);
|
||||
auto modes = screen->GetSupportedModes();
|
||||
uint32_t usedModeIdx = screen->GetModeId();
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}d", usedModeIdx, static_cast<int>(modes.size()));
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}zu", usedModeIdx, modes.size());
|
||||
|
||||
for (uint32_t modeIdx = 0; modeIdx < modes.size(); modeIdx++) {
|
||||
if (modeIdx != usedModeIdx) {
|
||||
if (modeIdx != usedModeIdx && CheckModeSizeChange(modes[usedModeIdx], modes[modeIdx])) {
|
||||
screen->SetScreenActiveMode(modeIdx);
|
||||
WLOGFI("SetScreenActiveMode: %{public}u", modeIdx);
|
||||
ASSERT_EQ(true, CheckDisplayChangeEventCallback(true));
|
||||
ASSERT_EQ(defaultDisplayId_, listener_->displayId_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -264,10 +274,10 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange01, Function | MediumTest | Le
|
||||
ASSERT_NE(nullptr, screen);
|
||||
auto modes = screen->GetSupportedModes();
|
||||
uint32_t usedModeIdx = screen->GetModeId();
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}d", usedModeIdx, static_cast<int>(modes.size()));
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}zu", usedModeIdx, modes.size());
|
||||
|
||||
for (uint32_t modeIdx = 0; modeIdx < modes.size(); modeIdx++) {
|
||||
if (modeIdx != usedModeIdx) {
|
||||
if (modeIdx != usedModeIdx && CheckModeSizeChange(modes[usedModeIdx], modes[modeIdx])) {
|
||||
screen->SetScreenActiveMode(modeIdx);
|
||||
WLOGFI("SetScreenActiveMode: %{public}u -> %{public}u", usedModeIdx, modeIdx);
|
||||
ASSERT_EQ(true, ScreenSizeEqual(screen, modes[modeIdx]));
|
||||
@ -289,17 +299,17 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange01, Function | MediumTest | Le
|
||||
*/
|
||||
HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange02, Function | MediumTest | Level2)
|
||||
{
|
||||
WLOGFI("CheckDisplaySizeChange01");
|
||||
WLOGFI("CheckDisplaySizeChange02");
|
||||
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
|
||||
ScreenId screenId = defaultDisplay->GetScreenId();
|
||||
sptr<Screen> screen = ScreenManager::GetInstance().GetScreenById(screenId);
|
||||
ASSERT_NE(nullptr, screen);
|
||||
auto modes = screen->GetSupportedModes();
|
||||
uint32_t usedModeIdx = screen->GetModeId();
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}d", usedModeIdx, static_cast<int>(modes.size()));
|
||||
WLOGFI("usedModeIdx / SupportMode size: %{public}u %{public}zu", usedModeIdx, modes.size());
|
||||
|
||||
for (uint32_t modeIdx = 0; modeIdx < modes.size(); modeIdx++) {
|
||||
if (modeIdx != usedModeIdx) {
|
||||
if (modeIdx != usedModeIdx && CheckModeSizeChange(modes[usedModeIdx], modes[modeIdx])) {
|
||||
screen->SetScreenActiveMode(modeIdx);
|
||||
WLOGFI("SetScreenActiveMode: %{public}u -> %{public}u", usedModeIdx, modeIdx);
|
||||
ASSERT_EQ(true, CheckDisplayChangeEventCallback(true));
|
||||
|
@ -267,13 +267,6 @@ void AbstractScreenController::ProcessScreenModeChanged(ScreenId rsScreenId)
|
||||
// if not, the recursive_mutex should be added
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
sptr<AbstractScreen> absScreen = dmsScreenMapIter->second;
|
||||
int32_t activeModeId = rsInterface_.GetScreenActiveMode(rsScreenId).GetScreenModeId();
|
||||
if (activeModeId < 0 || activeModeId >= absScreen->modes_.size()) {
|
||||
WLOGE("activeModeId exceed, screenId=%{public}" PRIu64", activeModeId:%{public}d/%{public}u",
|
||||
rsScreenId, activeModeId, static_cast<uint32_t>(absScreen->modes_.size()));
|
||||
return;
|
||||
}
|
||||
absScreen->activeIdx_ = activeModeId;
|
||||
if (abstractScreenCallback_ != nullptr) {
|
||||
abstractScreenCallback_->onChange_(absScreen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user