~widelands-dev/widelands-metaserver/ircbridge

« back to all changes in this revision

Viewing changes to wlms/server_test.go

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package main
2
2
 
3
3
import (
4
 
        . "launchpad.net/gocheck"
5
 
        "launchpad.net/widelands-metaserver/wlms/packet"
6
4
        "log"
7
5
        "testing"
8
6
        "time"
 
7
        . "launchpad.net/gocheck"
 
8
        "launchpad.net/widelands-metaserver/wlms/packet"
9
9
)
10
10
 
11
11
// Hook up gocheck into the gotest runner.
428
428
 
429
429
        SendPacket(clients[0], "GAME_START")
430
430
        ExpectPacket(c, clients[0], "GAME_START")
 
431
        // One for not being connectable, one for game starting.
 
432
        ExpectPacketForAll(c, clients[:2], "GAMES_UPDATE")
431
433
        ExpectPacketForAll(c, clients[:2], "GAMES_UPDATE")
432
434
 
433
435
        // Syncronize ping timers.
481
483
        SendPacket(clients[1], "PONG")
482
484
 
483
485
        // By now the clients should be forgotten and the game deleted.
484
 
        ExpectPacket(c, clients[1], "GAMES_UPDATE")
485
486
        ExpectPacket(c, clients[1], "CLIENTS_UPDATE")
486
487
 
487
488
        time.Sleep(21 * time.Millisecond)
923
924
// }}}
924
925
// Test Game Starting {{{
925
926
func (s *EndToEndSuite) TestStartGame(c *C) {
926
 
        server, clients, _ := gameTestSetup(c, true)
 
927
        server, clients, pinger := gameTestSetup(c, true)
927
928
 
928
929
        server.SetGamePingTimeout(5 * time.Second) // Not interested in this.
929
930
 
931
932
        ExpectPacketForAll(c, clients, "GAMES_UPDATE")
932
933
        ExpectPacketForAll(c, clients, "CLIENTS_UPDATE")
933
934
 
 
935
        pinger.C <- true
 
936
        ExpectPacket(c, clients[0], "GAME_OPEN")
 
937
        ExpectPacketForAll(c, clients, "GAMES_UPDATE")
 
938
 
934
939
        SendPacket(clients[1], "GAME_CONNECT", "my cool game")
935
940
        ExpectPacket(c, clients[1], "GAME_CONNECT", "192.168.0.0")
936
941
        ExpectPacketForAll(c, clients, "CLIENTS_UPDATE")
951
956
        ExpectPacket(c, clients[0], "GAME_START")
952
957
        ExpectPacketForAll(c, clients, "GAMES_UPDATE")
953
958
 
 
959
        // Ask for games.
 
960
        SendPacket(clients[1], "GAMES")
 
961
        ExpectPacket(c, clients[1], "GAMES", "1",
 
962
                "my cool game", "build-16", "false")
 
963
 
954
964
        ExpectServerToShutdownCleanly(c, server)
955
965
}
956
966