Helios-Browser-Tests.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. define(["amber/boot", "require", "amber/core/SUnit"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Helios-Browser-Tests");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"helios"};
  6. $core.addClass("HLBrowserTest", $globals.TestCase, ["browser"], "Helios-Browser-Tests");
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.HLBrowserTest.comment="Test cases for the functionality of `HLBrowserModel`";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "setUp",
  13. protocol: "tests",
  14. fn: function (){
  15. var self=this,$self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. $self["@browser"]=$recv($globals.HLBrowserModel)._new();
  20. return self;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. }, function($ctx1) {$ctx1.fill(self,"setUp",{},$globals.HLBrowserTest)});
  23. //>>excludeEnd("ctx");
  24. },
  25. //>>excludeStart("ide", pragmas.excludeIdeData);
  26. args: [],
  27. source: "setUp\x0a\x09browser := HLBrowserModel new.",
  28. referencedClasses: ["HLBrowserModel"],
  29. //>>excludeEnd("ide");
  30. messageSends: ["new"]
  31. }),
  32. $globals.HLBrowserTest);
  33. $core.addMethod(
  34. $core.method({
  35. selector: "testAllProtocolsSelectedWhenSelectingAClass",
  36. protocol: "tests",
  37. fn: function (){
  38. var self=this,$self=this;
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. return $core.withContext(function($ctx1) {
  41. //>>excludeEnd("ctx");
  42. var $2,$1;
  43. $2=$recv($self["@browser"])._selectedProtocol();
  44. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  45. $ctx1.sendIdx["selectedProtocol"]=1;
  46. //>>excludeEnd("ctx");
  47. $1=$recv($2)._isNil();
  48. $self._assert_($1);
  49. $recv($self["@browser"])._selectedClass_($globals.Object);
  50. $self._assert_equals_($recv($self["@browser"])._selectedProtocol(),$recv($self["@browser"])._allProtocol());
  51. return self;
  52. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  53. }, function($ctx1) {$ctx1.fill(self,"testAllProtocolsSelectedWhenSelectingAClass",{},$globals.HLBrowserTest)});
  54. //>>excludeEnd("ctx");
  55. },
  56. //>>excludeStart("ide", pragmas.excludeIdeData);
  57. args: [],
  58. source: "testAllProtocolsSelectedWhenSelectingAClass\x0a\x09self assert: browser selectedProtocol isNil.\x0a\x09browser selectedClass: Object.\x0a\x09self assert: browser selectedProtocol equals: browser allProtocol.",
  59. referencedClasses: ["Object"],
  60. //>>excludeEnd("ide");
  61. messageSends: ["assert:", "isNil", "selectedProtocol", "selectedClass:", "assert:equals:", "allProtocol"]
  62. }),
  63. $globals.HLBrowserTest);
  64. $core.addMethod(
  65. $core.method({
  66. selector: "testProtocolSelectedWhenChangingClass",
  67. protocol: "tests",
  68. fn: function (){
  69. var self=this,$self=this;
  70. var protocolSelectedCalled;
  71. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  72. return $core.withContext(function($ctx1) {
  73. //>>excludeEnd("ctx");
  74. protocolSelectedCalled=(0);
  75. $recv($recv($self["@browser"])._announcer())._on_do_for_($globals.HLProtocolSelected,(function(){
  76. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  77. return $core.withContext(function($ctx2) {
  78. //>>excludeEnd("ctx");
  79. protocolSelectedCalled=$recv(protocolSelectedCalled).__plus((1));
  80. return protocolSelectedCalled;
  81. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  82. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  83. //>>excludeEnd("ctx");
  84. }),self);
  85. $recv($self["@browser"])._selectedClass_($globals.Object);
  86. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  87. $ctx1.sendIdx["selectedClass:"]=1;
  88. //>>excludeEnd("ctx");
  89. $self._assert_equals_(protocolSelectedCalled,(1));
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. $ctx1.sendIdx["assert:equals:"]=1;
  92. //>>excludeEnd("ctx");
  93. $recv($self["@browser"])._selectedClass_($globals.ProtoObject);
  94. $self._assert_equals_(protocolSelectedCalled,(2));
  95. return self;
  96. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  97. }, function($ctx1) {$ctx1.fill(self,"testProtocolSelectedWhenChangingClass",{protocolSelectedCalled:protocolSelectedCalled},$globals.HLBrowserTest)});
  98. //>>excludeEnd("ctx");
  99. },
  100. //>>excludeStart("ide", pragmas.excludeIdeData);
  101. args: [],
  102. source: "testProtocolSelectedWhenChangingClass\x0a\x09| protocolSelectedCalled |\x0a\x09protocolSelectedCalled := 0.\x0a\x09browser announcer on: HLProtocolSelected do: [protocolSelectedCalled := protocolSelectedCalled + 1] for: self.\x0a\x09browser selectedClass: Object.\x0a\x09self assert: protocolSelectedCalled equals: 1.\x0a\x09browser selectedClass: ProtoObject.\x0a\x09self assert: protocolSelectedCalled equals: 2.",
  103. referencedClasses: ["HLProtocolSelected", "Object", "ProtoObject"],
  104. //>>excludeEnd("ide");
  105. messageSends: ["on:do:for:", "announcer", "+", "selectedClass:", "assert:equals:"]
  106. }),
  107. $globals.HLBrowserTest);
  108. });