!2416 修改用例Part2

Merge pull request !2416 from 张凯/fix_some_tdds_part2
This commit is contained in:
openharmony_ci 2023-03-30 03:42:23 +00:00 committed by Gitee
commit b8f3a902eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 23 additions and 34 deletions

View File

@ -533,6 +533,12 @@ HWTEST_F(ScreenRotationControllerTest, SubscribeMotionSensor, Function | SmallTe
*/
HWTEST_F(ScreenRotationControllerTest, OnMotionChanged, Function | SmallTest | Level3)
{
bool needUnsubscribe = false;
if (MotionSubscriber::motionEventCallback_ == nullptr) {
needUnsubscribe = true;
MotionSubscriber::SubscribeMotionSensor();
}
ASSERT_NE(MotionSubscriber::motionEventCallback_, nullptr);
DeviceRotation currentRotation = ScreenRotationController::lastSensorRotationConverted_;
DeviceRotation motionRotation = DeviceRotation::INVALID;
@ -566,6 +572,10 @@ HWTEST_F(ScreenRotationControllerTest, OnMotionChanged, Function | SmallTest | L
ASSERT_EQ(motionRotation, ScreenRotationController::lastSensorRotationConverted_);
ScreenRotationController::HandleSensorEventInput(currentRotation);
if (needUnsubscribe) {
MotionSubscriber::UnsubscribeMotionSensor();
}
}
#endif
}

View File

@ -242,7 +242,7 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
// 5:rect.posX_, 110:rect.posY_, 655:rect.width, 500:rect.height
sptr<Window> window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING,
Rect { 0, 0, displayWidth, displayHeight / 2 }, 0xff00ff00);
Rect { 0, 0, displayWidth, displayHeight / 2}, 0xff00ff00);
ASSERT_NE(nullptr, window3);
sleep(WAIT_FOR_SYNC_US);
window3->MoveTo(45, 115);
@ -250,7 +250,7 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
// 5:rect.posX_, 300:rect.posY_, 655:rect.width, 500:rect.height
sptr<Window> window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING,
Rect { 0, 0, displayWidth, displayHeight / 2 }, 0xff00ff00);
Rect { 0, 0, displayWidth, displayHeight / 2 + 200 }, 0xff00ff00);
ASSERT_NE(nullptr, window4);
window4->MoveTo(45, displayHeight / 2 - 95);

View File

@ -179,6 +179,7 @@ bool WindowImmersiveTest::SystemBarEnableState(bool expectStatus, bool expectNav
void TestSystemBarChangedListener::OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints)
{
WLOGI("TestSystemBarChangedListener Display ID: %{public}" PRIu64"", displayId);
WLOGI("TestSystemBarChangedListener tints size: %{public}zu", tints.size());
for (auto tint : tints) {
auto type = tint.type_;
for (uint32_t i = 0; i < tints_.size(); i++) {
@ -234,6 +235,7 @@ void WindowImmersiveTest::SetUp()
WindowManager::GetInstance().RegisterSystemBarChangedListener(testSystemBarChangedListener_);
activeWindows_.clear();
sleep(1);
}
void WindowImmersiveTest::TearDown()
@ -243,6 +245,7 @@ void WindowImmersiveTest::TearDown()
activeWindows_.pop_back();
}
WindowManager::GetInstance().UnregisterSystemBarChangedListener(testSystemBarChangedListener_);
sleep(1);
}
namespace {

View File

@ -30,7 +30,6 @@ public:
virtual void SetUp() override;
virtual void TearDown() override;
Utils::TestWindowInfo inputMethodWindowInfo_;
Utils::TestWindowInfo keyGuardWindowInfo_;
};
void WindowInputMethodTest::SetUpTestCase()
@ -54,15 +53,7 @@ void WindowInputMethodTest::SetUp()
.mode = WindowMode::WINDOW_MODE_FLOATING,
.needAvoid = false,
.parentLimit = false,
.parentId = INVALID_WINDOW_ID,
};
keyGuardWindowInfo_ = {
.name = "",
.rect = Utils::customAppRect_,
.type = WindowType::WINDOW_TYPE_KEYGUARD,
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
.needAvoid = false,
.parentLimit = false,
.showWhenLocked = true,
.parentId = INVALID_WINDOW_ID,
};
}
@ -88,34 +79,17 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Lev
/**
* @tc.name: InputMethodWindow02
* @tc.desc: One KeyGuard Window
* @tc.desc: One InputMethod Floating Window & One KeyGuard Window
* @tc.type: FUNC
*/
HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3)
{
keyGuardWindowInfo_.name = "keyGuard.1";
const sptr<Window>& window = Utils::CreateTestWindow(keyGuardWindowInfo_);
ASSERT_EQ(WindowType::WINDOW_TYPE_KEYGUARD, window->GetType());
ASSERT_EQ(WMError::WM_OK, window->Show());
ASSERT_EQ(WMError::WM_OK, window->Hide());
}
/**
* @tc.name: InputMethodWindow03
* @tc.desc: One InputMethod Floating Window & One KeyGuard Window
* @tc.type: FUNC
*/
HWTEST_F(WindowInputMethodTest, InputMethodWindow03, Function | MediumTest | Level3)
{
inputMethodWindowInfo_.name = "input_method.2";
keyGuardWindowInfo_.name = "keyGuard.2";
const sptr<Window>& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_);
const sptr<Window>& keyGuardWindow = Utils::CreateTestWindow(keyGuardWindowInfo_);
keyGuardWindow->Show();
inputMethodWindow->Show();
ASSERT_TRUE(Utils::RectEqualTo(keyGuardWindow, Utils::displayRect_));
ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_);
ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_);
inputMethodWindow->Hide();
}
} // namespace
} // namespace Rosen

View File

@ -148,7 +148,6 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow02, Function | MediumTest | L
WindowType::WINDOW_TYPE_TOAST,
WindowType::WINDOW_TYPE_STATUS_BAR,
WindowType::WINDOW_TYPE_PANEL,
WindowType::WINDOW_TYPE_KEYGUARD,
WindowType::WINDOW_TYPE_VOLUME_OVERLAY,
WindowType::WINDOW_TYPE_NAVIGATION_BAR,
WindowType::WINDOW_TYPE_DRAGGING_EFFECT,

View File

@ -69,6 +69,7 @@ public:
static sptr<TestIWaterMarkFlagChangedListener> lisenter_;
Utils::TestWindowInfo appInfo_;
sptr<Window> CreateWindow(const Utils::TestWindowInfo& appinfo);
static inline DisplayId displayId_;
};
sptr<TestIWaterMarkFlagChangedListener> WaterMarkTest::lisenter_ = nullptr;
@ -76,6 +77,7 @@ void WaterMarkTest::SetUpTestCase()
{
lisenter_= new TestIWaterMarkFlagChangedListener();
WindowManager::GetInstance().RegisterWaterMarkFlagChangedListener(lisenter_);
displayId_ = DisplayManager::GetInstance().GetDefaultDisplayId();
}
void WaterMarkTest::TearDownTestCase()
@ -104,6 +106,7 @@ void WaterMarkTest::TearDown()
sptr<Window> WaterMarkTest::CreateWindow(const Utils::TestWindowInfo& appinfo)
{
sptr<WindowOption> option = new WindowOption();
option->SetDisplayId(displayId_);
option->SetWindowRect(appinfo.rect);
option->SetWindowType(appinfo.type);
option->SetWindowMode(appinfo.mode);
@ -138,7 +141,7 @@ namespace {
HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, Function | MediumTest | Level1)
{
appInfo_.name = "window1";
appInfo_.rect = {0, 0, 300, 100};
appInfo_.rect = {200, 200, 300, 300};
sptr<Window> window = CreateWindow(appInfo_);
ASSERT_NE(window, nullptr);
window->Show();
@ -148,7 +151,7 @@ HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, Function | MediumTest | Level1)
ASSERT_TRUE(drawSuccess);
window->AddWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK);
sleep(NORMAL_SLEEP_TIME);
sleep(NORMAL_SLEEP_TIME * 30);
ASSERT_EQ(lisenter_->isShowing_, true);
window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK);