Indent every script with tabs, like the Godot editor does
This commit is contained in:
1 parent
8c1987807c
commit
bad4b3ad8b
35 files changed
+1653
-1653
No files matched your search
@@ -8,41 +8,41 @@ var _owner: Node
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_server = TCPServer.new()
|
||||
assert_int(_server.listen(0, "127.0.0.1")).is_equal(OK)
|
||||
_owner = auto_free(Node.new())
|
||||
add_child(_owner)
|
||||
_server = TCPServer.new()
|
||||
assert_int(_server.listen(0, "127.0.0.1")).is_equal(OK)
|
||||
_owner = auto_free(Node.new())
|
||||
add_child(_owner)
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
for connection: StreamPeerTCP in _connections:
|
||||
connection.disconnect_from_host()
|
||||
_server.stop()
|
||||
for connection: StreamPeerTCP in _connections:
|
||||
connection.disconnect_from_host()
|
||||
_server.stop()
|
||||
|
||||
|
||||
func _accept_connections() -> void:
|
||||
while _server.is_connection_available():
|
||||
_connections.append(_server.take_connection())
|
||||
while _server.is_connection_available():
|
||||
_connections.append(_server.take_connection())
|
||||
|
||||
|
||||
func test_request_to_silent_server_times_out_as_failed() -> void:
|
||||
var transport: HttpTransport = HttpTransport.new(_owner)
|
||||
transport.timeout_seconds = 0.5
|
||||
var response_codes: Array[int] = []
|
||||
var transport: HttpTransport = HttpTransport.new(_owner)
|
||||
transport.timeout_seconds = 0.5
|
||||
var response_codes: Array[int] = []
|
||||
|
||||
transport.request("http://127.0.0.1:%d/music/rand" % _server.get_local_port(),
|
||||
HTTPClient.METHOD_GET,
|
||||
func(response_code: int, _body: PackedByteArray) -> void:
|
||||
response_codes.append(response_code))
|
||||
for i: int in 40:
|
||||
_accept_connections()
|
||||
await await_millis(50)
|
||||
if !response_codes.is_empty():
|
||||
break
|
||||
transport.request("http://127.0.0.1:%d/music/rand" % _server.get_local_port(),
|
||||
HTTPClient.METHOD_GET,
|
||||
func(response_code: int, _body: PackedByteArray) -> void:
|
||||
response_codes.append(response_code))
|
||||
for i: int in 40:
|
||||
_accept_connections()
|
||||
await await_millis(50)
|
||||
if !response_codes.is_empty():
|
||||
break
|
||||
|
||||
assert_bool(_connections.is_empty()).is_false()
|
||||
assert_array(response_codes).contains_exactly([0])
|
||||
assert_bool(_connections.is_empty()).is_false()
|
||||
assert_array(response_codes).contains_exactly([0])
|
||||
|
||||
|
||||
func test_default_timeout_is_set() -> void:
|
||||
assert_float(HttpTransport.new(_owner).timeout_seconds).is_greater(0.0)
|
||||
assert_float(HttpTransport.new(_owner).timeout_seconds).is_greater(0.0)
|
||||
+10
-10
@@ -2,25 +2,25 @@ extends GdUnitTestSuite
|
||||
|
||||
|
||||
func _background(list_row: ListRow) -> Color:
|
||||
return (list_row.get_theme_stylebox("panel") as StyleBoxFlat).bg_color
|
||||
return (list_row.get_theme_stylebox("panel") as StyleBoxFlat).bg_color
|
||||
|
||||
|
||||
func test_row_shows_text() -> void:
|
||||
var list_row: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
||||
var list_row: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
||||
|
||||
assert_str(list_row.text).is_equal("Chrono Trigger")
|
||||
assert_str(list_row.text).is_equal("Chrono Trigger")
|
||||
|
||||
|
||||
func test_neighbouring_rows_have_different_backgrounds() -> void:
|
||||
var first: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
||||
var second: ListRow = auto_free(ListRow.create("Chrono Cross", 1, 20))
|
||||
var third: ListRow = auto_free(ListRow.create("Xenogears", 2, 20))
|
||||
var first: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
||||
var second: ListRow = auto_free(ListRow.create("Chrono Cross", 1, 20))
|
||||
var third: ListRow = auto_free(ListRow.create("Xenogears", 2, 20))
|
||||
|
||||
assert_that(_background(first)).is_not_equal(_background(second))
|
||||
assert_that(_background(first)).is_equal(_background(third))
|
||||
assert_that(_background(first)).is_not_equal(_background(second))
|
||||
assert_that(_background(first)).is_equal(_background(third))
|
||||
|
||||
|
||||
func test_long_text_wraps() -> void:
|
||||
var list_row: ListRow = auto_free(ListRow.create("Castlevania: Symphony of the Night", 0, 20))
|
||||
var list_row: ListRow = auto_free(ListRow.create("Castlevania: Symphony of the Night", 0, 20))
|
||||
|
||||
assert_int(list_row.label.autowrap_mode).is_equal(TextServer.AUTOWRAP_WORD_SMART)
|
||||
assert_int(list_row.label.autowrap_mode).is_equal(TextServer.AUTOWRAP_WORD_SMART)
|
||||
@@ -7,62 +7,62 @@ var _hide_for_seconds: float
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_music_player = auto_free(MusicPlayer.new())
|
||||
_hide_beginning = Settings.hide_beginning
|
||||
_hide_length = Settings.hide_length
|
||||
_hide_for_seconds = Settings.hide_for_seconds
|
||||
Settings.hide_beginning = false
|
||||
Settings.hide_length = false
|
||||
Settings.hide_for_seconds = 5.0
|
||||
_music_player = auto_free(MusicPlayer.new())
|
||||
_hide_beginning = Settings.hide_beginning
|
||||
_hide_length = Settings.hide_length
|
||||
_hide_for_seconds = Settings.hide_for_seconds
|
||||
Settings.hide_beginning = false
|
||||
Settings.hide_length = false
|
||||
Settings.hide_for_seconds = 5.0
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
Settings.hide_beginning = _hide_beginning
|
||||
Settings.hide_length = _hide_length
|
||||
Settings.hide_for_seconds = _hide_for_seconds
|
||||
Settings.hide_beginning = _hide_beginning
|
||||
Settings.hide_length = _hide_length
|
||||
Settings.hide_for_seconds = _hide_for_seconds
|
||||
|
||||
|
||||
func test_format_time() -> void:
|
||||
assert_str(_music_player.format_time(0.0)).is_equal("00:00")
|
||||
assert_str(_music_player.format_time(65.0)).is_equal("01:05")
|
||||
assert_str(_music_player.format_time(3661.0)).is_equal("61:01")
|
||||
assert_str(_music_player.format_time(0.0)).is_equal("00:00")
|
||||
assert_str(_music_player.format_time(65.0)).is_equal("01:05")
|
||||
assert_str(_music_player.format_time(3661.0)).is_equal("61:01")
|
||||
|
||||
|
||||
func test_format_time_rounds_up_into_next_minute() -> void:
|
||||
assert_str(_music_player.format_time(59.6)).is_equal("01:00")
|
||||
assert_str(_music_player.format_time(59.6)).is_equal("01:00")
|
||||
|
||||
|
||||
func test_format_text_shows_position_and_length() -> void:
|
||||
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / 01:40")
|
||||
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / 01:40")
|
||||
|
||||
|
||||
func test_format_text_hides_length() -> void:
|
||||
Settings.hide_length = true
|
||||
Settings.hide_length = true
|
||||
|
||||
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / ??:??")
|
||||
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / ??:??")
|
||||
|
||||
|
||||
func test_format_text_hides_position_at_start() -> void:
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_beginning = true
|
||||
|
||||
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / 01:40")
|
||||
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / 01:40")
|
||||
|
||||
|
||||
func test_format_text_shows_position_after_hidden_start() -> void:
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_beginning = true
|
||||
|
||||
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / 01:40")
|
||||
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / 01:40")
|
||||
|
||||
|
||||
func test_format_text_hides_everything_at_start() -> void:
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_length = true
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_length = true
|
||||
|
||||
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / ??:??")
|
||||
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / ??:??")
|
||||
|
||||
|
||||
func test_format_text_keeps_length_hidden_after_hidden_start() -> void:
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_length = true
|
||||
Settings.hide_beginning = true
|
||||
Settings.hide_length = true
|
||||
|
||||
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / ??:??")
|
||||
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / ??:??")
|
||||
@@ -4,143 +4,143 @@ var _server: FakeHttpTransport
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_server = FakeHttpTransport.new().install()
|
||||
_server = FakeHttpTransport.new().install()
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
_server.uninstall()
|
||||
_server.uninstall()
|
||||
|
||||
|
||||
func test_fetch_song_list_passes_parsed_json() -> void:
|
||||
var songs: Array = [{"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time"}]
|
||||
_server.respond_json("/music/list", songs)
|
||||
var received: Array = []
|
||||
var songs: Array = [{"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time"}]
|
||||
_server.respond_json("/music/list", songs)
|
||||
var received: Array = []
|
||||
|
||||
MusicServerClient.fetch_song_list(func(data: Array) -> void: received.append_array(data))
|
||||
MusicServerClient.fetch_song_list(func(data: Array) -> void: received.append_array(data))
|
||||
|
||||
assert_int(received.size()).is_equal(1)
|
||||
assert_int(int(received[0].SongNo)).is_equal(0)
|
||||
assert_str(received[0].Soundtrack).is_equal("Chrono Trigger")
|
||||
assert_int(received.size()).is_equal(1)
|
||||
assert_int(int(received[0].SongNo)).is_equal(0)
|
||||
assert_str(received[0].Soundtrack).is_equal("Chrono Trigger")
|
||||
|
||||
|
||||
func test_fetch_random_song_uses_normal_endpoint() -> void:
|
||||
MusicServerClient.fetch_random_song(false, func(_body: PackedByteArray) -> void: pass)
|
||||
MusicServerClient.fetch_random_song(false, func(_body: PackedByteArray) -> void: pass)
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/rand"])
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/rand"])
|
||||
|
||||
|
||||
func test_fetch_random_song_uses_low_played_endpoint() -> void:
|
||||
MusicServerClient.fetch_random_song(true, func(_body: PackedByteArray) -> void: pass)
|
||||
MusicServerClient.fetch_random_song(true, func(_body: PackedByteArray) -> void: pass)
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/rand/low"])
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/rand/low"])
|
||||
|
||||
|
||||
func test_fetch_song_passes_raw_bytes() -> void:
|
||||
var mp3: PackedByteArray = PackedByteArray([0x49, 0x44, 0x33])
|
||||
_server.respond_bytes("/music?song=4", mp3)
|
||||
var received: Array[PackedByteArray] = []
|
||||
var mp3: PackedByteArray = PackedByteArray([0x49, 0x44, 0x33])
|
||||
_server.respond_bytes("/music?song=4", mp3)
|
||||
var received: Array[PackedByteArray] = []
|
||||
|
||||
MusicServerClient.fetch_song(4, func(body: PackedByteArray) -> void: received.append(body))
|
||||
MusicServerClient.fetch_song(4, func(body: PackedByteArray) -> void: received.append(body))
|
||||
|
||||
assert_array(received).contains_exactly([mp3])
|
||||
assert_array(received).contains_exactly([mp3])
|
||||
|
||||
|
||||
func test_failed_request_does_not_call_back() -> void:
|
||||
_server.respond_json("/music/list", [], 500)
|
||||
var called: Array[bool] = [false]
|
||||
_server.respond_json("/music/list", [], 500)
|
||||
var called: Array[bool] = [false]
|
||||
|
||||
MusicServerClient.fetch_song_list(func(_data: Variant) -> void: called[0] = true)
|
||||
MusicServerClient.fetch_song_list(func(_data: Variant) -> void: called[0] = true)
|
||||
|
||||
assert_bool(called[0]).is_false()
|
||||
assert_bool(called[0]).is_false()
|
||||
|
||||
|
||||
func test_invalid_json_does_not_call_back() -> void:
|
||||
_server.respond_bytes("/music/info", "not json".to_utf8_buffer())
|
||||
var called: Array[bool] = [false]
|
||||
_server.respond_bytes("/music/info", "not json".to_utf8_buffer())
|
||||
var called: Array[bool] = [false]
|
||||
|
||||
MusicServerClient.fetch_song_info(func(_data: Variant) -> void: called[0] = true)
|
||||
MusicServerClient.fetch_song_info(func(_data: Variant) -> void: called[0] = true)
|
||||
|
||||
assert_bool(called[0]).is_false()
|
||||
assert_bool(called[0]).is_false()
|
||||
|
||||
|
||||
func test_failed_request_calls_on_failed() -> void:
|
||||
_server.respond_bytes("/music/rand", PackedByteArray(), 503)
|
||||
var outcome: Array[String] = []
|
||||
_server.respond_bytes("/music/rand", PackedByteArray(), 503)
|
||||
var outcome: Array[String] = []
|
||||
|
||||
MusicServerClient.fetch_random_song(false,
|
||||
func(_body: PackedByteArray) -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
MusicServerClient.fetch_random_song(false,
|
||||
func(_body: PackedByteArray) -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
|
||||
assert_array(outcome).contains_exactly(["failed"])
|
||||
assert_array(outcome).contains_exactly(["failed"])
|
||||
|
||||
|
||||
func test_invalid_json_calls_on_failed() -> void:
|
||||
_server.respond_bytes("/music/info", "not json".to_utf8_buffer())
|
||||
var outcome: Array[String] = []
|
||||
_server.respond_bytes("/music/info", "not json".to_utf8_buffer())
|
||||
var outcome: Array[String] = []
|
||||
|
||||
MusicServerClient.fetch_song_info(
|
||||
func(_data: Variant) -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
MusicServerClient.fetch_song_info(
|
||||
func(_data: Variant) -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
|
||||
assert_array(outcome).contains_exactly(["failed"])
|
||||
assert_array(outcome).contains_exactly(["failed"])
|
||||
|
||||
|
||||
func test_successful_request_does_not_call_on_failed() -> void:
|
||||
_server.respond_bytes("/music/addQue", PackedByteArray())
|
||||
var outcome: Array[String] = []
|
||||
_server.respond_bytes("/music/addQue", PackedByteArray())
|
||||
var outcome: Array[String] = []
|
||||
|
||||
MusicServerClient.add_to_queue(
|
||||
func() -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
MusicServerClient.add_to_queue(
|
||||
func() -> void: outcome.append("done"),
|
||||
func() -> void: outcome.append("failed"))
|
||||
|
||||
assert_array(outcome).contains_exactly(["done"])
|
||||
assert_array(outcome).contains_exactly(["done"])
|
||||
|
||||
|
||||
func test_send_calls_back_without_arguments() -> void:
|
||||
_server.respond_bytes("/music/reset", PackedByteArray())
|
||||
var called: Array[bool] = [false]
|
||||
_server.respond_bytes("/music/reset", PackedByteArray())
|
||||
var called: Array[bool] = [false]
|
||||
|
||||
MusicServerClient.reset_playlist(func() -> void: called[0] = true)
|
||||
MusicServerClient.reset_playlist(func() -> void: called[0] = true)
|
||||
|
||||
assert_bool(called[0]).is_true()
|
||||
assert_bool(called[0]).is_true()
|
||||
|
||||
|
||||
func test_mark_song_played_sends_put() -> void:
|
||||
_server.respond_bytes("/music/played?song=3", PackedByteArray())
|
||||
_server.respond_bytes("/music/played?song=3", PackedByteArray())
|
||||
|
||||
MusicServerClient.mark_song_played(3)
|
||||
MusicServerClient.mark_song_played(3)
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/played?song=3"])
|
||||
assert_array(_server.requested_methods).contains_exactly([HTTPClient.METHOD_PUT])
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/played?song=3"])
|
||||
assert_array(_server.requested_methods).contains_exactly([HTTPClient.METHOD_PUT])
|
||||
|
||||
|
||||
func test_character_name_is_url_encoded() -> void:
|
||||
MusicServerClient.fetch_character_image("Paper Mario.png", func(_body: PackedByteArray) -> void: pass)
|
||||
MusicServerClient.fetch_character_image("Paper Mario.png", func(_body: PackedByteArray) -> void: pass)
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/character?name=Paper%20Mario.png"])
|
||||
assert_array(_server.requested_paths).contains_exactly(["/character?name=Paper%20Mario.png"])
|
||||
|
||||
|
||||
func test_requests_go_to_selected_server() -> void:
|
||||
var previous_path: String = Settings.default_path
|
||||
Settings.default_path = "http://localhost:8080"
|
||||
var requested_urls: Array[String] = []
|
||||
var recording_transport: HttpTransport = _RecordingTransport.new(requested_urls)
|
||||
MusicServerClient.transport = recording_transport
|
||||
var previous_path: String = Settings.default_path
|
||||
Settings.default_path = "http://localhost:8080"
|
||||
var requested_urls: Array[String] = []
|
||||
var recording_transport: HttpTransport = _RecordingTransport.new(requested_urls)
|
||||
MusicServerClient.transport = recording_transport
|
||||
|
||||
MusicServerClient.fetch_song_info(func(_data: Variant) -> void: pass)
|
||||
MusicServerClient.fetch_song_info(func(_data: Variant) -> void: pass)
|
||||
|
||||
Settings.default_path = previous_path
|
||||
assert_array(requested_urls).contains_exactly(["http://localhost:8080/music/info"])
|
||||
Settings.default_path = previous_path
|
||||
assert_array(requested_urls).contains_exactly(["http://localhost:8080/music/info"])
|
||||
|
||||
|
||||
class _RecordingTransport:
|
||||
extends HttpTransport
|
||||
extends HttpTransport
|
||||
|
||||
var _urls: Array[String]
|
||||
var _urls: Array[String]
|
||||
|
||||
func _init(urls: Array[String]) -> void:
|
||||
super(null)
|
||||
_urls = urls
|
||||
func _init(urls: Array[String]) -> void:
|
||||
super(null)
|
||||
_urls = urls
|
||||
|
||||
func request(url: String, _method: int, _on_complete: Callable) -> void:
|
||||
_urls.append(url)
|
||||
func request(url: String, _method: int, _on_complete: Callable) -> void:
|
||||
_urls.append(url)
|
||||
@@ -5,134 +5,134 @@ var _player: PlayerObject
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_winning_score = Settings.winning_score
|
||||
Settings.winning_score = 3
|
||||
_player = PlayerObject.new("Crono")
|
||||
_winning_score = Settings.winning_score
|
||||
Settings.winning_score = 3
|
||||
_player = PlayerObject.new("Crono")
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
Settings.winning_score = _winning_score
|
||||
Settings.winning_score = _winning_score
|
||||
|
||||
|
||||
func test_first_point_triggers_first_point_signal() -> void:
|
||||
monitor_signals(_player, false)
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
assert_int(_player.player_score).is_equal(1)
|
||||
await assert_signal(_player).is_emitted("first_point_triggerd")
|
||||
await assert_signal(_player).is_emitted("player_point_given")
|
||||
assert_int(_player.player_score).is_equal(1)
|
||||
await assert_signal(_player).is_emitted("first_point_triggerd")
|
||||
await assert_signal(_player).is_emitted("player_point_given")
|
||||
|
||||
|
||||
func test_one_point_from_winning_triggers_match_point() -> void:
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
await assert_signal(_player).is_emitted("match_point_triggerd")
|
||||
await assert_signal(_player).is_emitted("match_point_triggerd")
|
||||
|
||||
|
||||
func test_reaching_winning_score_triggers_winner() -> void:
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
assert_int(_player.player_score).is_equal(3)
|
||||
await assert_signal(_player).is_emitted("winner_triggerd")
|
||||
assert_int(_player.player_score).is_equal(3)
|
||||
await assert_signal(_player).is_emitted("winner_triggerd")
|
||||
|
||||
|
||||
func test_score_does_not_go_past_winning_score() -> void:
|
||||
for i: int in 3:
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
for i: int in 3:
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
assert_int(_player.player_score).is_equal(3)
|
||||
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_given")
|
||||
assert_int(_player.player_score).is_equal(3)
|
||||
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_given")
|
||||
|
||||
|
||||
func test_ordinary_point_plays_point_sound() -> void:
|
||||
Settings.winning_score = 10
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
Settings.winning_score = 10
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
await assert_signal(_player).is_emitted("point_given_sound")
|
||||
await assert_signal(_player).is_emitted("point_given_sound")
|
||||
|
||||
|
||||
func test_minus_point_lowers_score() -> void:
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
_player.add_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.minus_point()
|
||||
_player.minus_point()
|
||||
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
await assert_signal(_player).is_emitted("player_point_taken")
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
await assert_signal(_player).is_emitted("player_point_taken")
|
||||
|
||||
|
||||
func test_score_does_not_go_below_zero() -> void:
|
||||
monitor_signals(_player, false)
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.minus_point()
|
||||
_player.minus_point()
|
||||
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_taken")
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_taken")
|
||||
|
||||
|
||||
func test_dropping_back_to_zero_allows_first_point_again() -> void:
|
||||
_player.add_point()
|
||||
_player.minus_point()
|
||||
monitor_signals(_player, false)
|
||||
_player.add_point()
|
||||
_player.minus_point()
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
await assert_signal(_player).is_emitted("first_point_triggerd")
|
||||
await assert_signal(_player).is_emitted("first_point_triggerd")
|
||||
|
||||
|
||||
func test_reset_points() -> void:
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
_player.reset_points()
|
||||
_player.reset_points()
|
||||
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
assert_bool(_player.is_first_point).is_true()
|
||||
assert_int(_player.player_score).is_equal(0)
|
||||
assert_bool(_player.is_first_point).is_true()
|
||||
|
||||
|
||||
func test_id_is_a_uuid() -> void:
|
||||
var uuid_pattern: RegEx = RegEx.create_from_string(
|
||||
"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
|
||||
var uuid_pattern: RegEx = RegEx.create_from_string(
|
||||
"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
|
||||
|
||||
assert_object(uuid_pattern.search(_player.id)).is_not_null()
|
||||
assert_object(uuid_pattern.search(_player.id)).is_not_null()
|
||||
|
||||
|
||||
func test_every_player_gets_a_different_id() -> void:
|
||||
var ids: Dictionary = {}
|
||||
for i: int in 100:
|
||||
ids[PlayerObject.new("Player %d" % i).id] = true
|
||||
var ids: Dictionary = {}
|
||||
for i: int in 100:
|
||||
ids[PlayerObject.new("Player %d" % i).id] = true
|
||||
|
||||
assert_int(ids.size()).is_equal(100)
|
||||
assert_int(ids.size()).is_equal(100)
|
||||
|
||||
|
||||
func test_winning_score_of_one_is_won_with_first_point() -> void:
|
||||
Settings.winning_score = 1
|
||||
monitor_signals(_player, false)
|
||||
Settings.winning_score = 1
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
await assert_signal(_player).is_emitted("winner_triggerd")
|
||||
await assert_signal(_player).is_emitted("winner_triggerd")
|
||||
|
||||
|
||||
func test_first_point_is_match_point_when_winning_score_is_two() -> void:
|
||||
Settings.winning_score = 2
|
||||
monitor_signals(_player, false)
|
||||
Settings.winning_score = 2
|
||||
monitor_signals(_player, false)
|
||||
|
||||
_player.add_point()
|
||||
_player.add_point()
|
||||
|
||||
await assert_signal(_player).is_emitted("match_point_triggerd")
|
||||
assert_bool(_player.is_first_point).is_false()
|
||||
await assert_signal(_player).is_emitted("match_point_triggerd")
|
||||
assert_bool(_player.is_first_point).is_false()
|
||||
+98
-98
@@ -6,196 +6,196 @@ var _is_debug: bool
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_server = FakeHttpTransport.new().install()
|
||||
_add_to_stats = Settings.add_to_stats
|
||||
_is_debug = Settings.is_debug
|
||||
Settings.add_to_stats = false
|
||||
Settings.is_debug = false
|
||||
Playlist.reset_playlist()
|
||||
Playlist.number_of_tracks_to_preload = 1
|
||||
_server = FakeHttpTransport.new().install()
|
||||
_add_to_stats = Settings.add_to_stats
|
||||
_is_debug = Settings.is_debug
|
||||
Settings.add_to_stats = false
|
||||
Settings.is_debug = false
|
||||
Playlist.reset_playlist()
|
||||
Playlist.number_of_tracks_to_preload = 1
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
Playlist.reset_playlist()
|
||||
Settings.add_to_stats = _add_to_stats
|
||||
Settings.is_debug = _is_debug
|
||||
_server.uninstall()
|
||||
Playlist.reset_playlist()
|
||||
Settings.add_to_stats = _add_to_stats
|
||||
Settings.is_debug = _is_debug
|
||||
_server.uninstall()
|
||||
|
||||
|
||||
func _add_songs(count: int) -> Array[SongObject]:
|
||||
var songs: Array[SongObject] = []
|
||||
for i: int in count:
|
||||
var song: SongObject = SongObject.new()
|
||||
song.song_number = i
|
||||
song.soundtrack_title = "Soundtrack %d" % i
|
||||
song.song_title = "Song %d" % i
|
||||
Playlist.add_to_playlist(song)
|
||||
songs.append(song)
|
||||
return songs
|
||||
var songs: Array[SongObject] = []
|
||||
for i: int in count:
|
||||
var song: SongObject = SongObject.new()
|
||||
song.song_number = i
|
||||
song.soundtrack_title = "Soundtrack %d" % i
|
||||
song.song_title = "Song %d" % i
|
||||
Playlist.add_to_playlist(song)
|
||||
songs.append(song)
|
||||
return songs
|
||||
|
||||
|
||||
func test_set_latest_played_song_advances() -> void:
|
||||
_add_songs(3)
|
||||
_add_songs(3)
|
||||
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
|
||||
assert_int(Playlist.latest_played_song).is_equal(1)
|
||||
assert_int(Playlist.latest_played_song).is_equal(1)
|
||||
|
||||
|
||||
func test_set_latest_played_song_stops_at_last_song() -> void:
|
||||
_add_songs(2)
|
||||
_add_songs(2)
|
||||
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.set_latest_played_song()
|
||||
|
||||
assert_int(Playlist.latest_played_song).is_equal(1)
|
||||
assert_int(Playlist.latest_played_song).is_equal(1)
|
||||
|
||||
|
||||
func test_get_next_song_returns_latest_played() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
Playlist.latest_played_song = 2
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
Playlist.latest_played_song = 2
|
||||
|
||||
assert_object(Playlist.get_next_song()).is_same(songs[2])
|
||||
assert_object(Playlist.get_next_song()).is_same(songs[2])
|
||||
|
||||
|
||||
func test_update_last_played_song_points_past_existing_songs() -> void:
|
||||
_add_songs(4)
|
||||
_add_songs(4)
|
||||
|
||||
Playlist.update_last_played_song()
|
||||
Playlist.update_last_played_song()
|
||||
|
||||
assert_int(Playlist.latest_played_song).is_equal(4)
|
||||
assert_int(Playlist.latest_played_song).is_equal(4)
|
||||
|
||||
|
||||
func test_preloaded_songs_counts_unplayed_songs() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
songs[0].has_played = true
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
songs[0].has_played = true
|
||||
|
||||
assert_int(Playlist.get_preloaded_songs()).is_equal(2)
|
||||
assert_int(Playlist.get_preloaded_songs()).is_equal(2)
|
||||
|
||||
|
||||
func test_should_preload_more_songs_when_below_target() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
songs[0].has_played = true
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
songs[0].has_played = true
|
||||
|
||||
assert_bool(Playlist.should_preload_more_songs()).is_true()
|
||||
assert_bool(Playlist.should_preload_more_songs()).is_true()
|
||||
|
||||
|
||||
func test_should_not_preload_more_songs_when_target_reached() -> void:
|
||||
_add_songs(1)
|
||||
_add_songs(1)
|
||||
|
||||
assert_bool(Playlist.should_preload_more_songs()).is_false()
|
||||
assert_bool(Playlist.should_preload_more_songs()).is_false()
|
||||
|
||||
|
||||
func test_get_playlist_hides_unplayed_songs() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
songs[0].has_played = true
|
||||
var songs: Array[SongObject] = _add_songs(3)
|
||||
songs[0].has_played = true
|
||||
|
||||
assert_array(Playlist.get_playlist()).contains_exactly([songs[0]])
|
||||
assert_array(Playlist.get_playlist()).contains_exactly([songs[0]])
|
||||
|
||||
|
||||
func test_get_playlist_shows_everything_in_debug() -> void:
|
||||
Settings.is_debug = true
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
Settings.is_debug = true
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
|
||||
assert_array(Playlist.get_playlist()).contains_exactly(songs)
|
||||
assert_array(Playlist.get_playlist()).contains_exactly(songs)
|
||||
|
||||
|
||||
func test_song_is_answered_marks_song() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
|
||||
Playlist.song_is_answered(1)
|
||||
Playlist.song_is_answered(1)
|
||||
|
||||
assert_bool(songs[1].is_answered).is_true()
|
||||
assert_bool(songs[0].is_answered).is_false()
|
||||
assert_bool(songs[1].is_answered).is_true()
|
||||
assert_bool(songs[0].is_answered).is_false()
|
||||
|
||||
|
||||
func test_song_is_answered_reports_to_stats_when_enabled() -> void:
|
||||
Settings.add_to_stats = true
|
||||
_add_songs(2)
|
||||
Settings.add_to_stats = true
|
||||
_add_songs(2)
|
||||
|
||||
Playlist.song_is_answered(1)
|
||||
Playlist.song_is_answered(1)
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/played?song=1"])
|
||||
assert_array(_server.requested_paths).contains_exactly(["/music/played?song=1"])
|
||||
|
||||
|
||||
func test_song_is_answered_does_not_report_when_stats_disabled() -> void:
|
||||
_add_songs(2)
|
||||
_add_songs(2)
|
||||
|
||||
Playlist.song_is_answered(1)
|
||||
Playlist.song_is_answered(1)
|
||||
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
|
||||
|
||||
func test_points_are_recorded_on_current_song() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
Playlist.set_currently_playing_song(1)
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
Playlist.set_currently_playing_song(1)
|
||||
|
||||
Playlist.add_point("lucca-id")
|
||||
Playlist.add_point("crono-id")
|
||||
Playlist.add_point("lucca-id")
|
||||
Playlist.add_point("crono-id")
|
||||
|
||||
assert_array(songs[1].players_given_point).contains_exactly(["lucca-id", "crono-id"])
|
||||
assert_array(songs[0].players_given_point).is_empty()
|
||||
assert_array(songs[1].players_given_point).contains_exactly(["lucca-id", "crono-id"])
|
||||
assert_array(songs[0].players_given_point).is_empty()
|
||||
|
||||
|
||||
func test_remove_point_from_current_song() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
Playlist.set_currently_playing_song(0)
|
||||
Playlist.add_point("crono-id")
|
||||
Playlist.add_point("marle-id")
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
Playlist.set_currently_playing_song(0)
|
||||
Playlist.add_point("crono-id")
|
||||
Playlist.add_point("marle-id")
|
||||
|
||||
Playlist.remove_point("crono-id")
|
||||
Playlist.remove_point("crono-id")
|
||||
|
||||
assert_array(songs[0].players_given_point).contains_exactly(["marle-id"])
|
||||
assert_array(songs[0].players_given_point).contains_exactly(["marle-id"])
|
||||
|
||||
|
||||
func test_remove_player_removes_only_that_players_points() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
songs[0].players_given_point.assign(["crono-id", "marle-id"])
|
||||
songs[1].players_given_point.assign(["crono-id"])
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
songs[0].players_given_point.assign(["crono-id", "marle-id"])
|
||||
songs[1].players_given_point.assign(["crono-id"])
|
||||
|
||||
Playlist.remove_player_from_list("marle-id")
|
||||
Playlist.remove_player_from_list("marle-id")
|
||||
|
||||
assert_array(songs[0].players_given_point).contains_exactly(["crono-id"])
|
||||
assert_array(songs[1].players_given_point).contains_exactly(["crono-id"])
|
||||
assert_array(songs[0].players_given_point).contains_exactly(["crono-id"])
|
||||
assert_array(songs[1].players_given_point).contains_exactly(["crono-id"])
|
||||
|
||||
|
||||
func test_reset_playlist_clears_songs_and_position() -> void:
|
||||
_add_songs(3)
|
||||
Playlist.latest_played_song = 2
|
||||
Playlist.set_currently_playing_song(1)
|
||||
_add_songs(3)
|
||||
Playlist.latest_played_song = 2
|
||||
Playlist.set_currently_playing_song(1)
|
||||
|
||||
Playlist.reset_playlist()
|
||||
Playlist.reset_playlist()
|
||||
|
||||
assert_array(Playlist.song_object_array).is_empty()
|
||||
assert_int(Playlist.latest_played_song).is_equal(0)
|
||||
assert_int(Playlist.currently_playing_song).is_equal(-1)
|
||||
assert_array(Playlist.song_object_array).is_empty()
|
||||
assert_int(Playlist.latest_played_song).is_equal(0)
|
||||
assert_int(Playlist.currently_playing_song).is_equal(-1)
|
||||
|
||||
|
||||
func test_current_titles_are_hidden_until_answered() -> void:
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
Playlist.set_currently_playing_song(0)
|
||||
var songs: Array[SongObject] = _add_songs(1)
|
||||
Playlist.set_currently_playing_song(0)
|
||||
|
||||
assert_str(Playlist.get_current_soundtrack_title()).is_equal("????????")
|
||||
assert_str(Playlist.get_current_soundtrack_title()).is_equal("????????")
|
||||
|
||||
songs[0].is_answered = true
|
||||
songs[0].is_answered = true
|
||||
|
||||
assert_str(Playlist.get_current_soundtrack_title()).is_equal("Soundtrack 0")
|
||||
assert_str(Playlist.get_current_song_title()).is_equal("Song 0")
|
||||
assert_str(Playlist.get_current_soundtrack_title()).is_equal("Soundtrack 0")
|
||||
assert_str(Playlist.get_current_song_title()).is_equal("Song 0")
|
||||
|
||||
|
||||
func test_answering_when_nothing_is_playing_does_nothing() -> void:
|
||||
Settings.add_to_stats = true
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
Settings.add_to_stats = true
|
||||
var songs: Array[SongObject] = _add_songs(2)
|
||||
|
||||
Playlist.song_is_answered()
|
||||
Playlist.song_is_answered()
|
||||
|
||||
assert_bool(songs[0].is_answered).is_false()
|
||||
assert_bool(songs[1].is_answered).is_false()
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
assert_bool(songs[0].is_answered).is_false()
|
||||
assert_bool(songs[1].is_answered).is_false()
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
|
||||
|
||||
func test_answering_with_empty_playlist_does_nothing() -> void:
|
||||
Playlist.song_is_answered()
|
||||
Playlist.song_is_answered()
|
||||
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
+26
-26
@@ -6,57 +6,57 @@ var _search: Control
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_search = auto_free(SearchWindowScript.new())
|
||||
_search.set_soundtracks([
|
||||
"Chrono Trigger",
|
||||
"Final Fantasy VI",
|
||||
"Mario & Luigi: Superstar Saga",
|
||||
"Pokémon Red",
|
||||
"Q*bert",
|
||||
"Super Mario 64",
|
||||
"The Legend of Zelda: A Link to the Past",
|
||||
])
|
||||
_search = auto_free(SearchWindowScript.new())
|
||||
_search.set_soundtracks([
|
||||
"Chrono Trigger",
|
||||
"Final Fantasy VI",
|
||||
"Mario & Luigi: Superstar Saga",
|
||||
"Pokémon Red",
|
||||
"Q*bert",
|
||||
"Super Mario 64",
|
||||
"The Legend of Zelda: A Link to the Past",
|
||||
])
|
||||
|
||||
|
||||
func test_plain_text_matches_case_insensitively() -> void:
|
||||
assert_array(_search.find_matches("chrono")).contains_exactly(["Chrono Trigger"])
|
||||
assert_array(_search.find_matches("chrono")).contains_exactly(["Chrono Trigger"])
|
||||
|
||||
|
||||
func test_contains_matches_come_before_letter_order_matches() -> void:
|
||||
var matches: Array[String] = _search.find_matches("mario")
|
||||
var matches: Array[String] = _search.find_matches("mario")
|
||||
|
||||
assert_array(matches).contains_exactly([
|
||||
"Mario & Luigi: Superstar Saga",
|
||||
"Super Mario 64",
|
||||
])
|
||||
assert_array(matches).contains_exactly([
|
||||
"Mario & Luigi: Superstar Saga",
|
||||
"Super Mario 64",
|
||||
])
|
||||
|
||||
|
||||
func test_ignores_spaces() -> void:
|
||||
assert_array(_search.find_matches("finalfantasy")).contains_exactly(["Final Fantasy VI"])
|
||||
assert_array(_search.find_matches("finalfantasy")).contains_exactly(["Final Fantasy VI"])
|
||||
|
||||
|
||||
func test_and_matches_ampersand() -> void:
|
||||
assert_array(_search.find_matches("mario and luigi")).contains(["Mario & Luigi: Superstar Saga"])
|
||||
assert_array(_search.find_matches("mario and luigi")).contains(["Mario & Luigi: Superstar Saga"])
|
||||
|
||||
|
||||
func test_accented_letters_match_plain_letters() -> void:
|
||||
assert_array(_search.find_matches("pokemon")).contains_exactly(["Pokémon Red"])
|
||||
assert_array(_search.find_matches("pokemon")).contains_exactly(["Pokémon Red"])
|
||||
|
||||
|
||||
func test_letters_in_order_match_abbreviations() -> void:
|
||||
assert_array(_search.find_matches("lozlttp")).contains_exactly([
|
||||
"The Legend of Zelda: A Link to the Past",
|
||||
])
|
||||
assert_array(_search.find_matches("lozlttp")).contains_exactly([
|
||||
"The Legend of Zelda: A Link to the Past",
|
||||
])
|
||||
|
||||
|
||||
func test_regex_characters_are_matched_literally() -> void:
|
||||
assert_array(_search.find_matches("q*b")).contains_exactly(["Q*bert"])
|
||||
assert_array(_search.find_matches("q*b")).contains_exactly(["Q*bert"])
|
||||
|
||||
|
||||
func test_no_matches() -> void:
|
||||
assert_array(_search.find_matches("metroid")).is_empty()
|
||||
assert_array(_search.find_matches("metroid")).is_empty()
|
||||
|
||||
|
||||
func test_clean_term() -> void:
|
||||
assert_str(_search.clean_term("Rock 'n Roll Racing")).is_equal("rockandrollracing")
|
||||
assert_str(_search.clean_term("Ys I & II")).is_equal("ysiandii")
|
||||
assert_str(_search.clean_term("Rock 'n Roll Racing")).is_equal("rockandrollracing")
|
||||
assert_str(_search.clean_term("Ys I & II")).is_equal("ysiandii")
|
||||
@@ -2,12 +2,12 @@ extends GdUnitTestSuite
|
||||
|
||||
|
||||
func test_version_comes_from_project_settings() -> void:
|
||||
assert_str(Settings.version).is_equal(
|
||||
ProjectSettings.get_setting("application/config/version"))
|
||||
assert_str(Settings.version).is_equal(
|
||||
ProjectSettings.get_setting("application/config/version"))
|
||||
|
||||
|
||||
func test_version_is_major_minor_patch() -> void:
|
||||
# The release job tags and names builds with this version
|
||||
var pattern: RegEx = RegEx.create_from_string("^\\d+\\.\\d+\\.\\d+$")
|
||||
# The release job tags and names builds with this version
|
||||
var pattern: RegEx = RegEx.create_from_string("^\\d+\\.\\d+\\.\\d+$")
|
||||
|
||||
assert_object(pattern.search(Settings.version)).is_not_null()
|
||||
assert_object(pattern.search(Settings.version)).is_not_null()
|
||||
@@ -5,56 +5,56 @@ var _song: SongObject
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_is_debug = Settings.is_debug
|
||||
Settings.is_debug = false
|
||||
_song = SongObject.new()
|
||||
_song.song_number = 4
|
||||
_song.soundtrack_title = "Final Fantasy VI"
|
||||
_song.song_title = "Dancing Mad"
|
||||
_is_debug = Settings.is_debug
|
||||
Settings.is_debug = false
|
||||
_song = SongObject.new()
|
||||
_song.song_number = 4
|
||||
_song.soundtrack_title = "Final Fantasy VI"
|
||||
_song.song_title = "Dancing Mad"
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
Settings.is_debug = _is_debug
|
||||
Settings.is_debug = _is_debug
|
||||
|
||||
|
||||
func test_titles_are_hidden_until_answered() -> void:
|
||||
assert_str(_song.get_soundtrack_title()).is_equal("????????")
|
||||
assert_str(_song.get_song_title()).is_equal("??????")
|
||||
assert_str(_song.get_song_info()).is_equal("??? - ???")
|
||||
assert_str(_song.get_soundtrack_title()).is_equal("????????")
|
||||
assert_str(_song.get_song_title()).is_equal("??????")
|
||||
assert_str(_song.get_song_info()).is_equal("??? - ???")
|
||||
|
||||
|
||||
func test_titles_are_shown_once_answered() -> void:
|
||||
_song.is_answered = true
|
||||
_song.is_answered = true
|
||||
|
||||
assert_str(_song.get_soundtrack_title()).is_equal("Final Fantasy VI")
|
||||
assert_str(_song.get_song_title()).is_equal("Dancing Mad")
|
||||
assert_str(_song.get_song_info()).is_equal("5. Final Fantasy VI - Dancing Mad")
|
||||
assert_str(_song.get_soundtrack_title()).is_equal("Final Fantasy VI")
|
||||
assert_str(_song.get_song_title()).is_equal("Dancing Mad")
|
||||
assert_str(_song.get_song_info()).is_equal("5. Final Fantasy VI - Dancing Mad")
|
||||
|
||||
|
||||
func test_debug_info_shows_unanswered_songs() -> void:
|
||||
Settings.is_debug = true
|
||||
Settings.is_debug = true
|
||||
|
||||
assert_str(_song.get_song_info()).is_equal(
|
||||
"5. Final Fantasy VI - Dancing Mad | played: false | answered: false")
|
||||
assert_str(_song.get_song_info()).is_equal(
|
||||
"5. Final Fantasy VI - Dancing Mad | played: false | answered: false")
|
||||
|
||||
|
||||
func test_points_are_kept_in_the_order_given() -> void:
|
||||
_song.add_point("marle-id")
|
||||
_song.add_point("crono-id")
|
||||
_song.add_point("marle-id")
|
||||
_song.add_point("crono-id")
|
||||
|
||||
assert_array(_song.players_given_point).contains_exactly(["marle-id", "crono-id"])
|
||||
assert_array(_song.players_given_point).contains_exactly(["marle-id", "crono-id"])
|
||||
|
||||
|
||||
func test_player_gets_at_most_one_point_per_song() -> void:
|
||||
_song.add_point("crono-id")
|
||||
_song.add_point("crono-id")
|
||||
_song.add_point("crono-id")
|
||||
_song.add_point("crono-id")
|
||||
|
||||
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|
||||
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|
||||
|
||||
|
||||
func test_removing_point_of_player_without_point_changes_nothing() -> void:
|
||||
_song.add_point("crono-id")
|
||||
_song.add_point("crono-id")
|
||||
|
||||
_song.remove_point("marle-id")
|
||||
_song.remove_point("marle-id")
|
||||
|
||||
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|
||||
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|
||||
Reference in new issue
Block a user