mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
ut and st for window effect
Signed-off-by: luwei <luwei51@huawei.com> Change-Id: I0b91bd03e4508764202638a381fa94795599f6d7
This commit is contained in:
@@ -19,6 +19,7 @@ group("systemtest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":wm_window_effect_test",
|
||||
":wm_window_focus_test",
|
||||
":wm_window_gamut_test",
|
||||
":wm_window_immersive_test",
|
||||
@@ -42,6 +43,17 @@ ohos_systemtest("wm_window_layout_test") {
|
||||
|
||||
## SystemTest wm_window_layout_test }}}
|
||||
|
||||
## SystemTest wm_window_effect_test {{{
|
||||
ohos_systemtest("wm_window_effect_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_effect_test.cpp" ]
|
||||
|
||||
deps = [ ":wm_systemtest_common" ]
|
||||
}
|
||||
|
||||
## SystemTest wm_window_effect_test }}}
|
||||
|
||||
## SystemTest wm_window_multi_ability_test {{{
|
||||
ohos_systemtest("wm_window_multi_ability_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
#include "window_test_utils.h"
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
class WindowEffectTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
};
|
||||
|
||||
void WindowEffectTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowEffectTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowEffectTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
}
|
||||
|
||||
void WindowEffectTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowEffect01
|
||||
* @tc.desc: SetWindowBackgroundBlur | GetWindowBackgroundBlur
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW));
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect02
|
||||
* @tc.desc: SetAlpha | GetAlpha
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetAlpha(1.0f));
|
||||
ASSERT_EQ(1.0f, window->GetAlpha());
|
||||
|
||||
window->Destroy();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -20,6 +20,7 @@ group("unittest") {
|
||||
deps = [
|
||||
":avoid_area_controller_test",
|
||||
":wm_input_transfer_station_test",
|
||||
":wm_window_effect_test",
|
||||
":wm_window_impl_test",
|
||||
":wm_window_input_channel_test",
|
||||
":wm_window_option_test",
|
||||
@@ -51,6 +52,17 @@ ohos_unittest("wm_window_impl_test") {
|
||||
|
||||
## UnitTest wm_window_impl_test }}}
|
||||
|
||||
## UnitTest wm_window_effect_test {{{
|
||||
ohos_unittest("wm_window_effect_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_effect_test.cpp" ]
|
||||
|
||||
deps = [ ":wm_unittest_common" ]
|
||||
}
|
||||
|
||||
## UnitTest wm_window_effect_test }}}
|
||||
|
||||
## UnitTest wm_input_transfer_station_test {{{
|
||||
ohos_unittest("wm_input_transfer_station_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
MOCK_METHOD1(RemoveWindow, WMError(uint32_t windowId));
|
||||
MOCK_METHOD0(ClearWindowAdapter, void());
|
||||
MOCK_METHOD1(DestroyWindow, WMError(uint32_t windowId));
|
||||
MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level));
|
||||
MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha));
|
||||
MOCK_METHOD2(SaveAbilityToken, WMError(const sptr<IRemoteObject>& abilityToken, uint32_t windowId));
|
||||
MOCK_METHOD3(SetSystemBarProperty, WMError(uint32_t windowId, WindowType type, const SystemBarProperty& property));
|
||||
};
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "window_effect_test.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
void WindowEffectTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowEffectTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowEffectTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowEffectTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowEffect01
|
||||
* @tc.desc: windowOption: set window background blur / get window background blur
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW);
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, option->GetWindowBackgroundBlur());
|
||||
option->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_MEDIUM);
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_MEDIUM, option->GetWindowBackgroundBlur());
|
||||
option->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_HIGH);
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_HIGH, option->GetWindowBackgroundBlur());
|
||||
option->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_OFF);
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_OFF, option->GetWindowBackgroundBlur());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect02
|
||||
* @tc.desc: windowOption: set window alpha/ get window alpha
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetAlpha(0.0f);
|
||||
ASSERT_EQ(0.0f, option->GetAlpha());
|
||||
option->SetAlpha(0.5f);
|
||||
ASSERT_EQ(0.5f, option->GetAlpha());
|
||||
option->SetAlpha(1.0f);
|
||||
ASSERT_EQ(1.0f, option->GetAlpha());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect03
|
||||
* @tc.desc: WindowImp: Create window with no default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect04
|
||||
* @tc.desc: Create window with no default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetAlpha(0.1f);
|
||||
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
|
||||
ASSERT_EQ(0.1f, window->GetAlpha());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect05
|
||||
* @tc.desc: set window effect parameters throw window, and check parameters.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
|
||||
EXPECT_CALL(m->Mock(), SetWindowBackgroundBlur(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW));
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect06
|
||||
* @tc.desc: set window effect parameters throw window, and check parameters.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect06, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), SetAlpha(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.1f));
|
||||
ASSERT_EQ(0.1f, window->GetAlpha());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect07
|
||||
* @tc.desc: WindowImp: Create window with default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect07, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_OFF, window->GetWindowBackgroundBlur());
|
||||
ASSERT_EQ(1.0f, window->GetAlpha());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_WM_TEST_UT_WINDOW_Effect_TEST_H
|
||||
#define FRAMEWORKS_WM_TEST_UT_WINDOW_Effect_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "mock_window_adapter.h"
|
||||
#include "singleton_mocker.h"
|
||||
#include "window_impl.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
|
||||
class WindowEffectTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
};
|
||||
} // namespace ROSEN
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FRAMEWORKS_WM_TEST_UT_WINDOW_Effect_TEST_H
|
||||
@@ -257,7 +257,6 @@ WMError WindowController::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurL
|
||||
if (srcLevel == dstLevel) {
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
node->SetWindowBackgroundBlur(dstLevel);
|
||||
|
||||
FlushWindowInfo(windowId);
|
||||
return WMError::WM_OK;
|
||||
|
||||
Reference in New Issue
Block a user