2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "wx/cucumber_bridge.h"
22 #include "lib/nanomsg.h"
23 #include <boost/test/unit_test.hpp>
24 #include <boost/process.hpp>
27 #include <cucumber-cpp/autodetect.hpp>
32 using std::stringstream;
34 using boost::optional;
35 using cucumber::ScenarioScope;
41 _nanomsg = new Nanomsg (true);
42 _dom = new boost::process::child ("/home/carl/src/dcpomatic/build/src/tools/dcpomatic2", "--cucumber");
43 /* Await "ready" message */
44 _nanomsg->receive (-1);
47 void click_button (string id)
50 send (CUCUMBER_BRIDGE_CLICK_BUTTON);
54 void select_menu (string id)
57 send (CUCUMBER_BRIDGE_SELECT_MENU);
61 void type (std::string text)
64 send (CUCUMBER_BRIDGE_TYPE);
68 void add_content_file (string filename)
71 send (CUCUMBER_BRIDGE_ADD_CONTENT_FILE);
75 vector<string> content_list ()
77 send (CUCUMBER_BRIDGE_GET_CONTENT_LIST);
78 stringstream all(receive());
81 while (getline(all, one, '\n')) {
90 _nanomsg->send(m + "\n", -1);
93 std::string receive ()
95 return _nanomsg->receive(-1).get();
104 boost::process::child* _dom;
108 GIVEN("^I have created a new film$") {
109 ScenarioScope<DoMCtx> context;
110 context->select_menu (CUCUMBER_MENU_FILE_NEW);
111 context->type ("test");
115 WHEN("^I add file (.+) as content$") {
116 REGEX_PARAM(string, filename);
117 ScenarioScope<DoMCtx> context;
118 /* I could not find a way to reliably enter text into a open file dialogue, so
119 * there's a custom method here.
121 context->add_content_file (filename);
124 THEN("^the result should be only (.+) in the content list$") {
125 REGEX_PARAM(string, entry);
126 ScenarioScope<DoMCtx> context;
127 vector<string> content = context->content_list ();
128 BOOST_CHECK_EQUAL (content.size(), 1);
129 BOOST_CHECK_EQUAL (content.front(), entry);