1 /*
2   ZynAddSubFX - a software synthesizer
3 
4   PluginTest.h - CxxTest for realtime watch points
5   Copyright (C) 2015-2015 Mark McCurry
6   Authors: Mark McCurry
7 
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of version 2 of the GNU General Public License
10   as published by the Free Software Foundation.
11 
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License (version 2 or later) for more details.
16 
17   You should have received a copy of the GNU General Public License (version 2)
18   along with this program; if not, write to the Free Software Foundation,
19   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 
21 */
22 #include "test-suite.h"
23 #include <cmath>
24 #include <cstdlib>
25 #include <iostream>
26 #include <fstream>
27 #include <string>
28 #include <thread>
29 #include <rtosc/thread-link.h>
30 #include "../Misc/Time.h"
31 #include "../Params/LFOParams.h"
32 #include "../Synth/LFO.h"
33 #include "../Synth/SynthNote.h"
34 #include <unistd.h>
35 using namespace std;
36 using namespace zyn;
37 
38 char *instance_name=(char*)"";
39 
40 class WatchTest
41 {
42     public:
43         rtosc::ThreadLink *tr;
44         SYNTH_T      *s;
45         AbsTime      *at;
46         WatchManager *w;
47         LFOParams    *par;
48         LFO          *l;
setUp()49         void setUp() {
50             tr  = new rtosc::ThreadLink(1024,3);
51             s   = new SYNTH_T;
52             at  = new AbsTime(*s);
53             w   = new WatchManager(tr);
54             par = new LFOParams(at);
55             l   = new LFO(*par, 440.0, *at, w);
56 
57         }
58 
tearDown()59         void tearDown() {
60             delete at;
61             delete s;
62             delete tr;
63         }
64 
testNoWatch(void)65         void testNoWatch(void)
66         {
67             TS_ASSERT(!tr->hasNext());
68             l->lfoout();
69             TS_ASSERT(!tr->hasNext());
70         }
71 
testPhaseWatch(void)72         void testPhaseWatch(void)
73         {
74             TS_ASSERT(!tr->hasNext());
75             w->add_watch("out");
76             l->lfoout();
77             w->tick();
78             TS_ASSERT(tr->hasNext());
79             TS_ASSERT_EQUAL_STR("out", tr->read());
80             TS_ASSERT(!tr->hasNext());
81         }
82 
83 };
84 
main()85 int main()
86 {
87     WatchTest test;
88     RUN_TEST(testNoWatch);
89     RUN_TEST(testPhaseWatch);
90     return test_summary();
91 }
92