Lumiera  0.pre.03
»edit your freedom«
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) Lumiera.org
5  2018, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
28 #include "lib/test/run.hpp"
29 #include "lib/test/test-helper.hpp"
30 //#include "stage/interact/view-spec-dsl.hpp"
33 //#include "gen-node-location-query.hpp"
34 #include "lib/depend-inject.hpp"
35 #include "lib/format-cout.hpp"
36 //#include "lib/idi/entry-id.hpp"
37 //#include "lib/diff/gen-node.hpp"
38 #include "lib/util.hpp"
39 
40 //#include <string>
41 //#include <vector>
42 
43 
44 //using std::string;
45 //using lib::diff::MakeRec;
46 //using lib::diff::Rec;
47 //using lib::idi::EntryID;
48 //using lib::diff::GenNode;
49 using util::isSameObject;
50 //using util::isnil;
51 
52 
53 namespace stage {
54 namespace model{
55 namespace test {
56 
57 // using lumiera::error::LUMIERA_ERROR_WRONG_TYPE;
58 // using lib::test::showSizeof;
59  using interact::UICoord;
64 
65  using MockAccess = lib::DependInject<ElementAccess>::Local<TestElementAccess>;
66  using AccessAPI = lib::Depend<ElementAccess>;
67 
68 
69 
70  /******************************************************************************/
87  class ElementAccess_test : public Test
88  {
89 
90  virtual void
91  run (Arg)
92  {
95  verify_limitedCreate();
96  verify_createNewPath();
97  }
98 
99 
101  void
103  {
104  MockAccess fakeDirectory;
105 
106  auto location = UICoord{"win-1","persp-A","thePanel","someView","tab#5"};
107 
108  fakeDirectory.triggerCreate();
109  fakeDirectory->existingPath = location;
110  fakeDirectory->response.reset (new DummyTab);
111 
112  AccessAPI accessAPI;
113  auto answer = accessAPI().access<DummyWidget> (location);
114 
115  CHECK (answer.isValid());
116  DummyWidget& widget = answer;
117  CHECK (INSTANCEOF (DummyTab, &widget));
118  CHECK (isSameObject (widget, *fakeDirectory->response));
119  }
120 
121 
125  void
127  {
128  MockAccess fakeDirectory;
129 
130  auto path = UICoord{"win-1","persp-A","thePanel"};
131  auto location = UICoord{"win-1","persp-A","thePanel","someView"};
132 
133  fakeDirectory.triggerCreate();
134  fakeDirectory->existingPath = path;
135  CHECK (not fakeDirectory->response);
136 
137  AccessAPI accessAPI;
138  DummyView& view = accessAPI().access<DummyView> (location);
139  CHECK ( fakeDirectory->response); // has been created
140  CHECK (isSameObject (view, *fakeDirectory->response));
141  }
142 
143 
144  void
145  verify_limitedCreate()
146  {
147  UNIMPLEMENTED ("limit creation of new sibling objects");
148  }
149 
150 
151  void
152  verify_createNewPath()
153  {
154  UNIMPLEMENTED ("create a new path from scratch");
155  }
156  };
157 
158 
160  LAUNCHER (ElementAccess_test, "unit stage");
161 
162 
163 }}} // namespace stage::model::test
Describe a location within the UI through structural/topological coordinates.
Definition: ui-coord.hpp:138
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:49
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Definition: util.hpp:492
Per type specific configuration of instances created as service dependencies.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Simple test class runner.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A topological addressing scheme to designate structural locations within the UI.
Mock implementation of the model::ElementAccess interface for testing without actual UI...
A collection of frequently used helper functions to support unit testing.
MOC & triggerCreate()
trigger lazy service object instantiation
Unit test helper for access to UI elements without actually running an UI.
Configuration handle for temporarily shadowing a dependency by a test mock instance.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.
Definition: util.hpp:372