File: cxx_dev_intr_event_not_running.cpp

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (74 lines) | stat: -rw-r--r-- 1,702 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// NOLINTBEGIN(*)

#include "cxx_common.h"

#undef SUITE_NAME
#define SUITE_NAME DevIntrNotRunningTest

class EventCallBack : public CountingCallBack<Tango::DevIntrChangeEventData>
{
  public:
    std::string cb_err_reason;

  private:
    bool process_event(Tango::DevIntrChangeEventData *event) override
    {
        TS_ASSERT_EQUALS(event->errors.length(), 1u);
        cb_err_reason = event->errors[0].reason;

        return event->err;
    }
};

class DevIntrNotRunningTest : public CxxTest::TestSuite
{
  public:
    SUITE_NAME()
    {
        CxxTest::TangoPrinter::validate_args();
    }

    virtual ~SUITE_NAME() { }

    static SUITE_NAME *createSuite()
    {
        return new SUITE_NAME();
    }

    static void destroySuite(SUITE_NAME *suite)
    {
        delete suite;
    }

    //
    // Tests -------------------------------------------------------
    //
    void test_not_running_error()
    {
        try
        {
            // connect to a defined device which is not running
            auto device = std::make_shared<DeviceProxy>("sys/tg_test/1");

            EventCallBack cb{};

            device->subscribe_event(Tango::INTERFACE_CHANGE_EVENT, &cb, true);

            TS_ASSERT_EQUALS(cb.invocation_count(), 1);
            TS_ASSERT_EQUALS(cb.error_count(), 1);
            TS_ASSERT_EQUALS(cb.cb_err_reason, std::string(API_CantConnectToDevice));
        }
        catch(Tango::DevFailed &e)
        {
            Except::print_exception(e);
            TS_FAIL("Unexpected exception");
        }
        catch(CORBA::Exception &e)
        {
            Except::print_exception(e);
            TS_FAIL("Unexpected exception");
        }
    }
};

// NOLINTEND(*)