Lumiera  0.pre.03
»edit your freedom«
life-cycle-test.cpp
Go to the documentation of this file.
1 /*
2  LifeCycle(Test) - checking the lifecycle callback hooks provided by AppState
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
20 #include "lib/test/run.hpp"
21 #include "lib/util.hpp"
22 
23 #include "include/lifecycle.h"
24 
25 
26 
27 
28 namespace lumiera{
29 namespace test {
30 
31  uint basicInit (0);
32  uint customCallback (0);
33 
34  void basicInitHook () { ++basicInit; }
35  void myCallback() { ++customCallback; }
36 
37  const char* MY_DEADLY_EVENT = "dial M for murder";
38 
39 
40  namespace // register them to be invoked by lifecycle event id
41  {
42  LifecycleHook _schedule1 (ON_BASIC_INIT, &basicInitHook);
43  LifecycleHook _schedule2 (MY_DEADLY_EVENT, &myCallback);
44  }
45 
46 
51  class LifeCycle_test : public Test
52  {
53  virtual void
54  run (Arg)
55  {
56  CHECK (basicInit, "the basic-init callback hasn't been invoked automatically");
57  CHECK (1 == basicInit, "the basic-init callback has been invoked more than once");
58 
59  CHECK (!customCallback);
60  LifecycleHook::trigger (MY_DEADLY_EVENT);
61  CHECK ( 1 == customCallback);
62  }
63 
64  };
65 
66  LAUNCHER (LifeCycle_test, "function common");
67 
68 
69 
70 
71 }} // namespace util::test
72 
const char * ON_BASIC_INIT
automatic static init. treated specially to run as soon as possible
Installing and invoking of application lifecycle event callbacks.
Definition: run.hpp:40
static void trigger(Symbol eventLabel)
trigger lifecycle callbacks registered under the given label
Definition: lifecycle.cpp:72
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
define and register a callback for a specific lifecycle event.
Definition: lifecycle.h:67
Lumiera public interface.
Definition: advice.cpp:104