Signed-off-by: z30042987 <zhouminghui8@huawei.com>
This commit is contained in:
z30042987 2023-08-29 09:50:49 +08:00
parent f38edb4a6d
commit 585db6727f

View File

@ -15,114 +15,128 @@
// gtest
#include <gtest/gtest.h>
#include "avoid_area_controller.h"
#include "window_manager.h"
#include "window_test_utils.h"
#include "wm_common.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using Utils = WindowTestUtils;
class WindowSplitImmersiveTest : public testing::Test {
class WindowMultiAbilityTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp() override;
virtual void TearDown() override;
void IsShowTopBar(const sptr<Window>& top, bool isShow);
void HideAndUnregister(const sptr<Window>& fullWindow, const sptr<Window>& priWindow, const sptr<Window>& top);
std::vector<sptr<Window>> activeWindows_;
Utils::TestWindowInfo fullInfo_;
Utils::TestWindowInfo splitInfo_;
private:
static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time
};
void WindowSplitImmersiveTest::SetUpTestCase()
void WindowMultiAbilityTest::SetUpTestCase()
{
}
void WindowSplitImmersiveTest::TearDownTestCase()
void WindowMultiAbilityTest::TearDownTestCase()
{
}
void WindowSplitImmersiveTest::SetUp()
void WindowMultiAbilityTest::SetUp()
{
fullInfo_ = {
.name = "fullscreen.1",
.rect = Utils::customAppRect_,
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
.needAvoid = true,
.parentLimit = false,
.parentId = INVALID_WINDOW_ID,
};
splitInfo_ = {
.name = "primary.1",
.rect = Utils::customAppRect_,
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
.needAvoid = true,
.parentLimit = false,
.parentId = INVALID_WINDOW_ID,
};
activeWindows_.clear();
}
void WindowSplitImmersiveTest::TearDown()
void WindowMultiAbilityTest::TearDown()
{
while (!activeWindows_.empty()) {
ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy());
activeWindows_.pop_back();
}
}
namespace {
/**
* @tc.name: SplitImmersive01
* @tc.desc: one primary window and one fullscreen window, test enter and out split immersive
* @tc.name: MultiAbilityWindow01
* @tc.desc: Five scene process in one thread
* @tc.type: FUNC
*/
HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Level3)
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, Function | MediumTest | Level2)
{
// create fullscreen win and show
fullInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
if (fullWindow == nullptr) {
return;
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
}
activeWindows_.push_back(fullWindow);
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
sleep(SPLIT_TEST_SLEEP_S);
/**
* @tc.name: MultiAbilityWindow04
* @tc.desc: Five scene process in one thread, create/show/hide/destroy in order
* @tc.type: FUNC
*/
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow02, Function | MediumTest | Level3)
{
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
// enter split mode
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
activeWindows_.push_back(priWindow);
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
sleep(SPLIT_TEST_SLEEP_S);
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
// check is enter split Immersive
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode());
Rect immersivePriRect = priWindow->GetRect();
ASSERT_EQ(0, immersivePriRect.posX_);
ASSERT_EQ(0, immersivePriRect.posY_);
sleep(SPLIT_TEST_SLEEP_S);
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
sleep(SPLIT_TEST_SLEEP_S);
ASSERT_EQ(WMError::WM_OK, priWindow->Hide());
sleep(SPLIT_TEST_SLEEP_S);
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
}
/**
* @tc.name: MultiAbilityWindow05
* @tc.desc: Five scene process in one thread, create/show/hide/destroy out of order
* @tc.type: FUNC
*/
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | Level3)
{
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
}
} // namespace Rosen
} // namespace OHOS