Skip to content

Commit

Permalink
Adding mouseout handlers to reproduce Issue operasoftware#57
Browse files Browse the repository at this point in the history
  • Loading branch information
rjatkins committed Jan 24, 2012
1 parent e74dd21 commit 1dacbb5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
25 changes: 25 additions & 0 deletions test/com/opera/core/systems/MouseTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Mouse;
import org.openqa.selenium.interactions.Actions;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -67,8 +69,31 @@ public void testContextClick() {
assertTrue(log().contains("mouseup 2"));
}

@Test
public void testMouseOverAndOutEvents() {
assertEquals("Test area", test());
Actions actions = new Actions(driver).moveToElement(test);
actions.perform();
assertEquals("mouseover", test());
actions = new Actions(driver).moveToElement(driver.findElement(By.tagName("body")));
actions.perform();
assertEquals("mouseout", test());
}

@Test
public void testCompoundMouseOverAndOutEvents() {
assertEquals("Test area", test());
Actions actions = new Actions(driver).moveToElement(test)
.moveToElement(driver.findElement(By.tagName("body")));
actions.perform();
assertEquals("mouseout", test());
}

private String log() {
return log.getAttribute("value");
}

private String test() {
return test.getText();
}
}
14 changes: 12 additions & 2 deletions test/fixtures/mouse.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<title>Mouse fixture</title>
</head>
<body>

<h1>Mouse test</h1>
<div id="test" style="">
Test area
</div>
Expand Down Expand Up @@ -48,10 +46,22 @@ <h1>Mouse test</h1>
return false;
}

function mouseoverHandler(e) {
test.innerHTML = "mouseover";
return false;
}

function mouseoutHandler(e) {
test.innerHTML = "mouseout";
return false;
}

document.getElementById("test");
test.addEventListener('mousedown', handler, false);
test.addEventListener('mouseup', handler, false);
test.addEventListener('click', handler, false);
test.addEventListener('mouseover', mouseoverHandler, false);
test.addEventListener('mouseout', mouseoutHandler, false);
</script>

</body>
Expand Down

0 comments on commit 1dacbb5

Please sign in to comment.