コード例 #1
0
def test_ticket_1520(gui):
	"""
	Crash when completing build after outlined/related buildings were removed.
	"""

	found_settlement(gui, (8, 2), (10, 6))

	ground_map = gui.session.world.islands[0].ground_map

	# Build a tent
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_01')
	gui.cursor_click(7, 9, 'left')

	assert ground_map[(7, 9)].object.id == BUILDINGS.RESIDENTIAL

	# Start building a mainsquare (not releasing left mouse button)
	gui.trigger('tab', 'button_02')
	gui.cursor_move(13, 11)
	gui.cursor_press_button(13, 11, 'left')

	# remove tent
	Tear( ground_map[(7, 9)].object ).execute(gui.session)

	# release mouse button, finish build
	gui.cursor_release_button(13, 11, 'left')
コード例 #2
0
def test_traderoute(gui):
	"""Check that a ship's route is configured correctly after setting it up using the GUI."""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# Create the first settlement
	found_settlement(gui, (36, 34), (38, 39))

	# Give the resources back to the ship
	# Click the trade button
	gui.trigger('overview_trade_ship', 'trade')

	# Get the default amount (50 t, which is more than all available) of everything
	gui.trigger('buy_sell_goods', 'inventory_entry_0')
	gui.trigger('buy_sell_goods', 'inventory_entry_1')
	gui.trigger('buy_sell_goods', 'inventory_entry_2')
	gui.trigger('buy_sell_goods', 'inventory_entry_3')

	# Create the second settlement
	found_settlement(gui, (27, 28), (28, 22))

	# Open the configure trade route widget
	gui.trigger('overview_trade_ship', 'configure_route')

	# The trade route widget is visible
	assert gui.find(name='configure_route')
	route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu

	assert not ship.route.wait_at_load
	assert not ship.route.wait_at_unload
	assert not ship.route.waypoints

	# Select the first waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 38, 39
	route_widget.on_map_click(event, False)

	# Select the other waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 28, 22
	route_widget.on_map_click(event, False)

	# Set the resources to be loaded from settlement on the left and the amount
	gui.trigger('configure_route/container_1/slot_0', 'button', mouse='left') # Select the second warehouse's first slot
	gui.trigger('configure_route', 'resource_%d' % RES.FOOD)
	gui.find('configure_route/container_1/slot_0/slider').slide(120)

	# Check if the ship obeys the state of "Wait at load" and "Wait at unload"
	gui.trigger('configure_route', 'wait_at_load')
	gui.trigger('configure_route', 'wait_at_unload')

	assert ship.route.wait_at_load
	assert ship.route.wait_at_unload
	assert len(ship.route.waypoints) == 2
	assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
	assert Point(28, 22) in ship.route.waypoints[1]['warehouse'].position
	assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}
コード例 #3
0
def test_traderoute(gui):
	"""Check that a ship's route is configured correctly after setting it up using the GUI."""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# Create the first settlement
	found_settlement(gui, (36, 34), (38, 39))

	# Give the resources back to the ship
	# Click the trade button
	gui.trigger('overview_trade_ship', 'trade')

	# Get the default amount (50 t, which is more than all available) of everything
	gui.trigger('buy_sell_goods', 'inventory_entry_0')
	gui.trigger('buy_sell_goods', 'inventory_entry_1')
	gui.trigger('buy_sell_goods', 'inventory_entry_2')
	gui.trigger('buy_sell_goods', 'inventory_entry_3')

	# Create the second settlement
	found_settlement(gui, (27, 28), (28, 22))

	# Open the configure trade route widget
	gui.trigger('overview_trade_ship', 'configure_route')

	# The trade route widget is visible
	assert gui.find(name='configure_route')
	route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu

	assert not ship.route.wait_at_load
	assert not ship.route.wait_at_unload
	assert not ship.route.waypoints

	# Select the first waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 38, 39
	route_widget.on_map_click(event, False)

	# Select the other waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 28, 22
	route_widget.on_map_click(event, False)

	# Set the resources to be loaded from settlement on the left and the amount
	gui.trigger('configure_route/container_1/slot_0', 'button', mouse='left') # Select the second warehouse's first slot
	gui.trigger('configure_route', 'resource_%d' % RES.FOOD)
	gui.find('configure_route/container_1/slot_0/slider').slide(120)

	# Check if the ship obeys the state of "Wait at load" and "Wait at unload"
	gui.trigger('configure_route', 'wait_at_load')
	gui.trigger('configure_route', 'wait_at_unload')

	assert ship.route.wait_at_load
	assert ship.route.wait_at_unload
	assert len(ship.route.waypoints) == 2
	assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
	assert Point(28, 22) in ship.route.waypoints[1]['warehouse'].position
	assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}
コード例 #4
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_ticket_1520(gui):
    """
	Crash when completing build after outlined/related buildings were removed.
	"""

    found_settlement(gui, (8, 2), (10, 6))

    ground_map = gui.session.world.islands[0].ground_map

    # Build a tent
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_01')
    gui.cursor_click(7, 9, 'left')

    assert ground_map[(7, 9)].object.id == BUILDINGS.RESIDENTIAL

    # Start building a mainsquare (not releasing left mouse button)
    gui.trigger('tab/button_02')
    gui.cursor_move(13, 11)
    gui.cursor_press_button(13, 11, 'left')

    # remove tent
    Tear(ground_map[(7, 9)].object).execute(gui.session)

    # release mouse button, finish build
    gui.cursor_release_button(13, 11, 'left')
コード例 #5
0
def test_ticket_1948(gui):
	"""Triggers a crash that happens when building a storage tent on the border of the settlement"""
	# Units cannot be selected right now, you need to do it this way. This is almost
	# the same as selecting it with the mouse
	ship = get_player_ship(gui.session)
	gui.select([ship])
	found_settlement(gui, (59, 1), (56, 3))

	# Select storage tent
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_11')
	# Build storage at the border of the settlement
	gui.cursor_click(37, 20, 'left')
コード例 #6
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_ticket_1948(gui):
    """Triggers a crash that happens when building a storage tent on the border of the settlement"""
    # Units cannot be selected right now, you need to do it this way. This is almost
    # the same as selecting it with the mouse
    ship = get_player_ship(gui.session)
    gui.select([ship])
    found_settlement(gui, (59, 1), (56, 3))

    # Select storage tent
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_11')
    # Build storage at the border of the settlement
    gui.cursor_click(37, 20, 'left')
コード例 #7
0
def test_tearing(gui):
    found_settlement(gui, (11, 1), (11, 6))

    # remove some trees
    gui.trigger('mainhud', 'destroy_tool')
    gui.cursor_drag((5, 7), (11, 16), 'left')

    # build 4 tents
    gui.trigger('mainhud', 'build')
    gui.trigger('tab', 'button_01')
    gui.cursor_drag((7, 9), (10, 12), 'left')

    # try to remove an area that includes the tents, some trees and
    # the warehouse
    gui.trigger('mainhud', 'destroy_tool')
    gui.cursor_drag((5, 15), (15, 3), 'left')
コード例 #8
0
def test_tearing(gui):
	found_settlement(gui, (11, 1), (11, 6))

	# remove some trees
	gui.trigger('mainhud', 'destroy_tool')
	gui.cursor_drag((5, 7), (11, 16), 'left')

	# build 4 tents
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_01')
	gui.cursor_drag((7, 9), (10, 12), 'left')

	# try to remove an area that includes the tents, some trees and
	# the warehouse
	gui.trigger('mainhud', 'destroy_tool')
	gui.cursor_drag((5, 15), (15, 3), 'left')
コード例 #9
0
def test_tearing(gui):
    found_settlement(gui, (11, 1), (11, 6))

    # remove some trees
    gui.trigger("mainhud/destroy_tool")
    gui.cursor_drag((5, 7), (11, 16), "left")

    # build 4 tents
    gui.trigger("mainhud/build")
    gui.trigger("tab/button_01")
    gui.cursor_drag((7, 9), (10, 12), "left")

    # try to remove an area that includes the tents, some trees and
    # the warehouse
    gui.trigger("mainhud/destroy_tool")
    gui.cursor_drag((5, 15), (15, 3), "left")
コード例 #10
0
def test_ticket_1509(gui):
	"""
	Crash when quickly switching between tent tabs.
	"""

	found_settlement(gui, (8, 2), (10, 6))

	# Build a tent
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_01')
	gui.cursor_click(7, 10, 'left')

	# Select tent
	gui.cursor_click(7, 10, 'left')

	# quickly switch between tabs
	gui.trigger('tab_base', '1')
	gui.run()
	gui.trigger('tab_base', '0')
	gui.run()
	gui.trigger('tab_base', '1')
コード例 #11
0
def test_pipette(gui):
    found_settlement(gui, (11, 1), (11, 6))

    # select mountain, can not be build
    gui.press_key(gui.Key.O)
    gui.cursor_click(6, 18, "left")
    assert not gui.find("place_building")

    # build signal fire
    gui.trigger("mainhud/build")
    gui.trigger("tab/button_22")
    gui.cursor_click(7, 7, "left")

    # activate pipette, select signal fire, place it next to the other
    gui.press_key(gui.Key.O)
    gui.cursor_click(7, 7, "left")
    gui.cursor_click(6, 7, "left")

    # select signal fire, check if it's actually there
    gui.cursor_click(6, 7, "left")
    assert gui.find("overview_signalfire")
コード例 #12
0
def test_pipette(gui):
	found_settlement(gui, (11, 1), (11, 6))

	# select mountain, can not be build
	gui.press_key(gui.Key.O)
	gui.cursor_click(6, 18, 'left')
	assert not gui.find('place_building')

	# build signal fire
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_22')
	gui.cursor_click(7, 7, 'left')

	# activate pipette, select signal fire, place it next to the other
	gui.press_key(gui.Key.O)
	gui.cursor_click(7, 7, 'left')
	gui.cursor_click(6, 7, 'left')
	
	# select signal fire, check if it's actually there
	gui.cursor_click(6, 7, 'left')
	assert gui.find('overview_signalfire')
コード例 #13
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_ticket_1509(gui):
    """
	Crash when quickly switching between tent tabs.
	"""

    found_settlement(gui, (8, 2), (10, 6))

    # Build a tent
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_01')
    gui.cursor_click(7, 10, 'left')

    # Select tent
    gui.cursor_click(7, 10, 'left')

    # quickly switch between tabs
    gui.trigger('tab_base/1')
    gui.run()
    gui.trigger('tab_base/0')
    gui.run()
    gui.trigger('tab_base/1')
コード例 #14
0
def test_pipette(gui):
    found_settlement(gui, (11, 1), (11, 6))

    # select mountain, can not be build
    gui.press_key(gui.Key.O)
    gui.cursor_click(6, 18, 'left')
    assert not gui.find('place_building')

    # build signal fire
    gui.trigger('mainhud', 'build')
    gui.trigger('tab', 'button_22')
    gui.cursor_click(7, 7, 'left')

    # activate pipette, select signal fire, place it next to the other
    gui.press_key(gui.Key.O)
    gui.cursor_click(7, 7, 'left')
    gui.cursor_click(6, 7, 'left')

    # select signal fire, check if it's actually there
    gui.cursor_click(6, 7, 'left')
    assert gui.find('overview_signalfire')
コード例 #15
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_ticket_1371(gui):
    """
	Build related tab becomes invisible.

	 * use uninterrupted building (press shift)
	 * click on lumberjack
	 * click on the 'build related' tab
	 * click on the tree
	 * build a tree

     => tab itself is invisible, but buttons for choosing it aren't
	"""

    found_settlement(gui, (59, 1), (56, 3))

    # Build lumberjack
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_03')
    gui.cursor_click(52, 7, 'left')

    # Select lumberjack
    gui.cursor_click(52, 7, 'left')

    # Open build related tab
    gui.trigger('tab_base/1')

    # Select tree
    gui.trigger('overview_buildrelated/build17')

    # Plant a tree (without uninterrupted building)
    gui.cursor_click(49, 6, 'left')
    assert gui.find(name='overview_buildrelated')

    # Select tree again and plant it with uninterrupted building
    gui.trigger('overview_buildrelated/build17')
    gui.cursor_click(49, 7, 'left', shift=True)

    # Tab should still be there
    assert gui.find(name='overview_buildrelated')
コード例 #16
0
def test_ticket_1371(gui):
	"""
	Build related tab becomes invisible.

	 * use uninterrupted building (press shift)
	 * click on lumberjack
	 * click on the 'build related' tab
	 * click on the tree
	 * build a tree

     => tab itself is invisible, but buttons for choosing it aren't
	"""

	found_settlement(gui, (59, 1), (56, 3))

	# Build lumberjack
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_03')
	gui.cursor_click(52, 7, 'left')

	# Select lumberjack
	gui.cursor_click(52, 7, 'left')

	# Open build related tab
	gui.trigger('tab_base', '1')

	# Select tree
	gui.trigger('overview_buildrelated', 'build17')

	# Plant a tree (without uninterrupted building)
	gui.cursor_click(49, 6, 'left')
	assert gui.find(name='overview_buildrelated')

	# Select tree again and plant it with uninterrupted building
	gui.trigger('overview_buildrelated', 'build17')
	gui.cursor_click(49, 7, 'left', shift=True)

	# Tab should still be there
	assert gui.find(name='overview_buildrelated')
コード例 #17
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
    """
	"""

    found_settlement(gui, (59, 1), (56, 3))

    # Build settler
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_01')
    gui.cursor_click(52, 7, 'left')

    # Select settler
    gui.cursor_click(52, 7, 'left')

    # Open build related tab
    gui.trigger('tab_base/1')

    # Select pavilion
    gui.trigger('overview_buildrelated/build5')

    # Plant it
    gui.cursor_click(49, 6, 'left')
コード例 #18
0
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
	"""
	"""

	found_settlement(gui, (59, 1), (56, 3))

	# Build settler
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_01')
	gui.cursor_click(52, 7, 'left')

	# Select settler
	gui.cursor_click(52, 7, 'left')

	# Open build related tab
	gui.trigger('tab_base', '1')

	# Select pavilion
	gui.trigger('overview_buildrelated', 'build5')

	# Plant it
	gui.cursor_click(49, 6, 'left')
コード例 #19
0
def test_ticket_2500(gui):
	"""Game crashes when exiting the game while the building tool is still active."""

	ship = get_player_ship(gui.session)
	gui.select([ship])
	settlement = found_settlement(gui, (13, 64), (17, 62))

	# Select lumberjack
	gui.trigger('mainhud/build')
	gui.trigger('tab/button_03')

	# Quit game via pause menu
	gui.press_key(gui.Key.P)
	def dialog():
		gui.trigger('popup_window/okButton')

	with gui.handler(dialog):
		gui.trigger('menu/quit')
コード例 #20
0
def test_ticket_2500(gui):
	"""Game crashes when exiting the game while the building tool is still active."""

	ship = get_player_ship(gui.session)
	gui.select([ship])
	settlement = found_settlement(gui, (13, 64), (17, 62))

	# Select lumberjack
	gui.trigger('mainhud/build')
	gui.trigger('tab/button_03')

	# Quit game via pause menu
	gui.press_key(gui.Key.P)
	def dialog():
		gui.trigger('popup_window/okButton')

	with gui.handler(dialog):
		gui.trigger('menu/quit')
コード例 #21
0
def test_ticket_2475(gui):
	"""Game crashes when two resources are produced in the same tick and the production
	finished icon is about to be shown."""

	# speed up animation to trigger bug earlier
	gui.session.ingame_gui.production_finished_icon_manager.animation_duration = 1

	ship = get_player_ship(gui.session)
	gui.select([ship])
	settlement = found_settlement(gui, (13, 64), (17, 62))

	# Place a lumberjack
	gui.trigger('mainhud/build')
	gui.trigger('tab/button_03')
	gui.cursor_click(18, 57, 'left', shift=True)

	lumberjack = settlement.buildings_by_id[BUILDINGS.LUMBERJACK][0]
	storage = lumberjack.get_component(StorageComponent)
	producer = lumberjack.get_component(Producer)

	storage.inventory.alter(RES.BOARDS, 5)

	producer.on_production_finished({RES.BOARDS: 1})
	producer.on_production_finished({RES.BOARDS: 1})
コード例 #22
0
ファイル: test_bugs.py プロジェクト: Z-Fikar/unknown-horizons
def test_ticket_2475(gui):
    """Game crashes when two resources are produced in the same tick and the production
	finished icon is about to be shown."""

    # speed up animation to trigger bug earlier
    gui.session.ingame_gui.production_finished_icon_manager.animation_duration = 1

    ship = get_player_ship(gui.session)
    gui.select([ship])
    settlement = found_settlement(gui, (13, 64), (17, 62))

    # Place a lumberjack
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_03')
    gui.cursor_click(18, 57, 'left', shift=True)

    lumberjack = settlement.buildings_by_id[BUILDINGS.LUMBERJACK][0]
    storage = lumberjack.get_component(StorageComponent)
    producer = lumberjack.get_component(Producer)

    storage.inventory.alter(RES.BOARDS, 5)

    producer.on_production_finished({RES.BOARDS: 1})
    producer.on_production_finished({RES.BOARDS: 1})
コード例 #23
0
def test_traderoute(gui):
    """Check that a ship's route is configured correctly after setting it up using the GUI."""

    ship = get_player_ship(gui.session)
    gui.select([ship])

    # Create the first settlement
    found_settlement(gui, (36, 34), (38, 39))

    # Give the resources back to the ship
    # Click the trade button
    gui.trigger('overview_trade_ship/trade')

    # Get the default amount (50 t, which is more than all available) of everything
    gui.trigger('buy_sell_goods/inventory_entry_0')
    gui.trigger('buy_sell_goods/inventory_entry_1')
    gui.trigger('buy_sell_goods/inventory_entry_2')
    gui.trigger('buy_sell_goods/inventory_entry_3')

    # Create the second settlement
    found_settlement(gui, (14, 30), (15, 26))

    # Open the configure trade route widget
    # NOTE gui of traderoute is initialized with a delay, wait a bit, see `RouteConfig.__init__`
    gui.run(MPManager.EXECUTIONDELAY + 3)
    gui.trigger('overview_trade_ship/configure_route')

    # The trade route widget is visible
    assert gui.find(name='configure_route/minimap')
    route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu

    assert not ship.route.wait_at_load
    assert not ship.route.wait_at_unload
    assert not ship.route.waypoints

    # Select the first waypoint for the trade route
    event = Mock(map_coords=(38, 39))
    event.getButton.return_value = fife.MouseEvent.LEFT
    route_widget.on_map_click(event, False)

    # Select the other waypoint for the trade route
    event = Mock(map_coords=(15, 26))
    event.getButton.return_value = fife.MouseEvent.LEFT
    route_widget.on_map_click(event, False)

    # need to give control to the rest of the code, these clicks will trigger new gui widgets
    # to be added
    gui.run()

    # Set the resources to be loaded from settlement on the left and the amount
    gui.trigger('configure_route/container_1/slot_0/button',
                mouse='left')  # Select the second warehouse's first slot
    gui.trigger('configure_route/traderoute_resources/resource_{:d}'.format(
        RES.FOOD))
    gui.find('configure_route/container_1/slot_0/slider').slide(120)

    # Check if the ship obeys the state of "Wait at load" and "Wait at unload"
    gui.trigger('configure_route/wait_options/wait_at_load')
    gui.trigger('configure_route/wait_options/wait_at_unload')

    assert ship.route.wait_at_load
    assert ship.route.wait_at_unload
    assert len(ship.route.waypoints) == 2
    assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
    assert Point(15, 26) in ship.route.waypoints[1]['warehouse'].position
    assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}

    # Since this test is rather complex, we test bug #2525 as well

    # open pause menu and quit
    gui.trigger('mainhud/gameMenuButton')

    def func1():
        gui.trigger('popup_window/okButton')

    with gui.handler(func1):
        gui.trigger('menu/closeButton')
コード例 #24
0
def test_traderoute(gui):
	"""Check that a ship's route is configured correctly after setting it up using the GUI."""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# Create the first settlement
	found_settlement(gui, (36, 34), (38, 39))

	# Give the resources back to the ship
	# Click the trade button
	gui.trigger('overview_trade_ship/trade')

	# Get the default amount (50 t, which is more than all available) of everything
	gui.trigger('buy_sell_goods/inventory_entry_0')
	gui.trigger('buy_sell_goods/inventory_entry_1')
	gui.trigger('buy_sell_goods/inventory_entry_2')
	gui.trigger('buy_sell_goods/inventory_entry_3')

	# Create the second settlement
	found_settlement(gui, (14, 30), (15, 26))

	# Open the configure trade route widget
	# NOTE gui of traderoute is initialized with a delay, wait a bit, see `RouteConfig.__init__`
	gui.run(MPManager.EXECUTIONDELAY + 3)
	gui.trigger('overview_trade_ship/configure_route')

	# The trade route widget is visible
	assert gui.find(name='configure_route/minimap')
	route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu

	assert not ship.route.wait_at_load
	assert not ship.route.wait_at_unload
	assert not ship.route.waypoints

	# Select the first waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 38, 39
	route_widget.on_map_click(event, False)

	# Select the other waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 15, 26
	route_widget.on_map_click(event, False)

	# need to give control to the rest of the code, these clicks will trigger new gui widgets
	# to be added
	gui.run()

	# Set the resources to be loaded from settlement on the left and the amount
	gui.trigger('configure_route/container_1/slot_0/button', mouse='left') # Select the second warehouse's first slot
	gui.trigger('configure_route/traderoute_resources/resource_%d' % RES.FOOD)
	gui.find('configure_route/container_1/slot_0/slider').slide(120)

	# Check if the ship obeys the state of "Wait at load" and "Wait at unload"
	gui.trigger('configure_route/wait_options/wait_at_load')
	gui.trigger('configure_route/wait_options/wait_at_unload')

	assert ship.route.wait_at_load
	assert ship.route.wait_at_unload
	assert len(ship.route.waypoints) == 2
	assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
	assert Point(15, 26) in ship.route.waypoints[1]['warehouse'].position
	assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}

	# Since this test is rather complex, we test bug #2525 as well

	# open pause menu and quit
	gui.trigger('mainhud/gameMenuButton')
	def func1():
		gui.trigger('popup_window/okButton')

	with gui.handler(func1):
		gui.trigger('menu/closeButton')
コード例 #25
0
def test_found_settlement(gui):
	"""
	Found a settlement.
	"""

	player = gui.session.world.player
	assert not player.settlements

	found_settlement(gui, (68, 10), (64, 12))

	assert len(player.settlements) == 1

	# activate the build menu
	ground_map = gui.session.world.islands[0].ground_map
	gui.trigger('mainhud', 'build')

	# build a lumberjack
	gui.trigger('tab', 'button_03')
	gui.cursor_click(55, 5, 'left')
	assert(ground_map[(55, 5)].object.id == BUILDINGS.LUMBERJACK)

	# build a storage
	gui.trigger('tab', 'button_11')
	gui.cursor_click(55, 15, 'left')
	storage = ground_map[(55, 15)].object
	assert(storage.id == BUILDINGS.STORAGE)

	# connect the lumberjack and storage using a road
	gui.trigger('tab', 'button_21')
	for y in xrange(7, 15):
		gui.cursor_click(55, y, 'left')
		assert(ground_map[(55, y)].object.id == BUILDINGS.TRAIL)
	gui.cursor_click(55, y, 'right')

	# select the storage
	gui.cursor_click(55, 15, 'left')
	assert gui.find('warehouse_and_storage_overview')
	collectors = storage.get_component(CollectingComponent).get_local_collectors()

	while True:
		if any(collector.state is Collector.states.moving_to_target for collector in collectors):
			break
		gui.run()

	# remove the storage, trigger ticket 1441
	gui.press_key(gui.Key.DELETE)
	start = time.time()
	# wait 0.5 seconds
	while time.time() - start < 0.5:
		gui.run()
	assert ground_map[(55, 15)].object is None

	# open build menu again
	gui.trigger('mainhud', 'build')

	# build a fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(60, 4, 'left')
	fisher = ground_map[(60, 4)].object
	assert(fisher.id == BUILDINGS.FISHER)

	# connect the lumberjack and fisher using a road
	gui.trigger('tab', 'button_21')
	for x in xrange(57, 60):
		gui.cursor_click(x, 5, 'left')
		assert(ground_map[(x, 5)].object.id == BUILDINGS.TRAIL)
	gui.cursor_click(x, 5, 'right')

	# trigger ticket 1767
	# build a signal fire
	gui.trigger('tab', 'button_22')
	gui.cursor_click(58, 5, 'left')
	gui.cursor_click(58, 4, 'left')
コード例 #26
0
def test_found_settlement(gui):
	"""
	Found a settlement.
	"""

	player = gui.session.world.player
	assert not player.settlements

	found_settlement(gui, (68, 10), (64, 12))

	assert len(player.settlements) == 1

	# activate the build menu
	ground_map = gui.session.world.islands[0].ground_map
	gui.trigger('mainhud', 'build')

	# build a lumberjack
	gui.trigger('tab', 'button_03')
	gui.cursor_click(55, 5, 'left')
	assert(ground_map[(55, 5)].object.id == BUILDINGS.LUMBERJACK)

	# build a storage
	gui.trigger('tab', 'button_11')
	gui.cursor_click(55, 15, 'left')
	storage = ground_map[(55, 15)].object
	assert(storage.id == BUILDINGS.STORAGE)

	# connect the lumberjack and storage using a road
	gui.trigger('tab', 'button_21')
	for y in xrange(7, 15):
		gui.cursor_click(55, y, 'left')
		assert(ground_map[(55, y)].object.id == BUILDINGS.TRAIL)
	gui.cursor_click(55, y, 'right')

	# select the storage
	gui.cursor_click(55, 15, 'left')
	gui.trigger('tab_base', '0')
	assert gui.find('tab_account')
	collectors = storage.get_component(CollectingComponent).get_local_collectors()

	while True:
		if any(collector.state is Collector.states.moving_to_target for collector in collectors):
			break
		gui.run()

	# remove the storage, trigger ticket 1441
	def func():
		assert gui.find('popup_window') is not None
		gui.trigger('popup_window', 'okButton')

	with gui.handler(func):
		gui.press_key(gui.Key.DELETE)

	start = time.time()
	# wait 0.5 seconds
	while time.time() - start < 0.5:
		gui.run()
	assert ground_map[(55, 15)].object is None

	# open build menu again
	gui.trigger('mainhud', 'build')

	# build a fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(60, 4, 'left')
	fisher = ground_map[(60, 4)].object
	assert(fisher.id == BUILDINGS.FISHER)

	# connect the lumberjack and fisher using a road
	gui.trigger('tab', 'button_21')
	for x in xrange(57, 60):
		gui.cursor_click(x, 5, 'left')
		assert(ground_map[(x, 5)].object.id == BUILDINGS.TRAIL)
	gui.cursor_click(x, 5, 'right')

	# trigger ticket 1767
	# build a signal fire
	gui.trigger('tab', 'button_22')
	gui.cursor_click(58, 5, 'left')
	gui.cursor_click(58, 4, 'left')