测试用例的修复

Signed-off-by: 张有康 <zhangyoukang@h-partners.com>
This commit is contained in:
张有康 2024-05-27 14:51:26 +08:00
parent 503dcdd235
commit 6eca75e13a
3 changed files with 6 additions and 2 deletions

View File

@ -26,6 +26,7 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using Mocker = SingletonMocker<DisplayManagerAdapter, MockDisplayManagerAdapter>;
using ScreenMocker = SingletonMocker<ScreenManagerAdapter, MockScreenManagerAdapter>;
class DisplayTest : public testing::Test {
public:
static void SetUpTestCase();
@ -231,7 +232,7 @@ HWTEST_F(DisplayTest, GetAvailableArea, Function | SmallTest | Level1)
*/
HWTEST_F(DisplayTest, GetSupportedHDRFormats, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
std::unique_ptr<ScreenMocker> m = std::make_unique<ScreenMocker>();
EXPECT_CALL(m->Mock(), GetSupportedHDRFormats(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
std::vector<uint32_t> hdrFormats;
auto res = defaultDisplay_ ->GetSupportedHDRFormats(hdrFormats);
@ -245,7 +246,7 @@ HWTEST_F(DisplayTest, GetSupportedHDRFormats, Function | SmallTest | Level1)
*/
HWTEST_F(DisplayTest, GetSupportedColorSpaces, Function | SmallTest | Level1)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
std::unique_ptr<ScreenMocker> m = std::make_unique<ScreenMocker>();
EXPECT_CALL(m->Mock(), GetSupportedColorSpaces(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
std::vector<uint32_t> colorSpaces;
auto res = defaultDisplay_ -> GetSupportedColorSpaces(colorSpaces);

View File

@ -402,6 +402,8 @@ HWTEST_F(ScreenTest, SetDensityDpi, Function | SmallTest | Level2)
*/
HWTEST_F(ScreenTest, SetResolution, Function | SmallTest | Level2)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), SetResolution(_, _, _, _)).Times(1).WillOnce(Return(DMError::DM_OK));
auto res = screen_->SetResolution(0, 0, 1000);
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, res);

View File

@ -90,6 +90,7 @@ public:
MOCK_METHOD1(RemoveVirtualScreenFromGroup, void(std::vector<ScreenId> screens));
MOCK_METHOD1(SetScreenRotationLocked, DMError(bool isLocked));
MOCK_METHOD1(IsScreenRotationLocked, DMError(bool& isLocked));
MOCK_METHOD4(SetResolution, DMError(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio));
};
}
} // namespace OHOS