1 //----------------------------------------------------------------------------- 2 // BCursorTester.cpp 3 // 4 //----------------------------------------------------------------------------- 5 6 // Standard Includes ---------------------------------------------------------- 7 8 // System Includes ------------------------------------------------------------ 9 #include <Application.h> 10 #include <Cursor.h> 11 #include <Message.h> 12 13 #define CHK CPPUNIT_ASSERT 14 15 // Project Includes ----------------------------------------------------------- 16 17 // Local Includes ------------------------------------------------------------- 18 #include "BCursorTester.h" 19 20 // Local Defines -------------------------------------------------------------- 21 22 // Globals -------------------------------------------------------------------- 23 24 //----------------------------------------------------------------------------- 25 26 /* 27 BCursor(const void *cursorData) 28 @case 1 29 @results nothing apparent (no segfault) 30 */ 31 void BCursorTester::BCursor1() 32 { 33 BApplication app("application/x-vnd.cursortest"); 34 BCursor cur((void *)NULL); 35 } 36 37 /* 38 BCursor(const void *cursorData) 39 @case 2 40 @results nothing apparent 41 */ 42 void BCursorTester::BCursor2() 43 { 44 BApplication app("application/x-vnd.cursortest"); 45 char data[68]; 46 int i; 47 48 data[0] = 16; 49 data[1] = 1; 50 data[2] = 0; 51 data[3] = 0; 52 for (i=4; i<68; i++) 53 data[i] = 1; 54 55 BCursor cur(data); 56 } 57 58 /* 59 BCursor(const void *cursorData) 60 @case 3 61 @results nothing apparent (no segfaults) 62 */ 63 void BCursorTester::BCursor3() 64 { 65 BApplication app("application/x-vnd.cursortest"); 66 int x; 67 BCursor cur1(&x); 68 char data[68]; 69 data[0] = 32; 70 BCursor cur2(data); 71 data[0] = 16; 72 data[1] = 8; 73 BCursor cur3(data); 74 data[1] = 1; 75 data[2] = 16; 76 data[3] = 16; 77 BCursor cur4(data); 78 } 79 80 /* 81 BCursor(BMessage *archive) 82 @case 1 83 @results nothing apparent (no segfault) 84 */ 85 void BCursorTester::BCursor4() 86 { 87 BApplication app("application/x-vnd.cursortest"); 88 BCursor cur((BMessage *)NULL); 89 } 90 91 /* 92 BCursor(BMessage *archive) 93 @case 2 94 @results nothing apparent (empty cursor) 95 */ 96 void BCursorTester::BCursor5() 97 { 98 BApplication app("application/x-vnd.cursortest"); 99 /* The message really should contain a valid archive, but Cursor doesn't 100 support archiving anyway, so until R2, this is a moot point. 101 */ 102 BMessage msg; 103 BCursor cur(&msg); 104 } 105 106 /* 107 static BArchivable *Instantiate(BMessage *archive) 108 @case 1 109 @results return NULL 110 */ 111 void BCursorTester::Instantiate1() 112 { 113 BApplication app("application/x-vnd.cursortest"); 114 CHK(BCursor::Instantiate(NULL) == NULL); 115 } 116 117 /* 118 static BArchivable *Instantiate(BMessage *archive) 119 @case 2 120 @results return NULL 121 */ 122 void BCursorTester::Instantiate2() 123 { 124 BApplication app("application/x-vnd.cursortest"); 125 /* The message really should contain a valid archive, but Cursor doesn't 126 support archiving anyway, so until R2, this is a moot point. 127 */ 128 BMessage msg; 129 CHK(BCursor::Instantiate(&msg) == NULL); 130 } 131 132 /* 133 status_t Archive(BMessage* into, bool deep = true) 134 @case 1 135 @results return B_OK 136 */ 137 void BCursorTester::Archive1() 138 { 139 BApplication app("application/x-vnd.cursortest"); 140 char data[68]; 141 int i; 142 143 data[0] = 16; 144 data[1] = 1; 145 data[2] = 0; 146 data[3] = 0; 147 for (i=4; i<68; i++) 148 data[i] = 1; 149 150 BCursor cur(data); 151 CHK(cur.Archive(NULL) == B_OK); 152 } 153 154 /* 155 status_t Archive(BMessage* into, bool deep = true) 156 @case 2 157 @results return B_OK 158 */ 159 void BCursorTester::Archive2() 160 { 161 BApplication app("application/x-vnd.cursortest"); 162 char data[68]; 163 int i; 164 165 data[0] = 16; 166 data[1] = 1; 167 data[2] = 0; 168 data[3] = 0; 169 for (i=4; i<68; i++) 170 data[i] = 1; 171 172 BCursor cur(data); 173 BMessage msg; 174 CHK(cur.Archive(&msg) == B_OK); 175 } 176 177 178 Test* BCursorTester::Suite() 179 { 180 TestSuite* SuiteOfTests = new TestSuite; 181 182 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, BCursor1); 183 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, BCursor2); 184 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, BCursor3); 185 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, BCursor4); 186 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, BCursor5); 187 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, Instantiate1); 188 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, Instantiate2); 189 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, Archive1); 190 ADD_TEST4(BCursor, SuiteOfTests, BCursorTester, Archive2); 191 192 return SuiteOfTests; 193 } 194 195