aRts audio server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.2KB

  1. /*
  2. Copyright (C) 2000 Stefan Westerfeld
  3. stefan@space.twc.de
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "flowsystem.h"
  18. #include "connect.h"
  19. #include "value.h"
  20. #include "test.h"
  21. using namespace Arts;
  22. using namespace std;
  23. struct TestFlowSystem : public TestCase
  24. {
  25. TESTCASE(TestFlowSystem);
  26. Dispatcher dispatcher;
  27. StringValue v1, v2;
  28. void process() {
  29. dispatcher.ioManager()->processOneEvent(false);
  30. }
  31. void setUp() {
  32. /* initialize v1, v2 with values */
  33. v1 = StringValue(); v1.value("v1");
  34. v2 = StringValue(); v2.value("v2");
  35. }
  36. void tearDown() {
  37. v1 = StringValue::null();
  38. v2 = StringValue::null();
  39. }
  40. TEST(connectObject) {
  41. dispatcher.flowSystem()->connectObject(v1,"value_changed",v2,"value");
  42. testEquals("v1",v1.value());
  43. testEquals("v2",v2.value());
  44. v1.value("test");
  45. process();
  46. testEquals("test",v1.value());
  47. testEquals("test",v2.value());
  48. }
  49. // at the time of writing, this fails: disconnectObject is not implemented
  50. TEST(disconnectObject) {
  51. connect(v1,"value_changed",v2,"value");
  52. /* here we have a connection, so this should be sent */
  53. v1.value("sendThis");
  54. process();
  55. testEquals("sendThis", v2.value());
  56. dispatcher.flowSystem()->disconnectObject(v1,"value_changed",
  57. v2,"value");
  58. /* here we don't have a connection, so this should not be sent */
  59. v1.value("v1only");
  60. process();
  61. testEquals("v1only", v1.value());
  62. testEquals("sendThis", v2.value());
  63. }
  64. };
  65. TESTMAIN(TestFlowSystem);