MCPcopy Create free account
hub / github.com/DISTRHO/DPF / main

Function main

tests/Application.cpp:43–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41// --------------------------------------------------------------------------------------------------------------------
42
43END_NAMESPACE_DGL
44
45int main()
46{
47 using DGL_NAMESPACE::Application;
48 using DGL_NAMESPACE::ApplicationQuitter;
49 using DGL_NAMESPACE::IdleCallbackCounter;
50
51 // regular usage
52 {
53 Application app(true);
54 IdleCallbackCounter idleCounter;
55 app.addIdleCallback(&idleCounter);
56 DISTRHO_ASSERT_EQUAL(app.isQuitting(), false, "app MUST NOT be set as quitting during init");
57 DISTRHO_ASSERT_EQUAL(idleCounter.counter, 0, "app MUST NOT have triggered idle callbacks yet");
58 app.idle();
59 DISTRHO_ASSERT_EQUAL(app.isQuitting(), false, "app MUST NOT be set as quitting after idle()");
60 DISTRHO_ASSERT_EQUAL(idleCounter.counter, 1, "app MUST have triggered 1 idle callback");
61 app.idle();
62 DISTRHO_ASSERT_EQUAL(idleCounter.counter, 2, "app MUST have triggered 2 idle callbacks");
63 app.quit();
64 DISTRHO_ASSERT_EQUAL(app.isQuitting(), true, "app MUST be set as quitting after quit()");
65 DISTRHO_ASSERT_EQUAL(idleCounter.counter, 2, "app MUST have triggered only 2 idle callbacks in its lifetime");
66 }
67
68 // standalone exec, must not block forever due to quit() called from another thread
69 {
70 Application app(true);
71 ApplicationQuitter appQuitter(app);
72 IdleCallbackCounter idleCounter;
73 app.addIdleCallback(&idleCounter);
74 app.exec();
75 DISTRHO_ASSERT_EQUAL(appQuitter.isThreadRunning(), false, "app quit triggered because we told it so");
76 DISTRHO_ASSERT_NOT_EQUAL(idleCounter.counter, 0, "app idle callbacks MUST have been triggered");
77 }
78
79 // standalone exec, but with 0 as timeout
80 {
81 Application app(true);
82 ApplicationQuitter appQuitter(app);
83 IdleCallbackCounter idleCounter;
84 app.addIdleCallback(&idleCounter);
85 app.exec(0);
86 DISTRHO_ASSERT_EQUAL(appQuitter.isThreadRunning(), false, "app quit triggered because we told it so");
87 DISTRHO_ASSERT_NOT_EQUAL(idleCounter.counter, 0, "app idle callbacks MUST have been triggered");
88 }
89
90 return 0;
91}
92
93// --------------------------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 5

isQuittingMethod · 0.80
execMethod · 0.80
addIdleCallbackMethod · 0.45
idleMethod · 0.45
quitMethod · 0.45

Tested by

no test coverage detected