### Question:
TitleForFrameRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlFrame frame : page.findAllFrameTags()) { if (!hasNonEmptyAttribute(frame, "title")) { violations.add(createViolation(frame, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void frameWithNoTitlePresent() throws Exception { String content = "<html><frameset><frame src=\"inner.htm\" /></frameset></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void twoFramesWithNoTitlePresent() throws Exception { String content = "<html><frameset cols=\"250,*\"><frame src=\"menu.htm\" /><frame src=\"main.htm\" /></frameset></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 2); }
@Test public void frameWithTitlePresent() throws Exception { String content = "<html><frameset><frame src=\"navigation.htm\" title=\"Navigation\" /></frameset></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }