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)
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"
20 #include "lib/test/test-helper.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;
40 using util::isSameObject;
41 //using util::isnil;
42 
43 
44 namespace stage {
45 namespace model{
46 namespace test {
47 
48 // using lumiera::error::LUMIERA_ERROR_WRONG_TYPE;
49 // using lib::test::showSizeof;
50  using interact::UICoord;
55 
56  using MockAccess = lib::DependInject<ElementAccess>::Local<TestElementAccess>;
57  using AccessAPI = lib::Depend<ElementAccess>;
58 
59 
60 
61  /******************************************************************************/
78  class ElementAccess_test : public Test
79  {
80 
81  virtual void
82  run (Arg)
83  {
86  verify_limitedCreate();
87  verify_createNewPath();
88  }
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
136  verify_limitedCreate()
137  {
138  UNIMPLEMENTED ("limit creation of new sibling objects");
139  }
140 
141 
142  void
143  verify_createNewPath()
144  {
145  UNIMPLEMENTED ("create a new path from scratch");
146  }
147  };
148 
149 
151  LAUNCHER (ElementAccess_test, "unit stage");
152 
153 
154 }}} // namespace stage::model::test
Describe a location within the UI through structural/topological coordinates.
Definition: ui-coord.hpp:129
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:40
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Definition: util.hpp:514
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:280
Simplistic test class runner.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
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, based directly on the referee&#39;s memory identities. ...
Definition: util.hpp:421