!1394 Add UT for getCutoutInfo

Merge pull request !1394 from X PN/dev-cutout
This commit is contained in:
openharmony_ci 2022-08-22 04:15:11 +00:00 committed by Gitee
commit a1dd810346
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 111 additions and 0 deletions

View File

@ -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

View 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

View 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

View File

@ -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 {