Add some cppunit-based tests for BTextView.
Note that this does not reproduce #8447. I could not get more precise details from involved people about how to reproduce this, and the patch was already applied anyway, so I'm stopping my investigation for now. Feel free to complete this with more test cases.
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "bdeskbar/DeskbarTest.h"
|
#include "bdeskbar/DeskbarTest.h"
|
||||||
#include "bpolygon/PolygonTest.h"
|
#include "bpolygon/PolygonTest.h"
|
||||||
#include "bregion/RegionTest.h"
|
#include "bregion/RegionTest.h"
|
||||||
|
#include "btextview/TextViewTest.h"
|
||||||
//#include "bwidthbuffer/WidthBufferTest.h"
|
//#include "bwidthbuffer/WidthBufferTest.h"
|
||||||
#include "GraphicsDefsTest.h"
|
#include "GraphicsDefsTest.h"
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ getTestSuite()
|
|||||||
suite->addTest("BDeskbar", DeskbarTestSuite());
|
suite->addTest("BDeskbar", DeskbarTestSuite());
|
||||||
suite->addTest("BPolygon", PolygonTestSuite());
|
suite->addTest("BPolygon", PolygonTestSuite());
|
||||||
suite->addTest("BRegion", RegionTestSuite());
|
suite->addTest("BRegion", RegionTestSuite());
|
||||||
|
suite->addTest("BTextView", TextViewTestSuite());
|
||||||
//suite->addTest("_BWidthBuffer_", WidthBufferTestSuite());
|
//suite->addTest("_BWidthBuffer_", WidthBufferTestSuite());
|
||||||
suite->addTest("GraphicsDefs", GraphicsDefsTestSuite());
|
suite->addTest("GraphicsDefs", GraphicsDefsTestSuite());
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) bbitmap ] ;
|
|||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) bdeskbar ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) bdeskbar ] ;
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) bpolygon ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) bpolygon ] ;
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) bregion ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) bregion ] ;
|
||||||
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) btextview ] ;
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) bwindowstack ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) bwindowstack ] ;
|
||||||
|
|
||||||
SEARCH_SOURCE += [ FDirName $(TOP) src kits interface ] ;
|
SEARCH_SOURCE += [ FDirName $(TOP) src kits interface ] ;
|
||||||
@@ -49,6 +50,8 @@ UnitTestLib libinterfacetest.so
|
|||||||
RegionIntersect.cpp
|
RegionIntersect.cpp
|
||||||
RegionOffsetBy.cpp
|
RegionOffsetBy.cpp
|
||||||
|
|
||||||
|
TextViewTest.cpp
|
||||||
|
|
||||||
: be [ TargetLibstdc++ ]
|
: be [ TargetLibstdc++ ]
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -164,7 +167,7 @@ SimpleTest SetBorderScrollViewTest :
|
|||||||
;
|
;
|
||||||
|
|
||||||
SimpleTest TextViewTest :
|
SimpleTest TextViewTest :
|
||||||
TextViewTest.cpp
|
TextViewTestManual.cpp
|
||||||
: be [ TargetLibsupc++ ]
|
: be [ TargetLibsupc++ ]
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -174,7 +177,8 @@ SimpleTest WindowStackTest :
|
|||||||
;
|
;
|
||||||
|
|
||||||
SEARCH on [ FGristFiles
|
SEARCH on [ FGristFiles
|
||||||
ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp Slider.cpp Control.cpp
|
ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp
|
||||||
|
Slider.cpp Control.cpp
|
||||||
] = [ FDirName $(HAIKU_TOP) src kits interface ] ;
|
] = [ FDirName $(HAIKU_TOP) src kits interface ] ;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src tests kits interface bprintjob ;
|
SubInclude HAIKU_TOP src tests kits interface bprintjob ;
|
||||||
|
|||||||
-7
@@ -149,13 +149,6 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
Application app;
|
Application app;
|
||||||
|
|
||||||
const int kExpectedTextViewSize = 356;
|
|
||||||
if (sizeof(BTextView) != kExpectedTextViewSize) {
|
|
||||||
fprintf(stderr, "sizeof(BTextView) is %ld instead of %d!\n",
|
|
||||||
sizeof(BTextView), kExpectedTextViewSize);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
class TextViewTestcase: public TestCase {
|
||||||
|
public:
|
||||||
|
void
|
||||||
|
SizeTest()
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL(356, sizeof(BTextView));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetTextTest()
|
||||||
|
{
|
||||||
|
BApplication app("application/x-vnd.Haiku-interfacekit-textviewtest");
|
||||||
|
BRect textRect(0, 0, 100, 100);
|
||||||
|
BTextView* v = new BTextView(textRect, "test", textRect, 0, 0);
|
||||||
|
v->SetText("Initial text");
|
||||||
|
v->Insert(8, "(inserted) ", 10);
|
||||||
|
char buffer[12];
|
||||||
|
v->GetText(2, 11, buffer);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(BString("itial (inse"), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Test*
|
||||||
|
TextViewTestSuite()
|
||||||
|
{
|
||||||
|
TestSuite *testSuite = new TestSuite();
|
||||||
|
|
||||||
|
testSuite->addTest(new CppUnit::TestCaller<TextViewTestcase>(
|
||||||
|
"BTextView_Size", &TextViewTestcase::SizeTest));
|
||||||
|
testSuite->addTest(new CppUnit::TestCaller<TextViewTestcase>(
|
||||||
|
"BTextView_GetText", &TextViewTestcase::GetTextTest));
|
||||||
|
|
||||||
|
return testSuite;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _text_view_test_h_
|
||||||
|
#define _text_view_test_h_
|
||||||
|
|
||||||
|
class CppUnit::Test;
|
||||||
|
|
||||||
|
CppUnit::Test *TextViewTestSuite();
|
||||||
|
|
||||||
|
#endif // text_view_test_h_
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user