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", source) self.assertIn("FInputModeUIOnly", source) self.assertIn("bShowMouseCursor = true", source) def test_widget_accepts_and_forwards_keyboard_focus(self): source = read("Source/pogo/UI/PogoTitleScreenWidget.cpp") self.assertIn("SetIsFocusable(true)", source) self.assertIn("SetDesiredFocusWidget(PlayButton)", source) def test_widget_uses_approved_media_and_layout(self): source = read("Source/pogo/UI/PogoTitleScreenWidget.cpp") self.assertIn("NewObject", source) self.assertIn('SetFilePath(TEXT("./Movies/pogo.mp4"))', source) self.assertIn("OpenSource(VideoSource)", 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) def test_packaged_media_sources_exist(self): self.assertTrue(path("Content/Movies/pogo.mp4").is_file()) self.assertTrue(path("SourceArt/Audio/pogo.wav").is_file()) def test_title_map_is_the_runtime_default(self): config = read("Config/DefaultEngine.ini") self.assertIn( "GameDefaultMap=/Game/Pogo/Maps/Lvl_TitleScreen.Lvl_TitleScreen", config, ) self.assertIn( "EditorStartupMap=/Game/ThirdPerson/Lvl_ThirdPerson.Lvl_ThirdPerson", config, ) def test_setup_script_creates_required_assets(self): setup = read("Scripts/setup_title_screen.py") self.assertIn('"/Game/Pogo/Audio/S_PogoTitleMusic"', setup) self.assertIn('"/Game/Pogo/Maps/Lvl_TitleScreen"', setup) self.assertIn('set_editor_property("looping", True)', setup) self.assertIn("unreal.PogoTitleScreenGameMode", setup) if __name__ == "__main__": unittest.main()