Covellite++  Version: 2.3.0 Revision: ??? Platform: x64 Build: 23:13 04.01.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
Layer.mock.hpp
1
2#pragma once
3#include <alicorn/std/string.forward.hpp>
4#include <Covellite/Gui/IWindow.hpp>
5#include <Covellite/Gui/ILayer.hpp>
6
7/*
8An example of use:
9
10using ExampleProxy_t = ::mock::covellite::gui::Layer::Proxy;
11ExampleProxy_t ExampleProxy;
12ExampleProxy_t::GetInstance() = &ExampleProxy;
13
14const ::mock::Id_t ExampleId = 1607301544;
15
16using namespace ::testing;
17
18InSequence Dummy;
19
20EXPECT_CALL(ExampleProxy, Constructor(Value1))
21 .Times(1)
22 .WillOnce(Return(ExampleId));
23
24::mock::covellite::gui::Layer Example(Value1);
25
26EXPECT_CALL(ExampleProxy, Function(ExampleId, Value2))
27 .Times(1)
28 .WillOnce(Return(Value3));
29
30const auto Result = Example.Function(Value2);
31EXPECT_EQ(Value3, Result);
32*/
33
34namespace mock
35{
36
37namespace covellite
38{
39
40namespace gui
41{
42
43class Layer :
45{
46 using DocumentId_t = ::std::string;
47 using ElementId_t = ::std::string;
48 using IWindow_t = ::covellite::gui::IWindow;
49
50protected:
51 using String_t = ::alicorn::extension::std::String;
52 using Path_t = ::boost::filesystem::path;
53
54public:
55 class Proxy :
56 public ::alicorn::extension::testing::Proxy<Proxy>
57 {
58 public:
59 MOCK_METHOD2(Constructor, Id_t(IWindow_t *, Path_t));
60 MOCK_METHOD3(Constructor, Id_t(IWindow_t *, Path_t, ::std::string));
61 MOCK_METHOD1(Constructor, Id_t(Id_t));
62 MOCK_METHOD1(SetFocus, void(Id_t));
63 MOCK_METHOD2(SetMeaning, void(Id_t, String_t));
64 MOCK_METHOD1(GetMeaning, String_t(Id_t));
65 MOCK_METHOD2(SetClassStyle, void(Id_t, String_t));
66 MOCK_METHOD2(Subscribe, void(Id_t, Id_t));
67 MOCK_METHOD1(Show, void(Id_t));
68 MOCK_METHOD1(Hide, void(Id_t));
69 MOCK_METHOD1(GetId, DocumentId_t(Id_t));
70 MOCK_METHOD2(GetElement, Id_t(Id_t, ElementId_t));
71 MOCK_METHOD1(GetWidth, int(Id_t));
72 MOCK_METHOD1(GetHeight, int(Id_t));
73 MOCK_METHOD2(EmployFontSize, float (Id_t, float));
74 };
75
76public:
77 const Id_t m_Id = 0;
78 Layer & operator= (const Layer &) = delete;
79 bool operator== (const Layer & _Value) const { return (m_Id == _Value.m_Id); }
80
81public:
82 class Element
83 {
84 public:
85 void SetFocus(void)
86 {
87 Proxy::GetInstance()->SetFocus(m_Id);
88 }
89
90 void SetMeaning(const String_t & _Value)
91 {
92 Proxy::GetInstance()->SetMeaning(m_Id, _Value);
93 }
94
95 String_t GetMeaning(void) const
96 {
97 return Proxy::GetInstance()->GetMeaning(m_Id);
98 }
99
100 void SetClassStyle(const String_t & _Value)
101 {
102 Proxy::GetInstance()->SetClassStyle(m_Id, _Value);
103 }
104
105 public:
106 const Id_t m_Id = 0;
107
108 public:
109 // cppcheck-suppress noExplicitConstructor
110 Element(Id_t _Id) : m_Id(_Id) {}
111 };
112
113public:
114 void Show(void)
115 {
116 Proxy::GetInstance()->Show(m_Id);
117 }
118
119 void Hide(void)
120 {
121 Proxy::GetInstance()->Hide(m_Id);
122 }
123
124 DocumentId_t GetId(void) const
125 {
126 return Proxy::GetInstance()->GetId(m_Id);
127 }
128
129 Element GetElement(const ElementId_t & _Id) const
130 {
131 return Proxy::GetInstance()->GetElement(m_Id, _Id);
132 }
133
134 int GetWidth(void) const
135 {
136 return Proxy::GetInstance()->GetWidth(m_Id);
137 }
138
139 int GetHeight(void) const
140 {
141 return Proxy::GetInstance()->GetHeight(m_Id);
142 }
143
144 float EmployFontSize(float _Value)
145 {
146 return Proxy::GetInstance()->EmployFontSize(m_Id, _Value);
147 }
148
149 public:
150 Layer(IWindow_t & _Param1, const Path_t & _Param2) :
151 m_Id(Proxy::GetInstance()->Constructor(&_Param1, _Param2))
152 {
153
154 }
155
156 Layer(IWindow_t & _Param1, const Path_t & _Param2, const ::std::string & _Param3) :
157 m_Id(Proxy::GetInstance()->Constructor(&_Param1, _Param2, _Param3))
158 {
159
160 }
161
162 explicit Layer(::mock::Id_t _Param1) :
163 m_Id(Proxy::GetInstance()->Constructor(_Param1))
164 {
165
166 }
167};
168
169} // namespace gui
170
171} // namespace covellite
172
173} // namespace mock
Класс входит в проект Covellite.Gui Интерфейсный класс слоя (текущего отображаемого экрана).
Definition ILayer.hpp:26
Класс входит в проект Covellite.Gui Интерфесный класс окна, отображающего элементы GUI.
Definition IWindow.hpp:31