tccompstreaming.pp 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. Unit tccompstreaming;
  2. interface
  3. Uses
  4. SysUtils,Classes,tcstreaming;
  5. Type
  6. TTestComponentStream = Class(TTestStreaming)
  7. Published
  8. Procedure TestTEmptyComponent;
  9. Procedure TestTIntegerComponent;
  10. Procedure TestTIntegerComponent2;
  11. Procedure TestTIntegerComponent3;
  12. Procedure TestTIntegerComponent4;
  13. Procedure TestTIntegerComponent5;
  14. Procedure TestTInt64Component;
  15. Procedure TestTInt64Component2;
  16. Procedure TestTInt64Component3;
  17. Procedure TestTInt64Component4;
  18. Procedure TestTInt64Component5;
  19. Procedure TestTInt64Component6;
  20. Procedure TestTStringComponent;
  21. Procedure TestTStringComponent2;
  22. Procedure TestTWideStringComponent;
  23. Procedure TestTWideStringComponent2;
  24. Procedure TestTSingleComponent;
  25. Procedure TestTDoubleComponent;
  26. Procedure TestTExtendedComponent;
  27. Procedure TestTCompComponent;
  28. Procedure TestTCurrencyComponent;
  29. Procedure TestTDateTimeComponent;
  30. Procedure TestTDateTimeComponent2;
  31. Procedure TestTDateTimeComponent3;
  32. Procedure TestTEnumComponent;
  33. Procedure TestTEnumComponent2;
  34. Procedure TestTEnumComponent3;
  35. Procedure TestTEnumComponent4;
  36. Procedure TestTSetComponent;
  37. Procedure TestTSetComponent2;
  38. Procedure TestTSetComponent3;
  39. Procedure TestTSetComponent4;
  40. Procedure TestTMultipleComponent;
  41. Procedure TestTPersistentComponent;
  42. Procedure TestTCollectionComponent;
  43. Procedure TestTCollectionComponent2;
  44. Procedure TestTCollectionComponent3;
  45. Procedure TestTCollectionComponent4;
  46. Procedure TestTOwnedComponent;
  47. Procedure TestTStreamedOwnedComponent;
  48. Procedure TestTMethodComponent;
  49. Procedure TestTMethodComponent2;
  50. end;
  51. Implementation
  52. uses testcomps;
  53. Procedure TTestComponentStream.TestTEmptyComponent;
  54. Var
  55. C : TComponent;
  56. begin
  57. C:=TEmptyComponent.Create(Nil);
  58. Try
  59. SaveToStream(C);
  60. ExpectSignature;
  61. ExpectFlags([],0);
  62. ExpectBareString('TEmptyComponent');
  63. ExpectBareString('TestTEmptyComponent');
  64. ExpectEndOfList;
  65. ExpectEndOfList;
  66. Finally
  67. C.Free;
  68. end;
  69. end;
  70. Procedure TTestComponentStream.TestTIntegerComponent;
  71. Var
  72. C : TComponent;
  73. begin
  74. C:=TIntegerComponent.Create(Nil);
  75. Try
  76. SaveToStream(C);
  77. ExpectSignature;
  78. ExpectFlags([],0);
  79. ExpectBareString('TIntegerComponent');
  80. ExpectBareString('TestTIntegerComponent');
  81. ExpectBareString('IntProp');
  82. ExpectInteger(3);
  83. ExpectEndOfList;
  84. ExpectEndOfList;
  85. Finally
  86. C.Free;
  87. end;
  88. end;
  89. Procedure TTestComponentStream.TestTIntegerComponent2;
  90. Var
  91. C : TComponent;
  92. begin
  93. C:=TIntegerComponent2.Create(Nil);
  94. Try
  95. SaveToStream(C);
  96. ExpectSignature;
  97. ExpectFlags([],0);
  98. ExpectBareString('TIntegerComponent2');
  99. ExpectBareString('TestTIntegerComponent2');
  100. ExpectBareString('IntProp');
  101. ExpectInteger(1024);
  102. ExpectEndOfList;
  103. ExpectEndOfList;
  104. Finally
  105. C.Free;
  106. end;
  107. end;
  108. Procedure TTestComponentStream.TestTIntegerComponent3;
  109. Var
  110. C : TComponent;
  111. begin
  112. C:=TIntegerComponent3.Create(Nil);
  113. Try
  114. SaveToStream(C);
  115. ExpectSignature;
  116. ExpectFlags([],0);
  117. ExpectBareString('TIntegerComponent3');
  118. ExpectBareString('TestTIntegerComponent3');
  119. ExpectBareString('IntProp');
  120. ExpectInteger(262144);
  121. ExpectEndOfList;
  122. ExpectEndOfList;
  123. Finally
  124. C.Free;
  125. end;
  126. end;
  127. Procedure TTestComponentStream.TestTIntegerComponent4;
  128. Var
  129. C : TComponent;
  130. begin
  131. C:=TIntegerComponent4.Create(Nil);
  132. Try
  133. SaveToStream(C);
  134. ExpectSignature;
  135. ExpectFlags([],0);
  136. ExpectBareString('TIntegerComponent4');
  137. ExpectBareString('TestTIntegerComponent4');
  138. ExpectEndOfList;
  139. ExpectEndOfList;
  140. Finally
  141. C.Free;
  142. end;
  143. end;
  144. Procedure TTestComponentStream.TestTIntegerComponent5;
  145. Var
  146. C : TComponent;
  147. begin
  148. C:=TIntegerComponent5.Create(Nil);
  149. Try
  150. SaveToStream(C);
  151. ExpectSignature;
  152. ExpectFlags([],0);
  153. ExpectBareString('TIntegerComponent5');
  154. ExpectBareString('TestTIntegerComponent5');
  155. ExpectBareString('IntProp');
  156. ExpectInteger(5);
  157. ExpectEndOfList;
  158. ExpectEndOfList;
  159. Finally
  160. C.Free;
  161. end;
  162. end;
  163. Procedure TTestComponentStream.TestTInt64Component;
  164. Var
  165. C : TComponent;
  166. begin
  167. C:=TInt64Component.Create(Nil);
  168. Try
  169. SaveToStream(C);
  170. ExpectSignature;
  171. ExpectFlags([],0);
  172. ExpectBareString('TInt64Component');
  173. ExpectBareString('TestTInt64Component');
  174. ExpectBareString('Int64Prop');
  175. ExpectInteger(4);
  176. ExpectEndOfList;
  177. ExpectEndOfList;
  178. Finally
  179. C.Free;
  180. end;
  181. end;
  182. Procedure TTestComponentStream.TestTInt64Component2;
  183. Var
  184. C : TComponent;
  185. begin
  186. C:=TInt64Component2.Create(Nil);
  187. Try
  188. SaveToStream(C);
  189. ExpectSignature;
  190. ExpectFlags([],0);
  191. ExpectBareString('TInt64Component2');
  192. ExpectBareString('TestTInt64Component2');
  193. ExpectBareString('Int64Prop');
  194. ExpectInteger(1024);
  195. ExpectEndOfList;
  196. ExpectEndOfList;
  197. Finally
  198. C.Free;
  199. end;
  200. end;
  201. Procedure TTestComponentStream.TestTInt64Component3;
  202. Var
  203. C : TComponent;
  204. begin
  205. C:=TInt64Component3.Create(Nil);
  206. Try
  207. SaveToStream(C);
  208. ExpectSignature;
  209. ExpectFlags([],0);
  210. ExpectBareString('TInt64Component3');
  211. ExpectBareString('TestTInt64Component3');
  212. ExpectBareString('Int64Prop');
  213. ExpectInteger(262144);
  214. ExpectEndOfList;
  215. ExpectEndOfList;
  216. Finally
  217. C.Free;
  218. end;
  219. end;
  220. Procedure TTestComponentStream.TestTInt64Component4;
  221. Var
  222. C : TComponent;
  223. begin
  224. C:=TInt64Component4.Create(Nil);
  225. Try
  226. SaveToStream(C);
  227. ExpectSignature;
  228. ExpectFlags([],0);
  229. ExpectBareString('TInt64Component4');
  230. ExpectBareString('TestTInt64Component4');
  231. ExpectBareString('Int64Prop');
  232. ExpectInt64(2147745791);
  233. ExpectEndOfList;
  234. ExpectEndOfList;
  235. Finally
  236. C.Free;
  237. end;
  238. end;
  239. Procedure TTestComponentStream.TestTInt64Component5;
  240. Var
  241. C : TComponent;
  242. begin
  243. C:=TInt64Component5.Create(Nil);
  244. Try
  245. SaveToStream(C);
  246. ExpectSignature;
  247. ExpectFlags([],0);
  248. ExpectBareString('TInt64Component5');
  249. ExpectBareString('TestTInt64Component5');
  250. ExpectBareString('Int64Prop');
  251. ExpectInteger(7);
  252. ExpectEndOfList;
  253. ExpectEndOfList;
  254. Finally
  255. C.Free;
  256. end;
  257. end;
  258. Procedure TTestComponentStream.TestTInt64Component6;
  259. Var
  260. C : TComponent;
  261. begin
  262. C:=TInt64Component6.Create(Nil);
  263. Try
  264. SaveToStream(C);
  265. ExpectSignature;
  266. ExpectFlags([],0);
  267. ExpectBareString('TInt64Component6');
  268. ExpectBareString('TestTInt64Component6');
  269. ExpectBareString('Int64Prop');
  270. ExpectInteger(8);
  271. ExpectEndOfList;
  272. ExpectEndOfList;
  273. Finally
  274. C.Free;
  275. end;
  276. end;
  277. Procedure TTestComponentStream.TestTStringComponent;
  278. Var
  279. C : TComponent;
  280. begin
  281. C:=TStringComponent.Create(Nil);
  282. Try
  283. SaveToStream(C);
  284. ExpectSignature;
  285. ExpectFlags([],0);
  286. ExpectBareString('TStringComponent');
  287. ExpectBareString('TestTStringComponent');
  288. ExpectBareString('StringProp');
  289. ExpectString('A string');
  290. ExpectEndOfList;
  291. ExpectEndOfList;
  292. Finally
  293. C.Free;
  294. end;
  295. end;
  296. Procedure TTestComponentStream.TestTStringComponent2;
  297. Var
  298. C : TComponent;
  299. begin
  300. C:=TStringComponent2.Create(Nil);
  301. Try
  302. SaveToStream(C);
  303. ExpectSignature;
  304. ExpectFlags([],0);
  305. ExpectBareString('TStringComponent2');
  306. ExpectBareString('TestTStringComponent2');
  307. ExpectEndOfList;
  308. ExpectEndOfList;
  309. Finally
  310. C.Free;
  311. end;
  312. end;
  313. Procedure TTestComponentStream.TestTWideStringComponent;
  314. Var
  315. C : TComponent;
  316. begin
  317. C:=TWideStringComponent.Create(Nil);
  318. Try
  319. SaveToStream(C);
  320. ExpectSignature;
  321. ExpectFlags([],0);
  322. ExpectBareString('TWideStringComponent');
  323. ExpectBareString('TestTWideStringComponent');
  324. ExpectBareString('WideStringProp');
  325. ExpectString('Some WideString');
  326. ExpectEndOfList;
  327. ExpectEndOfList;
  328. Finally
  329. C.Free;
  330. end;
  331. end;
  332. Procedure TTestComponentStream.TestTWideStringComponent2;
  333. Var
  334. C : TComponent;
  335. begin
  336. C:=TWideStringComponent2.Create(Nil);
  337. Try
  338. SaveToStream(C);
  339. ExpectSignature;
  340. ExpectFlags([],0);
  341. ExpectBareString('TWideStringComponent2');
  342. ExpectBareString('TestTWideStringComponent2');
  343. ExpectEndOfList;
  344. ExpectEndOfList;
  345. Finally
  346. C.Free;
  347. end;
  348. end;
  349. Procedure TTestComponentStream.TestTSingleComponent;
  350. Var
  351. C : TComponent;
  352. begin
  353. C:=TSingleComponent.Create(Nil);
  354. Try
  355. SaveToStream(C);
  356. ExpectSignature;
  357. ExpectFlags([],0);
  358. ExpectBareString('TSingleComponent');
  359. ExpectBareString('TestTSingleComponent');
  360. ExpectBareString('SingleProp');
  361. ExpectExtended(1.23);
  362. ExpectEndOfList;
  363. ExpectEndOfList;
  364. Finally
  365. C.Free;
  366. end;
  367. end;
  368. Procedure TTestComponentStream.TestTDoubleComponent;
  369. Var
  370. C : TComponent;
  371. begin
  372. C:=TDoubleComponent.Create(Nil);
  373. Try
  374. SaveToStream(C);
  375. ExpectSignature;
  376. ExpectFlags([],0);
  377. ExpectBareString('TDoubleComponent');
  378. ExpectBareString('TestTDoubleComponent');
  379. ExpectBareString('DoubleProp');
  380. ExpectExtended(2.34);
  381. ExpectEndOfList;
  382. ExpectEndOfList;
  383. Finally
  384. C.Free;
  385. end;
  386. end;
  387. Procedure TTestComponentStream.TestTExtendedComponent;
  388. Var
  389. C : TComponent;
  390. begin
  391. C:=TExtendedComponent.Create(Nil);
  392. Try
  393. SaveToStream(C);
  394. ExpectSignature;
  395. ExpectFlags([],0);
  396. ExpectBareString('TExtendedComponent');
  397. ExpectBareString('TestTExtendedComponent');
  398. ExpectBareString('ExtendedProp');
  399. ExpectExtended(3.45);
  400. ExpectEndOfList;
  401. ExpectEndOfList;
  402. Finally
  403. C.Free;
  404. end;
  405. end;
  406. Procedure TTestComponentStream.TestTCompComponent;
  407. Var
  408. C : TComponent;
  409. begin
  410. C:=TCompComponent.Create(Nil);
  411. Try
  412. SaveToStream(C);
  413. ExpectSignature;
  414. ExpectFlags([],0);
  415. ExpectBareString('TCompComponent');
  416. ExpectBareString('TestTCompComponent');
  417. ExpectBareString('ExtendedProp');
  418. ExpectExtended(5.00);
  419. ExpectEndOfList;
  420. ExpectEndOfList;
  421. Finally
  422. C.Free;
  423. end;
  424. end;
  425. Procedure TTestComponentStream.TestTCurrencyComponent;
  426. Var
  427. C : TComponent;
  428. begin
  429. C:=TCurrencyComponent.Create(Nil);
  430. Try
  431. SaveToStream(C);
  432. ExpectSignature;
  433. ExpectFlags([],0);
  434. ExpectBareString('TCurrencyComponent');
  435. ExpectBareString('TestTCurrencyComponent');
  436. ExpectBareString('CurrencyProp');
  437. ExpectExtended(5.67);
  438. ExpectEndOfList;
  439. ExpectEndOfList;
  440. Finally
  441. C.Free;
  442. end;
  443. end;
  444. Procedure TTestComponentStream.TestTDateTimeComponent;
  445. Var
  446. C : TComponent;
  447. begin
  448. C:=TDateTimeComponent.Create(Nil);
  449. Try
  450. SaveToStream(C);
  451. ExpectSignature;
  452. ExpectFlags([],0);
  453. ExpectBareString('TDateTimeComponent');
  454. ExpectBareString('TestTDateTimeComponent');
  455. ExpectBareString('DateTimeProp');
  456. ExpectExtended(35278.00);
  457. ExpectEndOfList;
  458. ExpectEndOfList;
  459. Finally
  460. C.Free;
  461. end;
  462. end;
  463. Procedure TTestComponentStream.TestTDateTimeComponent2;
  464. Var
  465. C : TComponent;
  466. begin
  467. C:=TDateTimeComponent2.Create(Nil);
  468. Try
  469. SaveToStream(C);
  470. ExpectSignature;
  471. ExpectFlags([],0);
  472. ExpectBareString('TDateTimeComponent2');
  473. ExpectBareString('TestTDateTimeComponent2');
  474. ExpectBareString('DateTimeProp');
  475. ExpectExtended(0.97);
  476. ExpectEndOfList;
  477. ExpectEndOfList;
  478. Finally
  479. C.Free;
  480. end;
  481. end;
  482. Procedure TTestComponentStream.TestTDateTimeComponent3;
  483. Var
  484. C : TComponent;
  485. begin
  486. C:=TDateTimeComponent3.Create(Nil);
  487. Try
  488. SaveToStream(C);
  489. ExpectSignature;
  490. ExpectFlags([],0);
  491. ExpectBareString('TDateTimeComponent3');
  492. ExpectBareString('TestTDateTimeComponent3');
  493. ExpectBareString('DateTimeProp');
  494. ExpectExtended(35278.97);
  495. ExpectEndOfList;
  496. ExpectEndOfList;
  497. Finally
  498. C.Free;
  499. end;
  500. end;
  501. Procedure TTestComponentStream.TestTEnumComponent;
  502. Var
  503. C : TComponent;
  504. begin
  505. C:=TEnumComponent.Create(Nil);
  506. Try
  507. SaveToStream(C);
  508. ExpectSignature;
  509. ExpectFlags([],0);
  510. ExpectBareString('TEnumComponent');
  511. ExpectBareString('TestTEnumComponent');
  512. ExpectBareString('Dice');
  513. ExpectIdent('four');
  514. ExpectEndOfList;
  515. ExpectEndOfList;
  516. Finally
  517. C.Free;
  518. end;
  519. end;
  520. Procedure TTestComponentStream.TestTEnumComponent2;
  521. Var
  522. C : TComponent;
  523. begin
  524. C:=TEnumComponent2.Create(Nil);
  525. Try
  526. SaveToStream(C);
  527. ExpectSignature;
  528. ExpectFlags([],0);
  529. ExpectBareString('TEnumComponent2');
  530. ExpectBareString('TestTEnumComponent2');
  531. ExpectBareString('Dice');
  532. ExpectIdent('one');
  533. ExpectEndOfList;
  534. ExpectEndOfList;
  535. Finally
  536. C.Free;
  537. end;
  538. end;
  539. Procedure TTestComponentStream.TestTEnumComponent3;
  540. Var
  541. C : TComponent;
  542. begin
  543. C:=TEnumComponent3.Create(Nil);
  544. Try
  545. SaveToStream(C);
  546. ExpectSignature;
  547. ExpectFlags([],0);
  548. ExpectBareString('TEnumComponent3');
  549. ExpectBareString('TestTEnumComponent3');
  550. ExpectBareString('Dice');
  551. ExpectIdent('three');
  552. ExpectEndOfList;
  553. ExpectEndOfList;
  554. Finally
  555. C.Free;
  556. end;
  557. end;
  558. Procedure TTestComponentStream.TestTEnumComponent4;
  559. Var
  560. C : TComponent;
  561. begin
  562. C:=TEnumComponent4.Create(Nil);
  563. Try
  564. SaveToStream(C);
  565. ExpectSignature;
  566. ExpectFlags([],0);
  567. ExpectBareString('TEnumComponent4');
  568. ExpectBareString('TestTEnumComponent4');
  569. ExpectEndOfList;
  570. ExpectEndOfList;
  571. Finally
  572. C.Free;
  573. end;
  574. end;
  575. Procedure TTestComponentStream.TestTSetComponent;
  576. Var
  577. C : TComponent;
  578. begin
  579. C:=TSetComponent.Create(Nil);
  580. Try
  581. SaveToStream(C);
  582. ExpectSignature;
  583. ExpectFlags([],0);
  584. ExpectBareString('TSetComponent');
  585. ExpectBareString('TestTSetComponent');
  586. ExpectBareString('Throw');
  587. ExpectValue(vaSet);
  588. ExpectBareString('two');
  589. ExpectBareString('five');
  590. ExpectBareString('');
  591. ExpectEndOfList;
  592. ExpectEndOfList;
  593. Finally
  594. C.Free;
  595. end;
  596. end;
  597. Procedure TTestComponentStream.TestTSetComponent2;
  598. Var
  599. C : TComponent;
  600. begin
  601. C:=TSetComponent2.Create(Nil);
  602. Try
  603. SaveToStream(C);
  604. ExpectSignature;
  605. ExpectFlags([],0);
  606. ExpectBareString('TSetComponent2');
  607. ExpectBareString('TestTSetComponent2');
  608. ExpectBareString('Throw');
  609. ExpectValue(vaSet);
  610. ExpectBareString('');
  611. ExpectEndOfList;
  612. ExpectEndOfList;
  613. Finally
  614. C.Free;
  615. end;
  616. end;
  617. Procedure TTestComponentStream.TestTSetComponent3;
  618. Var
  619. C : TComponent;
  620. begin
  621. C:=TSetComponent3.Create(Nil);
  622. Try
  623. SaveToStream(C);
  624. ExpectSignature;
  625. ExpectFlags([],0);
  626. ExpectBareString('TSetComponent3');
  627. ExpectBareString('TestTSetComponent3');
  628. ExpectBareString('Throw');
  629. ExpectValue(vaSet);
  630. ExpectBareString('one');
  631. ExpectBareString('four');
  632. ExpectBareString('');
  633. ExpectEndOfList;
  634. ExpectEndOfList;
  635. Finally
  636. C.Free;
  637. end;
  638. end;
  639. Procedure TTestComponentStream.TestTSetComponent4;
  640. Var
  641. C : TComponent;
  642. begin
  643. C:=TSetComponent4.Create(Nil);
  644. Try
  645. SaveToStream(C);
  646. ExpectSignature;
  647. ExpectFlags([],0);
  648. ExpectBareString('TSetComponent4');
  649. ExpectBareString('TestTSetComponent4');
  650. ExpectEndOfList;
  651. ExpectEndOfList;
  652. Finally
  653. C.Free;
  654. end;
  655. end;
  656. Procedure TTestComponentStream.TestTMultipleComponent;
  657. Var
  658. C : TComponent;
  659. begin
  660. C:=TMultipleComponent.Create(Nil);
  661. Try
  662. SaveToStream(C);
  663. ExpectSignature;
  664. ExpectFlags([],0);
  665. ExpectBareString('TMultipleComponent');
  666. ExpectBareString('TestTMultipleComponent');
  667. ExpectBareString('IntProp');
  668. ExpectInteger(1);
  669. ExpectBareString('StringProp');
  670. ExpectString('A String');
  671. ExpectBareString('CurrencyProp');
  672. ExpectExtended(2.30);
  673. ExpectBareString('Dice');
  674. ExpectIdent('two');
  675. ExpectBareString('Throw');
  676. ExpectValue(vaSet);
  677. ExpectBareString('three');
  678. ExpectBareString('four');
  679. ExpectBareString('');
  680. ExpectEndOfList;
  681. ExpectEndOfList;
  682. Finally
  683. C.Free;
  684. end;
  685. end;
  686. Procedure TTestComponentStream.TestTPersistentComponent;
  687. Var
  688. C : TComponent;
  689. begin
  690. C:=TPersistentComponent.Create(Nil);
  691. Try
  692. SaveToStream(C);
  693. ExpectSignature;
  694. ExpectFlags([],0);
  695. ExpectBareString('TPersistentComponent');
  696. ExpectBareString('TestTPersistentComponent');
  697. ExpectBareString('Persist.AInteger');
  698. ExpectInteger(3);
  699. ExpectBareString('Persist.AString');
  700. ExpectString('A persistent string');
  701. ExpectEndOfList;
  702. ExpectEndOfList;
  703. Finally
  704. C.Free;
  705. end;
  706. end;
  707. Procedure TTestComponentStream.TestTCollectionComponent;
  708. Var
  709. C : TComponent;
  710. begin
  711. C:=TCollectionComponent.Create(Nil);
  712. Try
  713. SaveToStream(C);
  714. ExpectSignature;
  715. ExpectFlags([],0);
  716. ExpectBareString('TCollectionComponent');
  717. ExpectBareString('TestTCollectionComponent');
  718. ExpectBareString('Coll');
  719. ExpectValue(vaCollection);
  720. ExpectEndOfList;
  721. ExpectEndOfList;
  722. ExpectEndOfList;
  723. Finally
  724. C.Free;
  725. end;
  726. end;
  727. Procedure TTestComponentStream.TestTCollectionComponent2;
  728. Var
  729. C : TComponent;
  730. begin
  731. C:=TCollectionComponent2.Create(Nil);
  732. Try
  733. SaveToStream(C);
  734. ExpectSignature;
  735. ExpectFlags([],0);
  736. ExpectBareString('TCollectionComponent2');
  737. ExpectBareString('TestTCollectionComponent2');
  738. ExpectBareString('Coll');
  739. ExpectValue(vaCollection);
  740. ExpectValue(vaList);
  741. ExpectBareString('StrProp');
  742. ExpectString('First');
  743. ExpectEndOfList;
  744. ExpectValue(vaList);
  745. ExpectBareString('StrProp');
  746. ExpectString('Second');
  747. ExpectEndOfList;
  748. ExpectValue(vaList);
  749. ExpectBareString('StrProp');
  750. ExpectString('Third');
  751. ExpectEndOfList;
  752. ExpectEndOfList;
  753. ExpectEndOfList;
  754. ExpectEndOfList;
  755. Finally
  756. C.Free;
  757. end;
  758. end;
  759. Procedure TTestComponentStream.TestTCollectionComponent3;
  760. Var
  761. C : TComponent;
  762. begin
  763. C:=TCollectionComponent3.Create(Nil);
  764. Try
  765. SaveToStream(C);
  766. ExpectSignature;
  767. ExpectFlags([],0);
  768. ExpectBareString('TCollectionComponent3');
  769. ExpectBareString('TestTCollectionComponent3');
  770. ExpectBareString('Coll');
  771. ExpectValue(vaCollection);
  772. ExpectValue(vaList);
  773. ExpectBareString('StrProp');
  774. ExpectString('First');
  775. ExpectEndOfList;
  776. ExpectValue(vaList);
  777. ExpectEndOfList;
  778. ExpectValue(vaList);
  779. ExpectBareString('StrProp');
  780. ExpectString('Third');
  781. ExpectEndOfList;
  782. ExpectEndOfList;
  783. ExpectEndOfList;
  784. ExpectEndOfList;
  785. Finally
  786. C.Free;
  787. end;
  788. end;
  789. Procedure TTestComponentStream.TestTCollectionComponent4;
  790. Var
  791. C : TComponent;
  792. begin
  793. C:=TCollectionComponent4.Create(Nil);
  794. Try
  795. SaveToStream(C);
  796. ExpectSignature;
  797. ExpectFlags([],0);
  798. ExpectBareString('TCollectionComponent4');
  799. ExpectBareString('TestTCollectionComponent4');
  800. ExpectBareString('Coll');
  801. ExpectValue(vaCollection);
  802. ExpectValue(vaList);
  803. ExpectBareString('StrProp');
  804. ExpectString('Something');
  805. ExpectEndOfList;
  806. ExpectEndOfList;
  807. ExpectEndOfList;
  808. ExpectEndOfList;
  809. Finally
  810. C.Free;
  811. end;
  812. end;
  813. Procedure TTestComponentStream.TestTOwnedComponent;
  814. Var
  815. C : TComponent;
  816. begin
  817. C:=TOwnedComponent.Create(Nil);
  818. Try
  819. SaveToStream(C);
  820. ExpectSignature;
  821. ExpectFlags([],0);
  822. ExpectBareString('TOwnedComponent');
  823. ExpectBareString('TestTOwnedComponent');
  824. ExpectBareString('CompProp');
  825. ExpectIdent('SubComponent');
  826. ExpectEndOfList;
  827. ExpectEndOfList;
  828. Finally
  829. C.Free;
  830. end;
  831. end;
  832. Procedure TTestComponentStream.TestTStreamedOwnedComponent;
  833. Var
  834. C : TComponent;
  835. begin
  836. C:=TStreamedOwnedComponent.Create(Nil);
  837. Try
  838. SaveToStream(C);
  839. ExpectSignature;
  840. ExpectFlags([],0);
  841. ExpectBareString('TStreamedOwnedComponent');
  842. ExpectBareString('TestTStreamedOwnedComponent');
  843. ExpectEndOfList;
  844. ExpectFlags([],0);
  845. ExpectBareString('TIntegerComponent');
  846. ExpectBareString('Sub');
  847. ExpectBareString('IntProp');
  848. ExpectInteger(3);
  849. ExpectEndOfList;
  850. ExpectEndOfList;
  851. ExpectEndOfList;
  852. Finally
  853. C.Free;
  854. end;
  855. end;
  856. Procedure TTestComponentStream.TestTMethodComponent;
  857. Var
  858. C : TComponent;
  859. begin
  860. C:=TMethodComponent.Create(Nil);
  861. Try
  862. SaveToStream(C);
  863. ExpectSignature;
  864. ExpectFlags([],0);
  865. ExpectBareString('TMethodComponent');
  866. ExpectBareString('TestTMethodComponent');
  867. ExpectBareString('MethodProp');
  868. ExpectIdent('MyMethod');
  869. ExpectEndOfList;
  870. ExpectEndOfList;
  871. Finally
  872. C.Free;
  873. end;
  874. end;
  875. Procedure TTestComponentStream.TestTMethodComponent2;
  876. Var
  877. C : TComponent;
  878. begin
  879. C:=TMethodComponent2.Create(Nil);
  880. Try
  881. SaveToStream(C);
  882. ExpectSignature;
  883. ExpectFlags([],0);
  884. ExpectBareString('TMethodComponent2');
  885. ExpectBareString('TestTMethodComponent2');
  886. ExpectEndOfList;
  887. ExpectFlags([],0);
  888. ExpectBareString('TMethodComponent');
  889. ExpectBareString('AComponent');
  890. ExpectBareString('MethodProp');
  891. ExpectIdent('MyMethod2');
  892. ExpectEndOfList;
  893. ExpectEndOfList;
  894. ExpectEndOfList;
  895. Finally
  896. C.Free;
  897. end;
  898. end;
  899. end.