PageRenderTime 1776ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/as3-commons-ui/src/test/actionscript/org/as3commons/ui/lifecycle/i10n/tests/I10NAdapterTest.as

http://as3-commons.googlecode.com/
ActionScript | 1299 lines | 997 code | 265 blank | 37 comment | 38 complexity | 12931bdc4f4a81e1a6126b50cad3487a MD5 | raw file
Possible License(s): Apache-2.0
  1. package org.as3commons.ui.lifecycle.i10n.tests {
  2. import org.as3commons.collections.utils.ArrayUtils;
  3. import org.as3commons.ui.framework.uiservice.errors.AdapterNotRegisteredError;
  4. import org.as3commons.ui.lifecycle.i10n.I10N;
  5. import org.as3commons.ui.lifecycle.i10n.errors.PhaseDoesNotExistError;
  6. import org.as3commons.ui.lifecycle.i10n.errors.ValidateNowInRunningCycleError;
  7. import org.as3commons.ui.lifecycle.i10n.testhelper.I10NCallbackWatcher;
  8. import org.as3commons.ui.lifecycle.i10n.testhelper.TestI10NAdapter;
  9. import org.as3commons.ui.lifecycle.testhelper.AsyncCallback;
  10. import org.as3commons.ui.testhelper.TestDisplayObject;
  11. import org.flexunit.asserts.assertEquals;
  12. import org.flexunit.asserts.assertFalse;
  13. import org.flexunit.asserts.assertNotNull;
  14. import org.flexunit.asserts.assertTrue;
  15. import flash.display.DisplayObject;
  16. import flash.display.Sprite;
  17. import flash.events.Event;
  18. /**
  19. * @author Jens Struwe 13.09.2011
  20. */
  21. public class I10NAdapterTest {
  22. private var _i10n : I10N;
  23. private var _watcher : I10NCallbackWatcher;
  24. [Before]
  25. public function setUp() : void {
  26. _i10n = new I10N();
  27. _i10n.addPhase("phase1", I10N.PHASE_ORDER_TOP_DOWN);
  28. _i10n.addPhase("phase2", I10N.PHASE_ORDER_BOTTOM_UP);
  29. _i10n.addPhase("phase3", I10N.PHASE_ORDER_TOP_DOWN);
  30. _i10n.start();
  31. _watcher = new I10NCallbackWatcher();
  32. }
  33. [After]
  34. public function tearDown() : void {
  35. _i10n.cleanUp();
  36. _i10n = null;
  37. _watcher = null;
  38. StageProxy.cleanUpRoot();
  39. }
  40. private function setUpCompleteTimer(callback : Function) : void {
  41. AsyncCallback.setUpCompleteTimer(this, callback);
  42. }
  43. [Test(async)]
  44. public function test_invalidate() : void {
  45. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  46. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  47. _i10n.registerDisplayObject(s, adapter);
  48. adapter.invalidate("phase1");
  49. adapter.invalidate("phase2");
  50. adapter.invalidate("phase3");
  51. setUpCompleteTimer(complete);
  52. function complete(event : Event, data : * = null) : void {
  53. assertTrue(ArrayUtils.arraysEqual([
  54. s, "phase1",
  55. s, "phase2",
  56. s, "phase3"
  57. ], _watcher.validateLog));
  58. }
  59. }
  60. [Test]
  61. public function test_invalidate_beforeRegistrationThrowsError() : void {
  62. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  63. var errorThrown : Error;
  64. try {
  65. adapter.invalidate("phase1");
  66. } catch (e : Error) {
  67. errorThrown = e;
  68. }
  69. assertNotNull(errorThrown);
  70. assertTrue(errorThrown is AdapterNotRegisteredError);
  71. }
  72. [Test(async)]
  73. public function test_invalidate_multipleTimes() : void {
  74. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  75. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  76. _i10n.registerDisplayObject(s, adapter);
  77. adapter.invalidate("phase1");
  78. adapter.invalidate("phase1");
  79. adapter.invalidate("phase1");
  80. setUpCompleteTimer(complete);
  81. function complete(event : Event, data : * = null) : void {
  82. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  83. adapter.invalidate("phase2");
  84. adapter.invalidate("phase2");
  85. adapter.invalidate("phase2");
  86. setUpCompleteTimer(complete2);
  87. }
  88. function complete2(event : Event, data : * = null) : void {
  89. assertTrue(ArrayUtils.arraysEqual([s, "phase2"], _watcher.validateLog));
  90. }
  91. }
  92. [Test(async)]
  93. public function test_invalidate_wrongPhaseThrowsError() : void {
  94. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  95. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  96. _i10n.registerDisplayObject(s, adapter);
  97. adapter.invalidate("phase1");
  98. adapter.invalidate("phase2");
  99. var errorThrown : Error;
  100. try {
  101. adapter.invalidate("phaseWrong");
  102. } catch (e : Error) {
  103. errorThrown = e;
  104. }
  105. assertNotNull(errorThrown);
  106. assertTrue(errorThrown is PhaseDoesNotExistError);
  107. }
  108. [Test(async)]
  109. public function test_invalidate_validateCalledOncePerPhase() : void {
  110. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  111. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  112. _i10n.registerDisplayObject(s, adapter);
  113. adapter.invalidate("phase1");
  114. adapter.invalidate("phase1");
  115. adapter.invalidate("phase2");
  116. adapter.invalidate("phase2");
  117. adapter.invalidate("phase3");
  118. adapter.invalidate("phase3");
  119. setUpCompleteTimer(complete);
  120. function complete(event : Event, data : * = null) : void {
  121. assertTrue(ArrayUtils.arraysEqual([s, "phase1", s, "phase2", s, "phase3"], _watcher.validateLog));
  122. }
  123. }
  124. [Test(async)]
  125. public function test_invalidate_validateCalledOncePerPhase2() : void {
  126. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  127. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  128. adapter.validateFunction = validate;
  129. _i10n.registerDisplayObject(s, adapter);
  130. adapter.invalidate("phase1");
  131. adapter.invalidate("phase2");
  132. adapter.invalidate("phase3");
  133. setUpCompleteTimer(complete);
  134. function validate(phaseName : String) : void {
  135. if (adapter.validateCountForPhase(phaseName)) return;
  136. if (phaseName == "phase1") adapter.invalidate("phase2");
  137. if (phaseName == "phase1") adapter.invalidate("phase3");
  138. if (phaseName == "phase2") adapter.invalidate("phase3");
  139. }
  140. function complete(event : Event, data : * = null) : void {
  141. assertEquals(1, adapter.validateCountForPhase("phase1"));
  142. assertEquals(1, adapter.validateCountForPhase("phase2"));
  143. assertEquals(1, adapter.validateCountForPhase("phase3"));
  144. assertTrue(ArrayUtils.arraysEqual([s, "phase1", s, "phase2", s, "phase3"], _watcher.validateLog));
  145. }
  146. }
  147. [Test(async)]
  148. public function test_invalidate_inValidation() : void {
  149. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  150. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  151. adapter.validateFunction = validate;
  152. _i10n.registerDisplayObject(s, adapter);
  153. adapter.invalidate("phase1");
  154. adapter.invalidate("phase2");
  155. adapter.invalidate("phase3");
  156. setUpCompleteTimer(complete);
  157. function validate(phaseName : String) : void {
  158. if (adapter.validateCountForPhase(phaseName)) return;
  159. if (phaseName == "phase1") adapter.invalidate("phase2");
  160. if (phaseName == "phase1") adapter.invalidate("phase3");
  161. if (phaseName == "phase2") adapter.invalidate("phase3");
  162. if (phaseName == "phase2") adapter.invalidate("phase1");
  163. if (phaseName == "phase3") adapter.invalidate("phase1");
  164. }
  165. function complete(event : Event, data : * = null) : void {
  166. assertEquals(3, adapter.validateCountForPhase("phase1"));
  167. assertEquals(1, adapter.validateCountForPhase("phase2"));
  168. assertEquals(1, adapter.validateCountForPhase("phase3"));
  169. assertTrue(ArrayUtils.arraysEqual([
  170. s, "phase1", s, "phase2", s, "phase1", s, "phase3", s, "phase1"
  171. ], _watcher.validateLog));
  172. }
  173. }
  174. [Test(async)]
  175. public function test_invalidate_inRenderHandler() : void {
  176. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  177. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  178. _i10n.registerDisplayObject(s, adapter);
  179. AsyncCallback.setUpRenderTimer(this, invalidate);
  180. function invalidate(event : Event, data : * = null) : void {
  181. adapter.invalidate("phase1");
  182. adapter.invalidate("phase2");
  183. adapter.invalidate("phase3");
  184. setUpCompleteTimer(complete);
  185. }
  186. function complete(event : Event, data : * = null) : void {
  187. assertTrue(ArrayUtils.arraysEqual([
  188. s, "phase1", s, "phase2", s, "phase3"
  189. ], _watcher.validateLog));
  190. }
  191. }
  192. [Test(async)]
  193. public function test_invalidate_inValidation_currentPhase() : void {
  194. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  195. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  196. adapter.validateFunction = validate;
  197. _i10n.registerDisplayObject(s, adapter);
  198. adapter.invalidate("phase1");
  199. adapter.invalidate("phase2");
  200. setUpCompleteTimer(complete);
  201. function validate(phaseName : String) : void {
  202. if (!adapter.validateCountForPhase(phaseName)) {
  203. adapter.invalidate(phaseName);
  204. }
  205. }
  206. function complete(event : Event, data : * = null) : void {
  207. var log : Array = _watcher.validateLog;
  208. assertTrue(ArrayUtils.arraysEqual([
  209. s, "phase1",
  210. s, "phase1",
  211. s, "phase2",
  212. s, "phase2"
  213. ], log));
  214. }
  215. }
  216. [Test(async)]
  217. public function test_invalidate_inValidation_currentPhase2() : void {
  218. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  219. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  220. adapter.validateFunction = validate;
  221. _i10n.registerDisplayObject(s, adapter);
  222. adapter.invalidate("phase1");
  223. adapter.invalidate("phase2");
  224. setUpCompleteTimer(complete);
  225. function validate(phaseName : String) : void {
  226. if (!adapter.validateCountForPhase(phaseName)) {
  227. adapter.invalidate("phase1");
  228. adapter.invalidate("phase2");
  229. }
  230. }
  231. function complete(event : Event, data : * = null) : void {
  232. var log : Array = _watcher.validateLog;
  233. assertTrue(ArrayUtils.arraysEqual([
  234. s, "phase1",
  235. s, "phase1",
  236. s, "phase2",
  237. s, "phase1",
  238. s, "phase2"
  239. ], log));
  240. }
  241. }
  242. [Test(async)]
  243. public function test_invalidate_inValidation_allProperties() : void {
  244. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  245. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  246. adapter.validateFunction = validate;
  247. _i10n.registerDisplayObject(s, adapter);
  248. adapter.invalidate("phase1", "test");
  249. adapter.invalidate("phase2");
  250. var results : Array = new Array();
  251. storeResults("phase1");
  252. storeResults("phase2");
  253. setUpCompleteTimer(complete);
  254. function validate(phaseName : String) : void {
  255. if (!adapter.validateCountForPhase(phaseName)) {
  256. storeResults(phaseName);
  257. if (phaseName == "phase1") adapter.invalidate("phase1");
  258. if (phaseName == "phase2") adapter.invalidate("phase2", "test");
  259. storeResults(phaseName);
  260. }
  261. if (adapter.validateCountForPhase(phaseName)) {
  262. storeResults(phaseName);
  263. }
  264. }
  265. function storeResults(phaseName : String) : void {
  266. results.push(
  267. adapter.isInvalid(),
  268. adapter.isInvalid(phaseName),
  269. adapter.isInvalid(phaseName, "test"),
  270. adapter.isInvalid(phaseName, "test2"),
  271. adapter.isInvalid(phaseName, "all_properties")
  272. );
  273. }
  274. function complete(event : Event, data : * = null) : void {
  275. assertTrue(ArrayUtils.arraysEqual([
  276. // immediately phase1
  277. true, true, true, false, false,
  278. // immediately phase2
  279. true, true, true, true, true,
  280. // phase1 first run1
  281. true, true, true, false, false,
  282. // phase1 first run2
  283. true, true, true, true, true,
  284. // phase 2 first run1
  285. true, true, true, true, true,
  286. // phase 2 first run2
  287. true, true, true, true, true,
  288. // phase1 second
  289. true, true, true, true, true,
  290. // phase2 second
  291. true, true, true, false, false
  292. ], results));
  293. }
  294. }
  295. [Test(async)]
  296. /*
  297. * s (validateNow -> invalidate s2, s3)
  298. * -- s2
  299. * s3
  300. * -- s4
  301. */
  302. public function test_invalidate_others_inValidateNow() : void {
  303. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  304. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  305. adapter.validateFunction = validate;
  306. _i10n.registerDisplayObject(s, adapter);
  307. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  308. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  309. _i10n.registerDisplayObject(s2, adapter2);
  310. var s3 : Sprite = StageProxy.root.addChild(new TestDisplayObject("s3")) as Sprite;
  311. var adapter3 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  312. _i10n.registerDisplayObject(s3, adapter3);
  313. adapter.invalidate("phase1");
  314. adapter.validateNow();
  315. assertTrue(ArrayUtils.arraysEqual([s, "phase1", s2, "phase1"], _watcher.validateLog));
  316. setUpCompleteTimer(complete);
  317. function validate(phaseName : String) : void {
  318. adapter2.invalidate("phase1");
  319. adapter3.invalidate("phase1");
  320. }
  321. function complete(event : Event, data : * = null) : void {
  322. assertTrue(ArrayUtils.arraysEqual([s3, "phase1"], _watcher.validateLog));
  323. }
  324. }
  325. [Test(async)]
  326. /*
  327. * s
  328. * -- s2 (validateNow -> invalidate s, s3)
  329. * -- -- s3
  330. */
  331. public function test_invalidate_others_inValidateNow2() : void {
  332. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  333. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  334. _i10n.registerDisplayObject(s, adapter);
  335. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  336. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  337. adapter2.validateFunction = validate;
  338. _i10n.registerDisplayObject(s2, adapter2);
  339. var s3 : Sprite = s2.addChild(new TestDisplayObject("s3")) as Sprite;
  340. var adapter3 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  341. _i10n.registerDisplayObject(s3, adapter3);
  342. adapter2.invalidate("phase1");
  343. adapter2.validateNow();
  344. assertTrue(ArrayUtils.arraysEqual([s2, "phase1", s3, "phase1"], _watcher.validateLog));
  345. setUpCompleteTimer(complete);
  346. function validate(phaseName : String) : void {
  347. adapter.invalidate("phase1");
  348. adapter3.invalidate("phase1");
  349. }
  350. function complete(event : Event, data : * = null) : void {
  351. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  352. }
  353. }
  354. [Test(async)]
  355. public function test_invalidate_notOnStage() : void {
  356. var s : DisplayObject = new TestDisplayObject("s");
  357. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  358. _i10n.registerDisplayObject(s, adapter);
  359. adapter.invalidate("phase1");
  360. setUpCompleteTimer(complete);
  361. function complete(event : Event, data : * = null) : void {
  362. assertTrue(ArrayUtils.arraysEqual([], _watcher.validateLog));
  363. }
  364. }
  365. [Test(async)]
  366. public function test_invalidate_notOnStage_autoAdd() : void {
  367. var s : DisplayObject = new TestDisplayObject("s");
  368. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  369. _i10n.registerDisplayObject(s, adapter);
  370. adapter.invalidate("phase1");
  371. setUpCompleteTimer(complete);
  372. function complete(event : Event, data : * = null) : void {
  373. assertTrue(ArrayUtils.arraysEqual([], _watcher.validateLog));
  374. StageProxy.root.addChild(s);
  375. setUpCompleteTimer(complete2);
  376. }
  377. function complete2(event : Event, data : * = null) : void {
  378. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  379. }
  380. }
  381. [Test(async)]
  382. public function test_invalidate_removedFromStageinValidation() : void {
  383. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  384. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  385. adapter.validateFunction = validate;
  386. _i10n.registerDisplayObject(s, adapter);
  387. adapter.invalidate("phase1");
  388. adapter.invalidate("phase2");
  389. adapter.invalidate("phase2");
  390. setUpCompleteTimer(complete);
  391. function validate(phaseName : String) : void {
  392. if (phaseName == "phase1") {
  393. StageProxy.root.removeChild(s);
  394. }
  395. }
  396. function complete(event : Event, data : * = null) : void {
  397. var log : Array = _watcher.validateLog;
  398. assertTrue(log, ArrayUtils.arraysEqual([
  399. s, "phase1"
  400. ], log));
  401. }
  402. }
  403. [Test(async)]
  404. public function test_invalidate_addedToStageinValidation() : void {
  405. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  406. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  407. adapter.validateFunction = validate;
  408. _i10n.registerDisplayObject(s, adapter);
  409. adapter.invalidate("phase1");
  410. adapter.invalidate("phase2");
  411. var s2 : DisplayObject = new TestDisplayObject("s2");
  412. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  413. _i10n.registerDisplayObject(s2, adapter2);
  414. adapter2.invalidate("phase1");
  415. adapter2.invalidate("phase2");
  416. setUpCompleteTimer(complete);
  417. function validate(phaseName : String) : void {
  418. if (phaseName == "phase2") {
  419. StageProxy.root.addChild(s2);
  420. }
  421. }
  422. function complete(event : Event, data : * = null) : void {
  423. var log : Array = _watcher.validateLog;
  424. assertTrue(ArrayUtils.arraysEqual([
  425. s, "phase1",
  426. s, "phase2",
  427. s2, "phase1",
  428. s2, "phase2"
  429. ], log));
  430. }
  431. }
  432. [Test(async)]
  433. public function test_invalidate_removedAndAddedToStageinValidation() : void {
  434. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  435. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  436. adapter.validateFunction = validate;
  437. _i10n.registerDisplayObject(s, adapter);
  438. adapter.invalidate("phase1");
  439. adapter.invalidate("phase2");
  440. adapter.invalidate("phase3");
  441. var s2 : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s2"));
  442. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  443. _i10n.registerDisplayObject(s2, adapter2);
  444. adapter2.invalidate("phase1");
  445. adapter2.invalidate("phase2");
  446. adapter2.invalidate("phase3");
  447. setUpCompleteTimer(complete);
  448. function validate(phaseName : String) : void {
  449. if (phaseName == "phase2") {
  450. StageProxy.root.removeChild(s2);
  451. }
  452. if (phaseName == "phase3") {
  453. StageProxy.root.addChild(s2);
  454. }
  455. }
  456. function complete(event : Event, data : * = null) : void {
  457. var log : Array = _watcher.validateLog;
  458. assertTrue(ArrayUtils.arraysEqual([
  459. s, "phase1",
  460. s2, "phase1",
  461. s, "phase2",
  462. s, "phase3",
  463. s2, "phase2",
  464. s2, "phase3"
  465. ], log));
  466. }
  467. }
  468. [Test(async)]
  469. public function test_invalidate_removedFromStage_autoAdd() : void {
  470. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  471. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  472. _i10n.registerDisplayObject(s, adapter);
  473. adapter.invalidate("phase1");
  474. StageProxy.root.removeChild(s);
  475. setUpCompleteTimer(complete);
  476. function complete(event : Event, data : * = null) : void {
  477. assertTrue(ArrayUtils.arraysEqual([], _watcher.validateLog));
  478. StageProxy.root.addChild(s);
  479. setUpCompleteTimer(complete2);
  480. }
  481. function complete2(event : Event, data : * = null) : void {
  482. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  483. }
  484. }
  485. [Test(async)]
  486. public function test_invalidate_properties() : void {
  487. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  488. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  489. adapter.validateFunction = validate;
  490. _i10n.registerDisplayObject(s, adapter);
  491. adapter.invalidate("phase1", "test");
  492. var results : Array;
  493. storeResults();
  494. complete(null);
  495. setUpCompleteTimer(complete);
  496. function storeResults() : void {
  497. results = [
  498. adapter.isInvalid(),
  499. adapter.isInvalid("phase1"),
  500. adapter.isInvalid("phase1", "test"),
  501. adapter.isInvalid("phase1", "test2"),
  502. adapter.isInvalid("phase1", "all_properties"),
  503. adapter.isInvalid("phase2"),
  504. adapter.isInvalid("phase2", "test"),
  505. adapter.isInvalid("phase2", "test2")
  506. ];
  507. }
  508. function validate(phaseName : String) : void {
  509. storeResults();
  510. }
  511. function complete(event : Event, data : * = null) : void {
  512. assertTrue(ArrayUtils.arraysEqual([
  513. true,
  514. true,
  515. true,
  516. false,
  517. false,
  518. false,
  519. false,
  520. false
  521. ], results));
  522. }
  523. }
  524. [Test(async)]
  525. public function test_invalidate_allProperties() : void {
  526. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  527. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  528. adapter.validateFunction = validate;
  529. _i10n.registerDisplayObject(s, adapter);
  530. adapter.invalidate("phase1");
  531. var results : Array;
  532. storeResults();
  533. complete(null);
  534. setUpCompleteTimer(complete);
  535. function storeResults() : void {
  536. results = [
  537. adapter.isInvalid(),
  538. adapter.isInvalid("phase1"),
  539. adapter.isInvalid("phase1", "test"),
  540. adapter.isInvalid("phase1", "test2"),
  541. adapter.isInvalid("phase1", "all_properties"),
  542. adapter.isInvalid("phase2"),
  543. adapter.isInvalid("phase2", "test"),
  544. adapter.isInvalid("phase2", "test2")
  545. ];
  546. }
  547. function validate(phaseName : String) : void {
  548. storeResults();
  549. }
  550. function complete(event : Event, data : * = null) : void {
  551. assertTrue(ArrayUtils.arraysEqual([
  552. true,
  553. true,
  554. true,
  555. true,
  556. true,
  557. false,
  558. false,
  559. false
  560. ], results));
  561. }
  562. }
  563. [Test(async)]
  564. public function test_invalidate_allProperties2() : void {
  565. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  566. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  567. adapter.validateFunction = storeResults;
  568. _i10n.registerDisplayObject(s, adapter);
  569. adapter.invalidate("phase1", "test");
  570. adapter.invalidate("phase1");
  571. adapter.invalidate("phase2");
  572. adapter.invalidate("phase2", "test");
  573. var results : Array = new Array();
  574. storeResults("phase1");
  575. storeResults("phase2");
  576. storeResults("phase3");
  577. setUpCompleteTimer(complete);
  578. function storeResults(phaseName : String) : void {
  579. results.push(
  580. adapter.isInvalid(),
  581. adapter.isInvalid(phaseName),
  582. adapter.isInvalid(phaseName, "test"),
  583. adapter.isInvalid(phaseName, "test2"),
  584. adapter.isInvalid(phaseName, "all_properties")
  585. );
  586. }
  587. function complete(event : Event, data : * = null) : void {
  588. storeResults("phase3");
  589. assertTrue(ArrayUtils.arraysEqual([
  590. // immediately phase1
  591. true, true, true, true, true,
  592. // immediately phase2
  593. true, true, true, true, true,
  594. // immediately phase3
  595. true, false, false, false, false,
  596. // in validation phase1
  597. true, true, true, true, true,
  598. // in validation phase2
  599. true, true, true, true, true,
  600. // after validation phase3
  601. false, false, false, false, false
  602. ], results));
  603. }
  604. }
  605. [Test(async)]
  606. public function test_invalidate_propertiesRemovedAfterPhase() : void {
  607. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  608. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  609. adapter.validateFunction = validate;
  610. _i10n.registerDisplayObject(s, adapter);
  611. adapter.invalidate("phase1", "test");
  612. adapter.invalidate("phase1", "test2");
  613. adapter.invalidate("phase2");
  614. var results : Array = new Array();
  615. setUpCompleteTimer(complete);
  616. function validate(phaseName : String) : void {
  617. results.push(
  618. adapter.isInvalid(),
  619. adapter.isInvalid("phase1"),
  620. adapter.isInvalid("phase1", "test"),
  621. adapter.isInvalid("phase1", "test2")
  622. );
  623. }
  624. function complete(event : Event, data : * = null) : void {
  625. assertTrue(ArrayUtils.arraysEqual([
  626. // from phase 1
  627. true,
  628. true,
  629. true,
  630. true,
  631. // from phase 2
  632. true,
  633. false,
  634. false,
  635. false
  636. ], results));
  637. }
  638. }
  639. [Test(async)]
  640. /*
  641. * Reinvalidation in phase 2
  642. */
  643. public function test_invalidate_propertiesRemovedAfterPhase2() : void {
  644. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  645. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  646. adapter.validateFunction = validate;
  647. _i10n.registerDisplayObject(s, adapter);
  648. adapter.invalidate("phase1", "test");
  649. adapter.invalidate("phase1", "test2");
  650. adapter.invalidate("phase2");
  651. var results : Array = new Array();
  652. setUpCompleteTimer(complete);
  653. function validate(phaseName : String) : void {
  654. results.push(
  655. adapter.isInvalid(),
  656. adapter.isInvalid("phase1"),
  657. adapter.isInvalid("phase1", "test"),
  658. adapter.isInvalid("phase1", "test2")
  659. );
  660. if (phaseName == "phase2" && !adapter.validateCountForPhase("phase2")) {
  661. adapter.invalidate("phase1", "test");
  662. adapter.invalidate("phase1", "test2");
  663. adapter.invalidate("phase2");
  664. }
  665. }
  666. function complete(event : Event, data : * = null) : void {
  667. var log : Array = _watcher.validateLog;
  668. assertTrue(ArrayUtils.arraysEqual([
  669. s, "phase1",
  670. s, "phase2",
  671. s, "phase1",
  672. s, "phase2"
  673. ], log));
  674. assertTrue(ArrayUtils.arraysEqual([
  675. // from phase 1
  676. true,
  677. true,
  678. true,
  679. true,
  680. // from phase 2
  681. true,
  682. false,
  683. false,
  684. false,
  685. // from phase 1 - second run
  686. true,
  687. true,
  688. true,
  689. true,
  690. // from phase 2 - second run
  691. true,
  692. false,
  693. false,
  694. false
  695. ], results));
  696. }
  697. }
  698. [Test]
  699. public function test_isInvalid() : void {
  700. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  701. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  702. _i10n.registerDisplayObject(s, adapter);
  703. adapter.invalidate("phase1");
  704. adapter.invalidate("phase2", "test");
  705. assertTrue(adapter.isInvalid());
  706. assertTrue(adapter.isInvalid("phase1"));
  707. assertTrue(adapter.isInvalid("phase1", "test"));
  708. assertTrue(adapter.isInvalid("phase2", "test"));
  709. assertFalse(adapter.isInvalid("phase2", "test2"));
  710. assertFalse(adapter.isInvalid("phase3"));
  711. assertFalse(adapter.isInvalid("phase3", "test"));
  712. }
  713. [Test]
  714. public function test_isInvalid_beforeRegistrationThrowsError() : void {
  715. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  716. var errorThrown : Error;
  717. try {
  718. assertFalse(adapter.isInvalid());
  719. } catch (e : Error) {
  720. errorThrown = e;
  721. }
  722. assertNotNull(errorThrown);
  723. assertTrue(errorThrown is AdapterNotRegisteredError);
  724. errorThrown = null;
  725. try {
  726. assertFalse(adapter.isInvalid("phase1"));
  727. } catch (e : Error) {
  728. errorThrown = e;
  729. }
  730. assertNotNull(errorThrown);
  731. assertTrue(errorThrown is AdapterNotRegisteredError);
  732. errorThrown = null;
  733. try {
  734. assertFalse(adapter.isInvalid("phase1", "test"));
  735. } catch (e : Error) {
  736. errorThrown = e;
  737. }
  738. assertNotNull(errorThrown);
  739. assertTrue(errorThrown is AdapterNotRegisteredError);
  740. }
  741. [Test(async)]
  742. public function test_validateNow_inValidationThrowsError() : void {
  743. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  744. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  745. adapter.validateFunction = validate;
  746. _i10n.registerDisplayObject(s, adapter);
  747. adapter.invalidate("phase1");
  748. var errorThrown : Error;
  749. setUpCompleteTimer(complete);
  750. function validate(phaseName : String) : void {
  751. try {
  752. adapter.validateNow();
  753. } catch (e : Error) {
  754. errorThrown = e;
  755. }
  756. }
  757. function complete(event : Event, data : * = null) : void {
  758. assertNotNull(errorThrown);
  759. assertTrue(errorThrown is ValidateNowInRunningCycleError);
  760. }
  761. }
  762. [Test(async)]
  763. public function test_validateNow() : void {
  764. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  765. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  766. _i10n.registerDisplayObject(s, adapter);
  767. adapter.invalidate("phase1");
  768. adapter.validateNow();
  769. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  770. }
  771. [Test]
  772. public function test_validateNow_beforeRegistrationThrowsError() : void {
  773. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  774. var errorThrown : Error;
  775. try {
  776. adapter.validateNow();
  777. } catch (e : Error) {
  778. errorThrown = e;
  779. }
  780. assertNotNull(errorThrown);
  781. assertTrue(errorThrown is AdapterNotRegisteredError);
  782. }
  783. [Test(async)]
  784. public function test_validateNow_withoutInvalidation() : void {
  785. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  786. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  787. _i10n.registerDisplayObject(s, adapter);
  788. adapter.validateNow();
  789. assertTrue(ArrayUtils.arraysEqual([], _watcher.validateLog));
  790. }
  791. [Test(async)]
  792. public function test_validateNow_validatesOnlyTarget() : void {
  793. var s : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s"));
  794. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  795. _i10n.registerDisplayObject(s, adapter);
  796. var s2 : DisplayObject = StageProxy.root.addChild(new TestDisplayObject("s2"));
  797. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  798. _i10n.registerDisplayObject(s2, adapter2);
  799. adapter.invalidate("phase1");
  800. adapter2.invalidate("phase1");
  801. adapter.validateNow();
  802. assertTrue(ArrayUtils.arraysEqual([s, "phase1"], _watcher.validateLog));
  803. setUpCompleteTimer(complete);
  804. function complete(event : Event, data : * = null) : void {
  805. assertTrue(ArrayUtils.arraysEqual([s2, "phase1"], _watcher.validateLog));
  806. }
  807. }
  808. [Test(async)]
  809. public function test_validateNow_validatesOnlyTarget2() : void {
  810. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  811. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  812. _i10n.registerDisplayObject(s, adapter);
  813. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  814. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  815. _i10n.registerDisplayObject(s2, adapter2);
  816. var s3 : Sprite = StageProxy.root.addChild(new TestDisplayObject("s3")) as Sprite;
  817. var adapter3 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  818. _i10n.registerDisplayObject(s3, adapter3);
  819. var s4 : Sprite = s3.addChild(new TestDisplayObject("s4")) as Sprite;
  820. var adapter4 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  821. _i10n.registerDisplayObject(s4, adapter4);
  822. adapter.invalidate("phase1");
  823. adapter2.invalidate("phase1");
  824. adapter3.invalidate("phase1");
  825. adapter4.invalidate("phase1");
  826. adapter.validateNow();
  827. assertTrue(ArrayUtils.arraysEqual([s, "phase1", s2, "phase1"], _watcher.validateLog));
  828. setUpCompleteTimer(complete);
  829. function complete(event : Event, data : * = null) : void {
  830. assertTrue(ArrayUtils.arraysEqual([s3, "phase1", s4, "phase1"], _watcher.validateLog));
  831. }
  832. }
  833. [Test]
  834. public function test_onAddedToStage_onRemovedFromStage() : void {
  835. var s : Sprite = new TestDisplayObject("s");
  836. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  837. _i10n.registerDisplayObject(s, adapter);
  838. assertEquals(0, adapter.addedToStageCount);
  839. assertEquals(0, adapter.removedFromStageCount);
  840. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  841. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  842. StageProxy.root.addChild(s);
  843. assertEquals(1, adapter.addedToStageCount);
  844. assertEquals(0, adapter.removedFromStageCount);
  845. assertTrue(ArrayUtils.arraysEqual([s], _watcher.addedLog));
  846. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  847. StageProxy.root.removeChild(s);
  848. assertEquals(1, adapter.addedToStageCount);
  849. assertEquals(1, adapter.removedFromStageCount);
  850. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  851. assertTrue(ArrayUtils.arraysEqual([s], _watcher.removedLog));
  852. StageProxy.root.addChild(s);
  853. assertEquals(2, adapter.addedToStageCount);
  854. assertEquals(1, adapter.removedFromStageCount);
  855. assertTrue(ArrayUtils.arraysEqual([s], _watcher.addedLog));
  856. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  857. }
  858. [Test]
  859. public function test_onAddedToStage_onRemovedFromStage2() : void {
  860. var s : Sprite = new TestDisplayObject("s");
  861. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  862. _i10n.registerDisplayObject(s, adapter);
  863. adapter.invalidate("phase1");
  864. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  865. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  866. _i10n.registerDisplayObject(s2, adapter2);
  867. assertEquals(0, adapter.addedToStageCount);
  868. assertEquals(0, adapter.removedFromStageCount);
  869. assertEquals(0, adapter2.addedToStageCount);
  870. assertEquals(0, adapter2.removedFromStageCount);
  871. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  872. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  873. StageProxy.root.addChild(s);
  874. assertEquals(1, adapter.addedToStageCount);
  875. assertEquals(0, adapter.removedFromStageCount);
  876. assertEquals(1, adapter2.addedToStageCount);
  877. assertEquals(0, adapter2.removedFromStageCount);
  878. assertTrue(ArrayUtils.arraysEqual([s, s2], _watcher.addedLog));
  879. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  880. StageProxy.root.removeChild(s);
  881. assertEquals(1, adapter.addedToStageCount);
  882. assertEquals(1, adapter.removedFromStageCount);
  883. assertEquals(1, adapter.addedToStageCount);
  884. assertEquals(1, adapter.removedFromStageCount);
  885. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  886. assertTrue(ArrayUtils.arraysEqual([s, s2], _watcher.removedLog));
  887. StageProxy.root.addChild(s);
  888. assertEquals(2, adapter.addedToStageCount);
  889. assertEquals(1, adapter.removedFromStageCount);
  890. assertEquals(2, adapter.addedToStageCount);
  891. assertEquals(1, adapter.removedFromStageCount);
  892. assertTrue(ArrayUtils.arraysEqual([s, s2], _watcher.addedLog));
  893. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  894. }
  895. [Test(async)]
  896. public function test_onRemovedFromStage_onAddedToStage_inValidation() : void {
  897. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  898. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  899. adapter.validateFunction = validate;
  900. _i10n.registerDisplayObject(s, adapter);
  901. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  902. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  903. _i10n.registerDisplayObject(s2, adapter2);
  904. adapter.invalidate("phase1");
  905. assertEquals(0, adapter.addedToStageCount);
  906. assertEquals(0, adapter.removedFromStageCount);
  907. assertEquals(0, adapter2.addedToStageCount);
  908. assertEquals(0, adapter2.removedFromStageCount);
  909. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  910. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  911. setUpCompleteTimer(complete);
  912. function validate(phaseName : String) : void {
  913. if (!adapter.validateCount) { // else, it will schedule a second run
  914. StageProxy.root.removeChild(s);
  915. StageProxy.root.addChild(s);
  916. }
  917. }
  918. function complete(event : Event, data : * = null) : void {
  919. assertEquals("1a", 1, adapter.addedToStageCount);
  920. assertEquals("1r", 1, adapter.removedFromStageCount);
  921. assertEquals("2a", 1, adapter2.addedToStageCount);
  922. assertEquals("2r", 1, adapter2.removedFromStageCount);
  923. assertTrue(ArrayUtils.arraysEqual([s, s2], _watcher.addedLog));
  924. assertTrue(ArrayUtils.arraysEqual([s, s2], _watcher.removedLog));
  925. }
  926. }
  927. [Test]
  928. public function test_onRemovedFromStage_onAddedToStage_afterCleanUp() : void {
  929. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  930. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  931. _i10n.registerDisplayObject(s, adapter);
  932. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  933. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  934. _i10n.registerDisplayObject(s2, adapter2);
  935. assertEquals(0, adapter.addedToStageCount);
  936. assertEquals(0, adapter.removedFromStageCount);
  937. assertEquals(0, adapter2.addedToStageCount);
  938. assertEquals(0, adapter2.removedFromStageCount);
  939. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  940. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  941. _i10n.cleanUp();
  942. StageProxy.root.removeChild(s);
  943. StageProxy.root.addChild(s);
  944. assertEquals(0, adapter.addedToStageCount);
  945. assertEquals(0, adapter.removedFromStageCount);
  946. assertEquals(0, adapter2.addedToStageCount);
  947. assertEquals(0, adapter2.removedFromStageCount);
  948. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  949. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  950. }
  951. [Test]
  952. public function test_onRemovedFromStage_onAddedToStage_afterUnregister() : void {
  953. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  954. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  955. _i10n.registerDisplayObject(s, adapter);
  956. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  957. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  958. _i10n.registerDisplayObject(s2, adapter2);
  959. assertEquals(0, adapter.addedToStageCount);
  960. assertEquals(0, adapter.removedFromStageCount);
  961. assertEquals(0, adapter2.addedToStageCount);
  962. assertEquals(0, adapter2.removedFromStageCount);
  963. assertTrue(ArrayUtils.arraysEqual([], _watcher.addedLog));
  964. assertTrue(ArrayUtils.arraysEqual([], _watcher.removedLog));
  965. _i10n.unregisterDisplayObject(s);
  966. StageProxy.root.removeChild(s);
  967. StageProxy.root.addChild(s);
  968. assertEquals(0, adapter.addedToStageCount);
  969. assertEquals(0, adapter.removedFromStageCount);
  970. assertEquals(1, adapter2.addedToStageCount);
  971. assertEquals(1, adapter2.removedFromStageCount);
  972. assertTrue(ArrayUtils.arraysEqual([s2], _watcher.addedLog));
  973. assertTrue(ArrayUtils.arraysEqual([s2], _watcher.removedLog));
  974. }
  975. [Test]
  976. public function test_nestLevel() : void {
  977. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  978. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  979. _i10n.registerDisplayObject(s, adapter);
  980. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  981. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  982. _i10n.registerDisplayObject(s2, adapter2);
  983. assertEquals(2, adapter.nestLevel);
  984. assertEquals(3, adapter2.nestLevel);
  985. StageProxy.root.removeChild(s);
  986. assertEquals(-1, adapter.nestLevel);
  987. assertEquals(-1, adapter2.nestLevel);
  988. StageProxy.root.addChild(s2);
  989. s2.addChild(s);
  990. assertEquals(3, adapter.nestLevel);
  991. assertEquals(2, adapter2.nestLevel);
  992. }
  993. [Test]
  994. public function test_nestLevel_afterCleanUp() : void {
  995. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  996. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  997. _i10n.registerDisplayObject(s, adapter);
  998. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  999. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  1000. _i10n.registerDisplayObject(s2, adapter2);
  1001. assertEquals(2, adapter.nestLevel);
  1002. assertEquals(3, adapter2.nestLevel);
  1003. _i10n.cleanUp();
  1004. assertEquals(-1, adapter.nestLevel);
  1005. assertEquals(-1, adapter2.nestLevel);
  1006. StageProxy.root.removeChild(s);
  1007. assertEquals(-1, adapter.nestLevel);
  1008. assertEquals(-1, adapter2.nestLevel);
  1009. StageProxy.root.addChild(s);
  1010. assertEquals(-1, adapter.nestLevel);
  1011. assertEquals(-1, adapter2.nestLevel);
  1012. }
  1013. [Test]
  1014. public function test_nestLevel_afterUnregister() : void {
  1015. var s : Sprite = StageProxy.root.addChild(new TestDisplayObject("s")) as Sprite;
  1016. var adapter : TestI10NAdapter = new TestI10NAdapter(_watcher);
  1017. _i10n.registerDisplayObject(s, adapter);
  1018. var s2 : Sprite = s.addChild(new TestDisplayObject("s2")) as Sprite;
  1019. var adapter2 : TestI10NAdapter = new TestI10NAdapter(_watcher);
  1020. _i10n.registerDisplayObject(s2, adapter2);
  1021. assertEquals(2, adapter.nestLevel);
  1022. assertEquals(3, adapter2.nestLevel);
  1023. _i10n.unregisterDisplayObject(s);
  1024. assertEquals(-1, adapter.nestLevel);
  1025. assertEquals(3, adapter2.nestLevel);
  1026. StageProxy.root.removeChild(s);
  1027. assertEquals(-1, adapter.nestLevel);
  1028. assertEquals(-1, adapter2.nestLevel);
  1029. StageProxy.root.addChild(s);
  1030. assertEquals(-1, adapter.nestLevel);
  1031. assertEquals(3, adapter2.nestLevel);
  1032. }
  1033. }
  1034. }