diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-25 01:07:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-25 01:07:35 +0100 |
| commit | 996b0c06e23bcb6b300d7b8799df94993692e07d (patch) | |
| tree | 615ff0c372dac97321489e3cb7f316cb4cb9eeec /test/job_test.cc | |
| parent | 4f03da3aa12525cb8389ddefee629f5d0b2ac0aa (diff) | |
| parent | 907735ee6ca162583c7c9d20f5603a6db83a149f (diff) | |
Merge master and multifarious hackery.
Diffstat (limited to 'test/job_test.cc')
| -rw-r--r-- | test/job_test.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/job_test.cc b/test/job_test.cc new file mode 100644 index 000000000..86c6dc9e3 --- /dev/null +++ b/test/job_test.cc @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +class TestJob : public Job +{ +public: + TestJob (shared_ptr<Film> f) + : Job (f) + { + + } + + void set_finished_ok () { + set_state (FINISHED_OK); + } + + void set_finished_error () { + set_state (FINISHED_ERROR); + } + + void run () + { + while (1) { + if (finished ()) { + return; + } + } + } + + string name () const { + return ""; + } +}; + +BOOST_AUTO_TEST_CASE (job_manager_test) +{ + shared_ptr<Film> f; + + /* Single job */ + shared_ptr<TestJob> a (new TestJob (f)); + + JobManager::instance()->add (a); + dcpomatic_sleep (1); + BOOST_CHECK_EQUAL (a->running (), true); + a->set_finished_ok (); + dcpomatic_sleep (2); + BOOST_CHECK_EQUAL (a->finished_ok(), true); +} |
