Add tests for Location(), SetLocation(), Frame() etc
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1026 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2f77eca4d8
commit
7f3de5c362
@ -19,6 +19,7 @@ CommonTestLib libinterfacetest.so
|
|||||||
# BDeskbar
|
# BDeskbar
|
||||||
DeskbarTest.cpp
|
DeskbarTest.cpp
|
||||||
DeskbarGetItemTest.cpp
|
DeskbarGetItemTest.cpp
|
||||||
|
DeskbarLocationTest.cpp
|
||||||
|
|
||||||
: <boot!home!config!lib>libopenbeos.so
|
: <boot!home!config!lib>libopenbeos.so
|
||||||
be stdc++.r4
|
be stdc++.r4
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: DeskbarGetItemTest.cpp,v 1.1 2002/09/12 05:14:36 jrand Exp $
|
$Id: DeskbarGetItemTest.cpp,v 1.2 2002/09/13 03:51:09 jrand Exp $
|
||||||
|
|
||||||
This file implements tests for the following use cases of BDeskbar:
|
This file implements tests for the following use cases of BDeskbar:
|
||||||
- Count Items
|
- Count Items
|
||||||
@ -40,7 +40,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: DeskbarGetItemTest::PerformTest()
|
* Method: DeskbarGetItemTest::PerformTest()
|
||||||
* Descr: This member function
|
* Descr: This member function iterates over all of the items in the
|
||||||
|
* deskbar shelf and gets information about each item and confirms
|
||||||
|
* that all of the information is self-consistent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: DeskbarGetItemTest.h,v 1.1 2002/09/12 05:14:36 jrand Exp $
|
$Id: DeskbarGetItemTest.h,v 1.2 2002/09/13 03:51:09 jrand Exp $
|
||||||
|
|
||||||
This file defines a class for performing a test of BDeskbar
|
This file defines a class for performing a test of BDeskbar
|
||||||
functionality.
|
functionality.
|
||||||
|
171
src/tests/kits/interface/bdeskbar/DeskbarLocationTest.cpp
Normal file
171
src/tests/kits/interface/bdeskbar/DeskbarLocationTest.cpp
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
$Id: DeskbarLocationTest.cpp,v 1.1 2002/09/13 03:51:09 jrand Exp $
|
||||||
|
|
||||||
|
This file implements tests for the following use cases of BDeskbar:
|
||||||
|
- Frame
|
||||||
|
- Location
|
||||||
|
- Is Expanded
|
||||||
|
- Set Location
|
||||||
|
- Expand
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DeskbarLocationTest.h"
|
||||||
|
#include <Deskbar.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: DeskbarLocationTest::DeskbarLocationTest()
|
||||||
|
* Descr: This is the constructor for this class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
DeskbarLocationTest::DeskbarLocationTest(std::string name) :
|
||||||
|
TestCase(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: DeskbarLocationTest::~DeskbarLocationTest()
|
||||||
|
* Descr: This is the destructor for this class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
DeskbarLocationTest::~DeskbarLocationTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: DeskbarLocationTest::CheckLocation()
|
||||||
|
* Descr: This member fuction checks that the passed in location and
|
||||||
|
* expansion state is the actual deskbar state
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void DeskbarLocationTest::CheckLocation(BDeskbar *myDeskbar,
|
||||||
|
deskbar_location currLocation,
|
||||||
|
bool currExpanded,
|
||||||
|
bool expandedSetDirectly)
|
||||||
|
{
|
||||||
|
bool isExpanded;
|
||||||
|
assert(myDeskbar->Location() == currLocation);
|
||||||
|
assert(myDeskbar->Location(&isExpanded) == currLocation);
|
||||||
|
|
||||||
|
if ((currLocation == B_DESKBAR_LEFT_TOP) ||
|
||||||
|
(currLocation == B_DESKBAR_RIGHT_TOP) ||
|
||||||
|
(expandedSetDirectly)) {
|
||||||
|
assert(myDeskbar->IsExpanded() == currExpanded);
|
||||||
|
assert(isExpanded == currExpanded);
|
||||||
|
} else if ((currLocation == B_DESKBAR_LEFT_BOTTOM) ||
|
||||||
|
(currLocation == B_DESKBAR_RIGHT_BOTTOM)) {
|
||||||
|
assert(!myDeskbar->IsExpanded());
|
||||||
|
assert(!isExpanded);
|
||||||
|
} else {
|
||||||
|
assert(myDeskbar->IsExpanded());
|
||||||
|
assert(isExpanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRect myRect(myDeskbar->Frame());
|
||||||
|
switch (currLocation) {
|
||||||
|
case B_DESKBAR_TOP:
|
||||||
|
case B_DESKBAR_LEFT_TOP:
|
||||||
|
assert(myRect.top == 0.0);
|
||||||
|
assert(myRect.left == 0.0);
|
||||||
|
break;
|
||||||
|
case B_DESKBAR_BOTTOM:
|
||||||
|
case B_DESKBAR_LEFT_BOTTOM:
|
||||||
|
assert(myRect.left == 0.0);
|
||||||
|
break;
|
||||||
|
case B_DESKBAR_RIGHT_TOP:
|
||||||
|
case B_DESKBAR_RIGHT_BOTTOM:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: DeskbarLocationTest::TestLocation()
|
||||||
|
* Descr: This member fuction performs a test of one location of the
|
||||||
|
* deskbar.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void DeskbarLocationTest::TestLocation(BDeskbar *myDeskbar,
|
||||||
|
deskbar_location newLocation)
|
||||||
|
{
|
||||||
|
assert(myDeskbar->SetLocation(newLocation) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, newLocation, false, false);
|
||||||
|
|
||||||
|
assert(myDeskbar->SetLocation(B_DESKBAR_TOP) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, B_DESKBAR_TOP, false, false);
|
||||||
|
|
||||||
|
assert(myDeskbar->SetLocation(newLocation, false) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, newLocation, false, false);
|
||||||
|
|
||||||
|
assert(myDeskbar->SetLocation(B_DESKBAR_TOP) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, B_DESKBAR_TOP, false, false);
|
||||||
|
|
||||||
|
assert(myDeskbar->SetLocation(newLocation, true) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, newLocation, true, false);
|
||||||
|
|
||||||
|
assert(myDeskbar->Expand(false) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, newLocation, false, true);
|
||||||
|
|
||||||
|
assert(myDeskbar->Expand(true) == B_OK);
|
||||||
|
CheckLocation(myDeskbar, newLocation, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: DeskbarLocationTest::PerformTest()
|
||||||
|
* Descr: This member function saves the starting state of the deskbar
|
||||||
|
* and then sets the deskbar location to each individual allowed
|
||||||
|
* state. Finally, it restores the original location at the end
|
||||||
|
* of the test.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void DeskbarLocationTest::PerformTest(void)
|
||||||
|
{
|
||||||
|
BDeskbar myDeskbar;
|
||||||
|
bool origExpanded;
|
||||||
|
deskbar_location origLocation = myDeskbar.Location(&origExpanded);
|
||||||
|
|
||||||
|
assert((origLocation == B_DESKBAR_TOP) ||
|
||||||
|
(origLocation == B_DESKBAR_BOTTOM) ||
|
||||||
|
(origLocation == B_DESKBAR_LEFT_BOTTOM) ||
|
||||||
|
(origLocation == B_DESKBAR_RIGHT_BOTTOM) ||
|
||||||
|
(origLocation == B_DESKBAR_LEFT_TOP) ||
|
||||||
|
(origLocation == B_DESKBAR_RIGHT_TOP));
|
||||||
|
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_TOP);
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_BOTTOM);
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_LEFT_BOTTOM);
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_RIGHT_BOTTOM);
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_LEFT_TOP);
|
||||||
|
TestLocation(&myDeskbar, B_DESKBAR_RIGHT_TOP);
|
||||||
|
|
||||||
|
assert(myDeskbar.SetLocation(origLocation, origExpanded) == B_OK);
|
||||||
|
assert(myDeskbar.Location() == origLocation);
|
||||||
|
assert(myDeskbar.IsExpanded() == origExpanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: PropertyConstructionTest::suite()
|
||||||
|
* Descr: This static member function returns a test caller for performing
|
||||||
|
* all combinations of "DeskbarLocationTest".
|
||||||
|
*/
|
||||||
|
|
||||||
|
Test *DeskbarLocationTest::suite(void)
|
||||||
|
{
|
||||||
|
typedef CppUnit::TestCaller<DeskbarLocationTest>
|
||||||
|
DeskbarLocationTestCaller;
|
||||||
|
|
||||||
|
return(new DeskbarLocationTestCaller("BDeskbar::Location Test", &DeskbarLocationTest::PerformTest));
|
||||||
|
}
|
34
src/tests/kits/interface/bdeskbar/DeskbarLocationTest.h
Normal file
34
src/tests/kits/interface/bdeskbar/DeskbarLocationTest.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
$Id: DeskbarLocationTest.h,v 1.1 2002/09/13 03:51:09 jrand Exp $
|
||||||
|
|
||||||
|
This file defines a class for performing a test of BDeskbar
|
||||||
|
functionality.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DeskbarLocationTest_H
|
||||||
|
#define DeskbarLocationTest_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include <Deskbar.h>
|
||||||
|
|
||||||
|
|
||||||
|
class DeskbarLocationTest :
|
||||||
|
public TestCase {
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CheckLocation(BDeskbar *, deskbar_location, bool, bool);
|
||||||
|
void TestLocation(BDeskbar *, deskbar_location);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
public:
|
||||||
|
static Test *suite(void);
|
||||||
|
void PerformTest(void);
|
||||||
|
DeskbarLocationTest(std::string name = "");
|
||||||
|
virtual ~DeskbarLocationTest();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,11 +1,13 @@
|
|||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "DeskbarGetItemTest.h"
|
#include "DeskbarGetItemTest.h"
|
||||||
|
#include "DeskbarLocationTest.h"
|
||||||
|
|
||||||
Test *DeskbarTestSuite()
|
Test *DeskbarTestSuite()
|
||||||
{
|
{
|
||||||
TestSuite *testSuite = new TestSuite();
|
TestSuite *testSuite = new TestSuite();
|
||||||
|
|
||||||
testSuite->addTest(DeskbarGetItemTest::suite());
|
testSuite->addTest(DeskbarGetItemTest::suite());
|
||||||
|
testSuite->addTest(DeskbarLocationTest::suite());
|
||||||
|
|
||||||
return(testSuite);
|
return(testSuite);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user