mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 02:31:59 +00:00
Added more self-test code
This commit is contained in:
parent
689fa77686
commit
1fa629b516
@ -29,6 +29,8 @@ public:
|
||||
PRBool TestAddBandOverlap();
|
||||
PRBool TestAddRectToBand();
|
||||
PRBool TestRemoveRegion();
|
||||
PRBool TestOffsetRegion();
|
||||
PRBool TestResizeRectRegion();
|
||||
|
||||
protected:
|
||||
struct BandInfo {
|
||||
@ -621,6 +623,91 @@ PRBool MySpaceManager::TestRemoveRegion()
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Test of offseting regions
|
||||
//
|
||||
// This tests the following:
|
||||
// 1. simple test of offseting the one and only band rect
|
||||
PRBool MySpaceManager::TestOffsetRegion()
|
||||
{
|
||||
PRBool status;
|
||||
BandsInfo bandsInfo;
|
||||
BandRect* bandRect;
|
||||
|
||||
// Clear any existing regions
|
||||
ClearRegions();
|
||||
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// #1. A simple test of offseting the one and only band rect
|
||||
status = AddRectRegion((nsIFrame*)0x01, nsRect(10, 100, 100, 100));
|
||||
NS_ASSERTION(PR_TRUE == status, "unexpected status");
|
||||
status = OffsetRegion((nsIFrame*)0x01, 50, 50);
|
||||
NS_ASSERTION(PR_TRUE == status, "unexpected status");
|
||||
|
||||
// Verify there is one band with one rect
|
||||
GetBandsInfo(bandsInfo);
|
||||
if (bandsInfo.numBands != 1) {
|
||||
printf("TestOffsetRegion: wrong number of bands (#1): %i\n", bandsInfo.numBands);
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (bandsInfo.bands[0].numRects != 1) {
|
||||
printf("TestOffsetRegion: wrong number of rects (#1): %i\n", bandsInfo.bands[0].numRects);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Verify the position
|
||||
bandRect = bandsInfo.bands[0].firstRect;
|
||||
if ((bandRect->left != 60) || (bandRect->top != 150)) {
|
||||
printf("TestOffsetRegion: wrong rect origin (#1)\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Test of resizing rect regions
|
||||
//
|
||||
// This tests the following:
|
||||
// 1. simple test of resizing the one and only band rect
|
||||
PRBool MySpaceManager::TestResizeRectRegion()
|
||||
{
|
||||
PRBool status;
|
||||
BandsInfo bandsInfo;
|
||||
BandRect* bandRect;
|
||||
|
||||
// Clear any existing regions
|
||||
ClearRegions();
|
||||
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// #1. A simple test of resizing the right edge of the one and only band rect
|
||||
status = AddRectRegion((nsIFrame*)0x01, nsRect(10, 100, 100, 100));
|
||||
NS_ASSERTION(PR_TRUE == status, "unexpected status");
|
||||
status = ResizeRectRegion((nsIFrame*)0x01, 50, 50, nsISpaceManager::RightEdge);
|
||||
NS_ASSERTION(PR_TRUE == status, "unexpected status");
|
||||
|
||||
// Verify there is one band with one rect
|
||||
GetBandsInfo(bandsInfo);
|
||||
if (bandsInfo.numBands != 1) {
|
||||
printf("TestResizeRectRegion: wrong number of bands (#1): %i\n", bandsInfo.numBands);
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (bandsInfo.bands[0].numRects != 1) {
|
||||
printf("TestResizeRectRegion: wrong number of rects (#1): %i\n", bandsInfo.bands[0].numRects);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Verify the position and size of the rect
|
||||
bandRect = bandsInfo.bands[0].firstRect;
|
||||
if ((bandRect->left != 10) || (bandRect->top != 100) ||
|
||||
(bandRect->right != 160) || (bandRect->bottom != 250)) {
|
||||
printf("TestResizeRectRegion: wrong rect shape (#1)\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@ -649,10 +736,21 @@ int main(int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test removing regions
|
||||
if (!spaceMgr->TestRemoveRegion()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test offseting regions
|
||||
if (!spaceMgr->TestOffsetRegion()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test resizing rect regions
|
||||
if (!spaceMgr->TestResizeRectRegion()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!spaceMgr->TestGetBandData()) {
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user