Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
command-binding-test.cpp
Go to the documentation of this file.
1/*
2 CommandBinding(Test) - special cases of binding command arguments
3
4 Copyright (C)
5 2009, 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
19#include "lib/test/run.hpp"
22#include "lib/format-cout.hpp"
23
24
25namespace steam {
26namespace control {
27namespace test {
28
29
30
31
32
33
34
35 /*************************************************************************/
44 class CommandBinding_test : public Test
45 {
46
47
48 virtual void
49 run (Arg)
50 {
52 uint cnt_inst = Command::instance_count();
53
55
56 Command::remove("test.command3.1");
57 Command::remove("test.command3.2");
58
59 CHECK (cnt_defs == Command::definition_count());
60 CHECK (cnt_inst == Command::instance_count());
61 }
62
63
64 void
66 {
68
69 CommandDef ("test.command3.1")
71 .captureUndo (command3::capture)
72 .undoOperation (command3::undoIt)
73 .bind() // spurious bind doesn't hurt
74 .execSync()
75 ;
76
77 CHECK ( 1 == command3::check_);
78
79 CommandDef ("test.command3.2")
81 .captureUndo (command3::capture)
82 .undoOperation (command3::undoIt)
83 ;
84 Command com ("test.command3.2");
85 CHECK (com.canExec());
86 cout << com << endl;
87
88 com();
89 CHECK ( 2 == command3::check_);
90 com.undo();
91 CHECK ( 1 == command3::check_);
92
94 com();
95 com();
96 com();
97 CHECK ( 4 == command3::check_);
98
99 commi.undo(); // it uses the inherited UNDO state
100 CHECK ( 1 == command3::check_);
101
102 com.undo();
103 CHECK ( 3 == command3::check_);
104
105 Command::get("test.command3.1").undo();
106 CHECK ( 0 == command3::check_);
107 }
108 };
109
110
111
113 LAUNCHER (CommandBinding_test, "function controller");
114
115
116}}} // namespace steam::control::test
Helper class used solely for defining a Command-Object.
auto operation(FUN operation_to_define)
Handle object representing a single Command instance to be used by client code.
Definition command.hpp:120
static size_t definition_count()
Definition command.cpp:289
Command newInstance() const
create independent (anonymous) clone copy of this command
Definition command.cpp:200
static Command get(Symbol cmdID)
Access existing command for use.
Definition command.cpp:120
static bool remove(Symbol cmdID)
Definition command.cpp:241
static size_t instance_count()
Definition command.cpp:298
Actually defining a command and binding it to execution parameters.
Automatically use custom string conversion in C++ stream output.
unsigned int uint
Definition integral.hpp:29
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
ulong check_
< test command with zero arguments
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Some dummy command functions used for building unit test cases.