Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
element-access-test.cpp
Go to the documentation of this file.
1/*
2 ElementAccess(Test) - verify mechanics of low-level UI element access
3
4 Copyright (C)
5 2018, 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"
21//#include "stage/interact/view-spec-dsl.hpp"
24//#include "gen-node-location-query.hpp"
25#include "lib/depend-inject.hpp"
26#include "lib/format-cout.hpp"
27//#include "lib/idi/entry-id.hpp"
28//#include "lib/diff/gen-node.hpp"
29#include "lib/util.hpp"
30
31//#include <string>
32//#include <vector>
33
34
35//using std::string;
36//using lib::diff::MakeRec;
37//using lib::diff::Rec;
38//using lib::idi::EntryID;
39//using lib::diff::GenNode;
41//using util::isnil;
42
43
44namespace stage {
45namespace model{
46namespace test {
47
48// using lumiera::error::LUMIERA_ERROR_WRONG_TYPE;
49// using lib::test::showSizeof;
50 using interact::UICoord;
55
58
59
60
61 /******************************************************************************/
78 class ElementAccess_test : public Test
79 {
80
81 virtual void
89
90
92 void
94 {
95 MockAccess fakeDirectory;
96
97 auto location = UICoord{"win-1","persp-A","thePanel","someView","tab#5"};
98
99 fakeDirectory.triggerCreate();
100 fakeDirectory->existingPath = location;
101 fakeDirectory->response.reset (new DummyTab);
102
103 AccessAPI accessAPI;
104 auto answer = accessAPI().access<DummyWidget> (location);
105
106 CHECK (answer.isValid());
107 DummyWidget& widget = answer;
108 CHECK (INSTANCEOF (DummyTab, &widget));
109 CHECK (isSameObject (widget, *fakeDirectory->response));
110 }
111
112
116 void
118 {
119 MockAccess fakeDirectory;
120
121 auto path = UICoord{"win-1","persp-A","thePanel"};
122 auto location = UICoord{"win-1","persp-A","thePanel","someView"};
123
124 fakeDirectory.triggerCreate();
125 fakeDirectory->existingPath = path;
126 CHECK (not fakeDirectory->response);
127
128 AccessAPI accessAPI;
129 DummyView& view = accessAPI().access<DummyView> (location);
130 CHECK ( fakeDirectory->response); // has been created
131 CHECK (isSameObject (view, *fakeDirectory->response));
132 }
133
134
135 void
137 {
138 UNIMPLEMENTED ("limit creation of new sibling objects");
139 }
140
141
142 void
144 {
145 UNIMPLEMENTED ("create a new path from scratch");
146 }
147 };
148
149
152
153
154}}} // namespace stage::model::test
Configuration handle for temporarily shadowing a dependency by a test mock instance.
MOC & triggerCreate()
trigger lazy service object instantiation
Access point to singletons and other kinds of dependencies designated by type.
Definition depend.hpp:281
Describe a location within the UI through structural/topological coordinates.
Definition ui-coord.hpp:131
Mock implementation of the model::ElementAccess interface for testing without actual UI.
Per type specific configuration of instances created as service dependencies.
Automatically use custom string conversion in C++ stream output.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Unit test helper for access to UI elements without actually running an UI.
A collection of frequently used helper functions to support unit testing.
A topological addressing scheme to designate structural locations within the UI.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Definition util.hpp:514