1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
11 require 'helpers/stubs.rb'
13 require 'dummy_player'
16 require 'board/element_manager'
18 class TestController < Test::Unit::TestCase
20 include ElementManager
21 attr_reader :scene, :elements, :game, :theme
26 @loader = PluginLoader.new
30 @theme = @loader.get_matching(:theme_loader).new.load(@game)
31 @elements = create_elements(@game)
39 $qApp or Qt::Application.new([])
40 field = GeneralMock.new
41 @game = Game.get(:shogi)
42 @table = FakeTable.new(@game)
43 @controller = Controller.new(@table, field)
50 def test_initial_state
51 assert_nil @controller.match
54 def test_single_player
55 match = Match.new(@game)
56 setup_single_player(match)
57 @controller.reset(match)
58 assert_equal match, @controller.match
63 def setup_single_player(match)
64 @controller.color = :white
65 @controller.premove = false
66 opponent = DummyPlayer.new(:black)
67 @controller.add_controlled_player(opponent)
68 match.register(@controller)
69 match.register(opponent)
70 match.start(@controller)