Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
test-element-access.hpp
Go to the documentation of this file.
1/*
2 TEST-ELEMENT-ACCESS.hpp - fake access directory to handle generic UI entities for test
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
14
33#ifndef STAGE_TEST_ELEMENT_ACCESS_H
34#define STAGE_TEST_ELEMENT_ACCESS_H
35
36
37#include "lib/error.hpp"
40#include "test/mock-elm.hpp"
41#include "lib/symbol.hpp"
42//#include "lib/util.hpp"
43
44#include <string>
45#include <memory>
46
47
48
49namespace stage {
50namespace test {
51 namespace error = lumiera::error;
52
53// using util::isnil;
54 using std::string;
55 using lib::Literal;
56 using interact::UICoord;
59
60
61
62
63 /* === Dummy Widgets for Unit testing === */
64
66 : public MockElm
67 {
68 public:
69 virtual ~DummyWidget() { }
70
71 DummyWidget(string name ="DummyWidget")
72 : MockElm{name}
73 { }
75 : DummyWidget{string (name)}
76 { }
77 };
78
79 struct DummyTab
81 {
83 };
84
85 struct DummyView
87 {
89 };
90
91
92
99 {
100
101 public:
102 explicit
105
106
107 /* == Test/Diagnostics interface == */
108
111
113 std::unique_ptr<model::Tangible> response;
114
115
116 /* == ElementAccess interface == */
117
119 performAccessTo (UICoord::Builder & target, size_t) override
120 {
121 UICoord const& location = target.uiCoord();
122
123 CHECK (existingPath >= location);
124 if (existingPath > location and !response)
125 {
126 if (location.leafLevel() == UIC_VIEW)
127 response.reset(new DummyView(location[UIC_VIEW]));
128 else
129 if (location.leafLevel() == UIC_TAB)
130 response.reset(new DummyTab(location[UIC_TAB]));
131 else
132 throw error::Invalid("Mock ElementAccess supports only creation of VIEW and TAB. Requested Target was "+string(location));
133 }
134
135 return response.get();
136 }
137
138
139 protected:
140 };
141
142
143
144
145}} // namespace stage::test
146#endif /*STAGE_TEST_ELEMENT_ACCESS_H*/
Inline string literal.
Definition symbol.hpp:78
size_t leafLevel() const
Typesafe union record.
Definition variant.hpp:216
Describe a location within the UI through structural/topological coordinates.
Definition ui-coord.hpp:131
Interface: access UI elements by navigating the UI topology.
virtual ~DummyWidget()
is an interface
DummyWidget(string name="DummyWidget")
Mock UI element or controller.
Definition mock-elm.hpp:101
Mock implementation of the model::ElementAccess interface for testing without actual UI.
RawResult performAccessTo(UICoord::Builder &target, size_t) override
std::unique_ptr< model::Tangible > response
...and if acceptable, we record the last answer here
UICoord existingPath
the next query will fail unless it presents this Path
Interface to discover and access raw UI elements in a cross cutting way.
Lumiera error handling (C++ interface).
A generic interface element instrumented for unit testing.
LumieraError< LERR_(INVALID)> Invalid
Definition error.hpp:211
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Test runner and basic definitions for tests.
Marker types to indicate a literal string and a Symbol.
A topological addressing scheme to designate structural locations within the UI.