OSDN Git Service

[shogi-server] A player, attempting to login with the current live player
[shogi-server/shogi-server.git] / test / TC_oute_sennichite.rb
index 2938047..631b18c 100644 (file)
@@ -1,41 +1,34 @@
-require "baseclient"
+$:.unshift File.join(File.dirname(__FILE__), "..")
+$topdir = File.expand_path File.dirname(__FILE__)
+require "test/baseclient"
 include Socket::Constants
 
 class OuteSennichiteTest < ReadFileClient
   def test_oute_sennichite
     csa = File.open(filepath("oute_sennichite.csa")) {|f| f.read}
     handshake(csa)
-    #cmd2 "%KACHI"
-    sleep 1
-    result1 = read_nonblock(@socket1)
-    result2 = read_nonblock(@socket2)
+    @p1.wait(/#OUTE_SENNICHITE.#LOSE/m)
+    @p2.wait(/#OUTE_SENNICHITE.#WIN/m)
+    assert true
     logout12
-    assert_match(/#OUTE_SENNICHITE.#LOSE/m, result1)
-    assert_match(/#OUTE_SENNICHITE.#WIN/m, result2)
   end
 
   def test_oute_sennichite2
     csa = File.open(filepath("oute_sennichite2.csa")) {|f| f.read}
     handshake(csa)
-    #cmd2 "%KACHI"
-    sleep 1
-    result1 = read_nonblock(@socket1)
-    result2 = read_nonblock(@socket2)
+    @p1.wait(/#OUTE_SENNICHITE.#WIN/m)
+    @p2.wait(/#OUTE_SENNICHITE.#LOSE/m)
+    assert true
     logout12
-    assert_match(/#OUTE_SENNICHITE.#WIN/m, result1)
-    assert_match(/#OUTE_SENNICHITE.#LOSE/m, result2)
   end
 
   def test_oute_sennichite3
     csa = File.open(filepath("oute_sennichite3.csa")) {|f| f.read}
     handshake(csa)
-    #cmd2 "%KACHI"
-    sleep 1
-    result1 = read_nonblock(@socket1)
-    result2 = read_nonblock(@socket2)
+    @p1.wait(/#OUTE_SENNICHITE.#LOSE/m)
+    @p2.wait(/#OUTE_SENNICHITE.#WIN/m)
+    assert true
     logout12
-    assert_match(/#OUTE_SENNICHITE.#LOSE/m, result1)
-    assert_match(/#OUTE_SENNICHITE.#WIN/m, result2)
   end
 end # Client class