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