ardour
session_test.cc
Go to the documentation of this file.
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 
19 
20 using namespace std;
21 using namespace ARDOUR;
22 using namespace PBD;
23 
24 void
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 
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;
42 }
43 
44 void
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 
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;
74 
75  // keep the same audio 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;
87 }
Session * load_session(string dir, string state)
Definition: test_util.cc:125
void create_and_start_dummy_backend()
Definition: test_util.cc:100
Definition: Beats.hpp:239
CPPUNIT_TEST_SUITE_REGISTRATION(SessionTest)
Definition: amp.h:29
void stop_and_destroy_backend()
Definition: test_util.cc:114
bool new_session
Definition: opts.cc:41
PBD::Searchpath test_search_path()
Definition: test_util.cc:133
Definition: debug.h:30
std::string session_name
Definition: opts.cc:34
std::string new_test_output_dir(std::string prefix)
Definition: test_util.cc:144
void new_session()
Definition: session_test.cc:25
int save_state(std::string snapshot_name, bool pending=false, bool switch_to_snapshot=false, bool template_only=false)
void new_session_from_template()
Definition: session_test.cc:45