desktop/reserved: fix a possible reserved crash (#13207)
This commit is contained in:
parent
ff061d177e
commit
339661229d
2 changed files with 16 additions and 1 deletions
|
|
@ -16,7 +16,8 @@ CReservedArea::CReservedArea(double top, double right, double bottom, double lef
|
|||
}
|
||||
|
||||
CReservedArea::CReservedArea(const CBox& parent, const CBox& child) {
|
||||
ASSERT(!parent.empty() && !child.empty());
|
||||
if (parent.empty() || child.empty())
|
||||
return; // empty reserved area
|
||||
|
||||
ASSERT(parent.containsPoint(child.pos() + Vector2D{0.0001, 0.0001}));
|
||||
ASSERT(parent.containsPoint(child.pos() + child.size() - Vector2D{0.0001, 0.0001}));
|
||||
|
|
|
|||
|
|
@ -35,4 +35,18 @@ TEST(Desktop, reservedArea) {
|
|||
EXPECT_EQ(b.top(), 30 - 10);
|
||||
EXPECT_EQ(b.right(), 1010 - 920);
|
||||
EXPECT_EQ(b.bottom(), 1010 - 930);
|
||||
|
||||
Desktop::CReservedArea c{CBox{}, CBox{20, 30, 900, 900}};
|
||||
|
||||
EXPECT_EQ(c.left(), 0);
|
||||
EXPECT_EQ(c.top(), 0);
|
||||
EXPECT_EQ(c.right(), 0);
|
||||
EXPECT_EQ(c.bottom(), 0);
|
||||
|
||||
Desktop::CReservedArea d{CBox{20, 30, 900, 900}, CBox{}};
|
||||
|
||||
EXPECT_EQ(d.left(), 0);
|
||||
EXPECT_EQ(d.top(), 0);
|
||||
EXPECT_EQ(d.right(), 0);
|
||||
EXPECT_EQ(d.bottom(), 0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue