diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-26 02:18:21 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-26 02:21:16 +0100 |
| commit | 69fabac6d2219c07cfdcd9a8fe6e92bf4669be46 (patch) | |
| tree | 1627020b59fb7380f6e7a4d5ba42de8f1955242c /src/tools | |
| parent | 811e70bdd09a618f8b0a512950a7f3254c591614 (diff) | |
Add a simple cucumber test.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic.cc | 89 | ||||
| -rw-r--r-- | src/tools/wscript | 6 |
2 files changed, 92 insertions, 3 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 3d9d571af..20f9beaa1 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -26,6 +26,10 @@ #include "wx/about_dialog.h" #include "wx/content_panel.h" +#ifdef DCPOMATIC_CUCUMBER +#include "wx/cucumber_bridge.h" +#include "wx/cucumber_registry.h" +#endif #include "wx/dcp_referencing_dialog.h" #include "wx/dkdm_dialog.h" #include "wx/export_subtitles_dialog.h" @@ -530,6 +534,17 @@ public: return _film; } +#ifdef DCPOMATIC_CUCUMBER + void cucumber_add_content_file(string filename) { + _film_editor->cucumber_add_content_file(filename); + } + + /* Could be called from any thread */ + std::string cucumber_get_content_list() { + return _film_editor->cucumber_get_content_list(); + } +#endif + private: void show (wxShowEvent& ev) @@ -1604,7 +1619,10 @@ static const wxCmdLineEntryDesc command_line_description[] = { { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "c", "content", "add content file / directory", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "d", "dcp", "add content DCP", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, - { wxCMD_LINE_SWITCH, "v", "version", "show version", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_SWITCH, "v", "version", "show DCP-o-matic version", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, +#ifdef DCPOMATIC_CUCUMBER + { wxCMD_LINE_SWITCH, "t", "cucumber", "enable cucumber tests", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, +#endif { wxCMD_LINE_OPTION, "", "config", "directory containing config.xml and cinemas.xml", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 } @@ -1760,6 +1778,12 @@ private: grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] ")); setup_grok_library_path(); #endif + +#ifdef DCPOMATIC_CUCUMBER + if (_cucumber_bridge) { + _cucumber_bridge->start(); + } +#endif } catch (exception& e) { @@ -1806,9 +1830,67 @@ private: State::override_path = wx_to_std (config); } +#ifdef DCPOMATIC_CUCUMBER + if (parser.Found(wxT("cucumber"))) { + _cucumber_bridge = new CucumberBridge(); + _cucumber_bridge->ClickRegisteredButton.connect(bind(&App::cucumber_click_registered_button, this, _1)); + _cucumber_bridge->ClickButtonId.connect(bind(&App::cucumber_click_button_id, this, _1)); + _cucumber_bridge->SelectMenu.connect(bind(&App::cucumber_select_menu, this, _1)); + _cucumber_bridge->Type.connect(bind(&App::cucumber_type, this, _1)); + _cucumber_bridge->AddContentFile.connect(bind(&App::cucumber_add_content_file, this, _1)); + _cucumber_bridge->GetContentList.connect(bind(&App::cucumber_get_content_list, this)); + } +#endif + return true; } + +#ifdef DCPOMATIC_CUCUMBER + void cucumber_add_content_file(string filename) + { + _frame->cucumber_add_content_file(filename); + } + + + std::string cucumber_get_content_list() + { + return _frame->cucumber_get_content_list(); + } + + + void cucumber_click_registered_button(string id) + { + CucumberRegistry::instance()->click_button(id); + } + + void cucumber_click_button_id(wxStandardID id) + { + wxCommandEvent event(wxEVT_BUTTON, id); + if (auto focus = wxWindow::FindFocus()) { + if (auto dialog = focus->GetParent()) { + event.SetEventObject(dialog); + dialog->HandleWindowEvent(event); + } + } + } + + void cucumber_select_menu(string id) + { + if (id == CUCUMBER_MENU_FILE_NEW) { + wxPostEvent(_frame, wxMenuEvent(wxEVT_MENU, ID_file_new)); + } + } + + + void cucumber_type(string text) + { + if (auto ctrl = dynamic_cast<wxTextCtrl*>(wxWindow::FindFocus())) { + ctrl->SetValue(std_to_wx(text)); + } + } +#endif + void report_exception () { try { @@ -2003,6 +2085,9 @@ private: string _film_to_create; string _content_to_add; string _dcp_to_add; +#ifdef DCPOMATIC_CUCUMBER + CucumberBridge* _cucumber_bridge = nullptr; +#endif }; diff --git a/src/tools/wscript b/src/tools/wscript index e6d7c4be1..7eae66636 100644 --- a/src/tools/wscript +++ b/src/tools/wscript @@ -103,10 +103,14 @@ def build(bld): if bld.env.ENABLE_DISK: if bld.env.TARGET_LINUX: uselib += 'POLKIT ' - uselib += 'LWEXT4 NANOMSG ' + uselib += 'LWEXT4 ' + + if bld.env.ENABLE_DISK or bld.env.ENABLE_CUCUMBER: + uselib += 'NANOMSG ' if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32: uselib += 'WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE WINSOCK2 OLE32 DSOUND WINMM KSUSER SETUPAPI UUID ' + if bld.env.TARGET_LINUX: uselib += 'DL ' |
