This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: new Menu and MenuBar tests


Hi,

Here are two more tests like the Frame test I added earlier:

2006-02-14  Mark Wielaard  <mark@klomp.org>

        * gnu/testlet/java/awt/Menu/addItem.java: New test.
        * gnu/testlet/java/awt/MenuBar/addMenu.java: New test.

Committed,

Mark
// Tags: GUI JDK1.0

// Copyright (C) 2006 Free Software Foundation, Inc.

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to the Free
// Software Foundation,Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301 USA.


package gnu.testlet.java.awt.Menu;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.*;

public class addItem implements Testlet
{
  public void test (TestHarness harness)
  {
    Menu m = new Menu("Test");
    harness.check(m.countItems(), 0);

    MenuItem i = new MenuItem("Testing");
    m.add(i);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);

    m.remove(i);
    harness.check(m.countItems(), 0);
    harness.check(i.getParent(), null);

    m.add(i);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);
    
    MenuItem i2 = new MenuItem("Second");
    m.insert(i2, 0);
    harness.check(m.countItems(), 2);
    harness.check(m.getItem(0), i2);
    harness.check(m.getItem(1), i);
    harness.check(i.getParent(), m);
    harness.check(i2.getParent(), m);

    m.remove(0);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);
    harness.check(i2.getParent(), null);

    m.remove(i);
    harness.check(m.countItems(), 0);
    harness.check(i.getParent(), null);

    // A Menu can be an MenuItem
    
    i = new Menu("TestingMenu");
    m.add(i);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);

    m.remove(i);
    harness.check(m.countItems(), 0);
    harness.check(i.getParent(), null);

    m.add(i);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);
    
    i2 = new Menu("SecondMenu");
    m.insert(i2, 0);
    harness.check(m.countItems(), 2);
    harness.check(m.getItem(0), i2);
    harness.check(m.getItem(1), i);
    harness.check(i.getParent(), m);
    harness.check(i2.getParent(), m);

    m.remove(0);
    harness.check(m.countItems(), 1);
    harness.check(m.getItem(0), i);
    harness.check(i.getParent(), m);
    harness.check(i2.getParent(), null);

    m.remove(i);
    harness.check(m.countItems(), 0);
    harness.check(i.getParent(), null);
  }
}
// Tags: GUI JDK1.0

// Copyright (C) 2006 Free Software Foundation, Inc.

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to the Free
// Software Foundation,Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301 USA.


package gnu.testlet.java.awt.MenuBar;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.awt.*;

public class addMenu implements Testlet
{
  public void test (TestHarness harness)
  {
    MenuBar mb = new MenuBar();
    harness.check(mb.countMenus(), 0);

    Menu m = new Menu("Testing");
    mb.add(m);
    harness.check(mb.countMenus(), 1);
    harness.check(mb.getMenu(0), m);
    harness.check(m.getParent(), mb);

    mb.remove(m);
    harness.check(mb.countMenus(), 0);
    harness.check(m.getParent(), null);

    mb.add(m);
    harness.check(mb.countMenus(), 1);
    harness.check(mb.getMenu(0), m);
    harness.check(m.getParent(), mb);
    
    Menu m2 = new Menu("SecondMenu");
    mb.add(m2);
    harness.check(mb.countMenus(), 2);
    harness.check(mb.getMenu(0), m);
    harness.check(mb.getMenu(1), m2);
    harness.check(m2.getParent(), mb);

    mb.remove(0);
    harness.check(mb.countMenus(), 1);
    harness.check(mb.getMenu(0), m2);
    harness.check(m.getParent(), null);
    harness.check(m2.getParent(), mb);

    mb.remove(m2);
    harness.check(mb.countMenus(), 0);
    harness.check(m2.getParent(), null);
  }
}

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]