Helios-Browser-Tests.js 4.7 KB

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