public void testSelect() {
    Word word1 = new Word(200, 300, 0, "Hello", WordType.adj);
    Word word2 = new Word(100, 100, 0, "World", WordType.adj);
    ArrayList<Word> wrds = new ArrayList<Word>();
    wrds.add(word1);
    int height = 250;
    int width = 500;
    Position posProtect = new Position(0, 0, 0);
    Position posUnprotect = new Position(0, height + 1, 0);

    board = new Board(wrds, posProtect, posUnprotect, height, height, width, width);
    model = new Model(board);
    panel = new RegionPanel(model);

    Position pos = new Position(1, 1, 0);
    board.protectWord(word1, pos);

    Poem p = board.getProtectedRegion().convertWordToPoem(word1);

    ReleasePoemController prc = new ReleasePoemController(model, panel);

    assertEquals(board.getProtectedRegion().getPoems().size(), 1);
    prc.select(2, 2);
    assertEquals(board.getProtectedRegion().getPoems().size(), 0);
  }
示例#2
0
  protected void setUp() {
    Board board = null;
    Word word1 = new Word(200, 300, 0, "Hello", WordType.adj);
    Word word2 = new Word(100, 100, 0, "World", WordType.adj);

    ArrayList<Word> wrds = new ArrayList<Word>();
    wrds.add(word1);
    int height = 250;
    int width = 500;
    Position posProtect = new Position(0, 0, 0);
    Position posUnprotect = new Position(0, height + 1, 0);

    board = new Board(wrds, posProtect, posUnprotect, height, height, width, width);

    model = new Model(board);
    panel = new RegionPanel(model);

    board.getProtectedRegion().getWords().add(word2);

    Poem p = board.getProtectedRegion().convertWordToPoem(word2);

    int selectedID = board.getProtectedRegion().getPoems().get(0).getID();
    Poem selected = board.getProtectedRegion().getPoem(selectedID);
    ReleasePoemMove move = new ReleasePoemMove(selected);

    if (move.execute(board)) {
      board.addUndoMove(move);
      board.clearRedoStacks();
    }

    assertEquals(board.getProtectedRegion().getPoems().size(), 0);
  }