@@ -0,0 +1,2474 @@
+/*%0A * Copyright (C) 2013 salesforce.com, inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *         http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.auraframework.client;%0A%0Aimport org.auraframework.def.ComponentDef;%0Aimport org.auraframework.def.DefDescriptor;%0Aimport org.auraframework.test.WebDriverTestCase;%0Aimport org.openqa.selenium.By;%0A%0Apublic class UtilUiTest extends WebDriverTestCase %7B%0A%0A%09public UtilUiTest(String name) %7B%0A%09%09super(name);%0A%09%7D%0A%0A%09public void testRemoveOn() throws Exception %7B%0A%09%09DefDescriptor%3CComponentDef%3E cmpDesc = addSourceAutoCleanup(%0A%09%09%09%09ComponentDef.class, String.format(baseComponentTag,%0A%09%09%09%09%09%09%22render='client'%22,%0A%09%09%09%09%09%09%22%3Cdiv aura:id='div' class='target'%3Ehandled%3C/div%3E%22));%0A%09%09By target = By.cssSelector(%22.target%22);%0A%09%09open(cmpDesc);%0A%0A%09%09// check that test property is unset, then add a handler%0A%09%09getDriver().findElement(target).click();%0A%09%09assertEquals(%0A%09%09%09%09true,%0A%09%09%09%09auraUITestingUtil%0A%09%09%09%09%09%09.getBooleanEval(%22return window%5B'handledByTest'%5D === undefined%22));%0A%09%09auraUITestingUtil%0A%09%09%09%09.getEval(%22var handler=function()%7Bwindow%5B'handledByTest'%5D=true;%7D;window%5B'testHandler'%5D=handler;var elem=$A.getRoot().find('div').getElement();$A.util.on(elem, 'click', handler, false);%22);%0A%0A%09%09// trigger handler, then check that test property is now set%0A%09%09// reset the test property after checking%0A%09%09getDriver().findElement(target).click();%0A%09%09assertEquals(%0A%09%09%09%09true,%0A%09%09%09%09auraUITestingUtil%0A%09%09%09%09%09%09.getBooleanEval(%22var res = window%5B'handledByTest'%5D;delete window%5B'handledByTest'%5D;return res===true;%22));%0A%09%09assertEquals(%0A%09%09%09%09true,%0A%09%09%09%09auraUITestingUtil%0A%09%09%09%09%09%09.getBooleanEval(%22return window%5B'handledByTest'%5D === undefined%22));%0A%0A%09%09// remove the handler, then check that test property is not set on next event%0A%09%09auraUITestingUtil%0A%09%09%09%09.getEval(%22$A.util.removeOn($A.getRoot().find('div').getElement(), 'click', window%5B'testHandler'%5D, false);%22);%0A%09%09getDriver().findElement(target).click();%0A%09%09assertEquals(%0A%09%09%09%09true,%0A%09%09%09%09auraUITestingUtil%0A%09%09%09%09%09%09.getBooleanEval(%22return window%5B'handledByTest'%5D === undefined%22));%0A%09%7D%0A%7D%0A

test for $A.util.removeOn