@Test
  public void autos5() {
    TestPage p = new TestPage();
    p.setPageMarkup(
        "<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>");
    A a = new A();
    B b = new B();
    p.queue(a);
    p.add(b);
    tester.startPage(p);

    assertTrue(a.getParent() instanceof Enclosure);
    assertTrue(b.getParent() instanceof TestPage);

    // A is visible, enclosure renders

    assertEquals(
        "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>",
        tester.getLastResponseAsString());

    // A is not visible, enclosure does not render

    a.setVisible(false);
    tester.startPage(p);
    assertEquals("", tester.getLastResponseAsString());
  }
Ejemplo n.º 2
0
  /** Issue https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/316 */
  @Test
  public void hasActiveButton() {

    TestPage page = new TestPage();
    final NavbarButton<?> buttonUnderTest =
        new NavbarButton<Object>(TestPage.class, GlyphIconType.adjust);
    page.add(buttonUnderTest);

    List<AbstractLink> buttons = new ArrayList<AbstractLink>();
    DropDownButton dropDownButton1 =
        new DropDownButton("dropDown", Model.of("")) {
          @Override
          protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) {
            return Collections.<AbstractLink>singletonList(buttonUnderTest);
          }
        };
    buttons.add(dropDownButton1);
    ButtonList buttonList = new ButtonList("id", buttons);

    assertTrue(buttonList.hasActiveButton(buttonUnderTest));
  }