/test/src/nativeElement/NativeElementTests.hx

http://github.com/silexlabs/Cocktail · Haxe · 60 lines · 36 code · 10 blank · 14 comment · 0 complexity · 6c46e2b6ab9d741f2b607b35cd953560 MD5 · raw file

  1. /*This file is part of Silex - see http://projects.silexlabs.org/?/silex
  2. Silex is Š 2010-2011 Silex Labs and is released under the GPL License:
  3. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  4. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  5. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  6. */
  7. package nativeElement;
  8. import haxe.Log;
  9. import cocktail.nativeElement.NativeElement;
  10. import utest.Assert;
  11. import utest.Runner;
  12. import utest.ui.Report;
  13. import cocktail.nativeElement.NativeElementManager;
  14. import cocktail.nativeElement.NativeElementData;
  15. /**
  16. * Test the cross-platform native element manager
  17. *@author Yannick DOMINGUEZ
  18. */
  19. class NativeElementTests
  20. {
  21. public static function main()
  22. {
  23. var runner = new Runner();
  24. runner.addCase(new NativeElementTests());
  25. Report.create(runner);
  26. runner.run();
  27. }
  28. public function new()
  29. {
  30. }
  31. public function testNativeElement()
  32. {
  33. var domRoot:NativeElement = NativeElementManager.getRoot();
  34. #if flash9
  35. Assert.is(domRoot, flash.display.Stage);
  36. #elseif js
  37. Assert.same(domRoot.nodeName, "BODY");
  38. #end
  39. var nativeGraphicReference:NativeElement = NativeElementManager.createNativeElement(graphic);
  40. #if flash9
  41. Assert.is(nativeGraphicReference, flash.display.Sprite);
  42. #elseif js
  43. Assert.same(nativeGraphicReference.nodeName, "CANVAS");
  44. #end
  45. }
  46. }