59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
from pathlib import Path
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def path(relative):
|
|
return ROOT / relative
|
|
|
|
|
|
def read(relative):
|
|
source_path = path(relative)
|
|
return source_path.read_text(encoding="utf-8") if source_path.exists() else ""
|
|
|
|
|
|
class TitleScreenSourceTests(unittest.TestCase):
|
|
def test_media_modules_are_linked(self):
|
|
build = read("Source/pogo/pogo.Build.cs")
|
|
self.assertIn('"MediaAssets"', build)
|
|
self.assertIn('"SlateCore"', build)
|
|
|
|
def test_controller_owns_ui_input_mode(self):
|
|
source = read("Source/pogo/UI/PogoTitleScreenPlayerController.cpp")
|
|
self.assertIn("CreateWidget<UPogoTitleScreenWidget>", source)
|
|
self.assertIn("FInputModeUIOnly", source)
|
|
self.assertIn("bShowMouseCursor = true", source)
|
|
|
|
def test_widget_uses_approved_media_and_layout(self):
|
|
source = read("Source/pogo/UI/PogoTitleScreenWidget.cpp")
|
|
self.assertIn('TEXT("./Movies/pogo.mp4")', source)
|
|
self.assertIn("SetLooping(true)", source)
|
|
self.assertIn("EStretch::ScaleToFill", source)
|
|
self.assertIn("FAnchors(0.5f, 1.0f)", source)
|
|
self.assertIn("0.65f", source)
|
|
|
|
def test_play_is_idempotent_and_opens_gameplay(self):
|
|
source = read("Source/pogo/UI/PogoTitleScreenWidget.cpp")
|
|
self.assertIn("if (bTransitionStarted)", source)
|
|
self.assertIn("bTransitionStarted = true", source)
|
|
self.assertLess(
|
|
source.index("if (bTransitionStarted)"),
|
|
source.index("bTransitionStarted = true"),
|
|
)
|
|
self.assertIn(
|
|
'FName(TEXT("/Game/ThirdPerson/Lvl_ThirdPerson"))', source
|
|
)
|
|
self.assertIn("EKeys::Enter", source)
|
|
self.assertIn("EKeys::SpaceBar", source)
|
|
|
|
def test_failure_paths_do_not_disable_play(self):
|
|
source = read("Source/pogo/UI/PogoTitleScreenWidget.cpp")
|
|
self.assertIn("void UPogoTitleScreenWidget::RequestPlay", source)
|
|
before_request = source[: source.index("void UPogoTitleScreenWidget::RequestPlay")]
|
|
self.assertNotIn("PlayButton->SetIsEnabled(false)", before_request)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|