xref: /haiku/src/tests/kits/interface/btextview/TextViewTest.cpp (revision 5fae0bc1a2f74ccf56b7e3958149317d6af2cccc)
1*5fae0bc1SAdrien Destugues #include "../common.h"
2*5fae0bc1SAdrien Destugues 
3*5fae0bc1SAdrien Destugues #include <Application.h>
4*5fae0bc1SAdrien Destugues #include <String.h>
5*5fae0bc1SAdrien Destugues #include <TextView.h>
6*5fae0bc1SAdrien Destugues 
7*5fae0bc1SAdrien Destugues class TextViewTestcase: public TestCase {
8*5fae0bc1SAdrien Destugues public:
9*5fae0bc1SAdrien Destugues 	void
SizeTest()10*5fae0bc1SAdrien Destugues 	SizeTest()
11*5fae0bc1SAdrien Destugues 	{
12*5fae0bc1SAdrien Destugues 		CPPUNIT_ASSERT_EQUAL(356, sizeof(BTextView));
13*5fae0bc1SAdrien Destugues 	}
14*5fae0bc1SAdrien Destugues 
15*5fae0bc1SAdrien Destugues 	void
GetTextTest()16*5fae0bc1SAdrien Destugues 	GetTextTest()
17*5fae0bc1SAdrien Destugues 	{
18*5fae0bc1SAdrien Destugues 		BApplication app("application/x-vnd.Haiku-interfacekit-textviewtest");
19*5fae0bc1SAdrien Destugues 		BRect textRect(0, 0, 100, 100);
20*5fae0bc1SAdrien Destugues 		BTextView* v = new BTextView(textRect, "test", textRect, 0, 0);
21*5fae0bc1SAdrien Destugues 		v->SetText("Initial text");
22*5fae0bc1SAdrien Destugues 		v->Insert(8, "(inserted) ", 10);
23*5fae0bc1SAdrien Destugues 		char buffer[12];
24*5fae0bc1SAdrien Destugues 		v->GetText(2, 11, buffer);
25*5fae0bc1SAdrien Destugues 		CPPUNIT_ASSERT_EQUAL(BString("itial (inse"), buffer);
26*5fae0bc1SAdrien Destugues 	}
27*5fae0bc1SAdrien Destugues };
28*5fae0bc1SAdrien Destugues 
29*5fae0bc1SAdrien Destugues 
30*5fae0bc1SAdrien Destugues Test*
TextViewTestSuite()31*5fae0bc1SAdrien Destugues TextViewTestSuite()
32*5fae0bc1SAdrien Destugues {
33*5fae0bc1SAdrien Destugues 	TestSuite *testSuite = new TestSuite();
34*5fae0bc1SAdrien Destugues 
35*5fae0bc1SAdrien Destugues 	testSuite->addTest(new CppUnit::TestCaller<TextViewTestcase>(
36*5fae0bc1SAdrien Destugues 		"BTextView_Size", &TextViewTestcase::SizeTest));
37*5fae0bc1SAdrien Destugues 	testSuite->addTest(new CppUnit::TestCaller<TextViewTestcase>(
38*5fae0bc1SAdrien Destugues 		"BTextView_GetText", &TextViewTestcase::GetTextTest));
39*5fae0bc1SAdrien Destugues 
40*5fae0bc1SAdrien Destugues 	return testSuite;
41*5fae0bc1SAdrien Destugues }
42