mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-17 14:30:02 +00:00
!1394 Add UT for getCutoutInfo
Merge pull request !1394 from X PN/dev-cutout
This commit is contained in:
commit
a1dd810346
@ -21,12 +21,21 @@ group("unittest") {
|
||||
deps = [
|
||||
":dm_display_change_unit_test",
|
||||
":dm_display_power_unit_test",
|
||||
":dm_display_test",
|
||||
":dm_screen_manager_test",
|
||||
":dm_screen_test",
|
||||
":dm_screenshot_test",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("dm_display_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "display_test.cpp" ]
|
||||
|
||||
deps = [ ":dm_unittest_common" ]
|
||||
}
|
||||
|
||||
ohos_unittest("dm_display_change_unit_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
|
63
dm/test/unittest/display_test.cpp
Normal file
63
dm/test/unittest/display_test.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 "display_test.h"
|
||||
#include "mock_display_manager_adapter.h"
|
||||
#include "singleton_mocker.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Mocker = SingletonMocker<DisplayManagerAdapter, MockDisplayManagerAdapter>;
|
||||
|
||||
sptr<Display> DisplayTest::defaultDisplay_ = nullptr;
|
||||
DisplayId DisplayTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
|
||||
|
||||
void DisplayTest::SetUpTestCase()
|
||||
{
|
||||
defaultDisplay_ = DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
defaultDisplayId_ = static_cast<DisplayId>(defaultDisplay_->GetId());
|
||||
}
|
||||
|
||||
void DisplayTest::TearDownTestCase()
|
||||
{
|
||||
defaultDisplay_ = nullptr;
|
||||
}
|
||||
|
||||
void DisplayTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void DisplayTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: GetCutoutInfo01
|
||||
* @tc.desc: GetCutoutInfo with valid defaultDisplayId and return success
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5K0JP
|
||||
*/
|
||||
HWTEST_F(DisplayTest, GetCutoutInfo01, Function | SmallTest | Level1)
|
||||
{
|
||||
auto cutoutInfo = defaultDisplay_->GetCutoutInfo();
|
||||
ASSERT_NE(nullptr, cutoutInfo);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
38
dm/test/unittest/display_test.h
Normal file
38
dm/test/unittest/display_test.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_DM_TEST_UT_DISPLAY_TEST_H
|
||||
#define FRAMEWORKS_DM_TEST_UT_DISPLAY_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "display.h"
|
||||
#include "display_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DisplayTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
static sptr<Display> defaultDisplay_;
|
||||
static DisplayId defaultDisplayId_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FRAMEWORKS_DM_TEST_UT_DISPLAY_TEST_H
|
@ -40,6 +40,7 @@ public:
|
||||
MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId));
|
||||
MOCK_METHOD1(NotifyDisplayEvent, void(DisplayEvent event));
|
||||
MOCK_METHOD1(GetDisplayInfo, sptr<DisplayInfo>(DisplayId displayId));
|
||||
MOCK_METHOD1(GetCutoutInfo, sptr<CutoutInfo>(DisplayId displayId));
|
||||
};
|
||||
|
||||
class MockScreenManagerAdapter : public ScreenManagerAdapter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user