Tempo ramps - make ramp test more challenging.
[ardour.git] / libs / ardour / test / session_test.cc
1
2 #include <glibmm/fileutils.h>
3 #include <glibmm/miscutils.h>
4
5 #include <stdexcept>
6
7 #include "pbd/textreceiver.h"
8 #include "pbd/file_utils.h"
9 #include "ardour/session.h"
10 #include "ardour/audioengine.h"
11 #include "ardour/smf_source.h"
12 #include "ardour/midi_model.h"
13
14 #include "test_util.h"
15
16 #include "session_test.h"
17
18 CPPUNIT_TEST_SUITE_REGISTRATION (SessionTest);
19
20 using namespace std;
21 using namespace ARDOUR;
22 using namespace PBD;
23
24 void
25 SessionTest::new_session ()
26 {
27         const string session_name("test_session");
28         std::string new_session_dir = Glib::build_filename (new_test_output_dir(), session_name);
29
30         CPPUNIT_ASSERT (!Glib::file_test (new_session_dir, Glib::FILE_TEST_EXISTS));
31
32         create_and_start_dummy_backend ();
33
34         ARDOUR::Session* new_session = load_session (new_session_dir, "test_session");
35
36         CPPUNIT_ASSERT (new_session);
37
38         new_session->save_state ("");
39
40         delete new_session;
41         stop_and_destroy_backend ();
42 }
43
44 void
45 SessionTest::new_session_from_template ()
46 {
47         const string session_name("two_tracks");
48         const string session_template_dir_name("2 Track-template");
49
50         std::string new_session_dir = Glib::build_filename (new_test_output_dir(), session_name);
51
52         CPPUNIT_ASSERT (!Glib::file_test (new_session_dir, Glib::FILE_TEST_EXISTS));
53
54         std::string session_template_dir = test_search_path ().front ();
55         session_template_dir = Glib::build_filename (session_template_dir, "2 Track-template");
56
57         CPPUNIT_ASSERT (Glib::file_test (session_template_dir, Glib::FILE_TEST_IS_DIR));
58
59         Session* new_session = 0;
60         BusProfile* bus_profile = 0;
61
62         create_and_start_dummy_backend ();
63
64         // create a new session based on session template
65         new_session = new Session (*AudioEngine::instance (), new_session_dir, session_name,
66                                 bus_profile, session_template_dir);
67
68         CPPUNIT_ASSERT (new_session);
69
70         new_session->save_state ("");
71
72         delete new_session;
73         stop_and_destroy_backend ();
74
75         // keep the same audio backend
76         create_and_start_dummy_backend ();
77
78         Session* template_session = 0;
79
80         // reopen same session to check that it opens without error
81         template_session = new Session (*AudioEngine::instance (), new_session_dir, session_name);
82
83         CPPUNIT_ASSERT (template_session);
84
85         delete template_session;
86         stop_and_destroy_backend ();
87 }