Covellite++  Version: 2.3.1 Revision: ??? Platform: x64 Build: 21:47 08.04.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
OpenGLCommon_test.hpp
1
2#pragma once
3#include <Platform/Windows.mock.hpp>
4
5inline static ::std::vector<float> ARGBtoFloat4(const uint32_t _HexColor)
6{
7 return
8 {
9 ((_HexColor & 0x00FF0000) >> 16) / 255.0f,
10 ((_HexColor & 0x0000FF00) >> 8) / 255.0f,
11 ((_HexColor & 0x000000FF) >> 0) / 255.0f,
12 ((_HexColor & 0xFF000000) >> 24) / 255.0f,
13 };
14};
15
16namespace
17{
18
19// ************************************************************************** //
20TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_NoEqMatrix)
21{
22 // При определении некоторых макросов glm оператор == возвращает true для
23 // разных матриц, поэтому в тестовых проектах используется отдельный
24 // заголовочный файл, проверяем это:
25 EXPECT_FALSE(::glm::mat4{ 1.0f } == ::glm::mat4{ 2.0f });
26 EXPECT_TRUE(::glm::mat4{ 1.0f } != ::glm::mat4{ 2.0f });
27}
28
29// ************************************************************************** //
30TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Blend)
31{
32 using GLProxy_t = ::mock::GLProxy;
33 GLProxy_t GLProxy;
34 GLProxy_t::GetInstance() = &GLProxy;
35
36 const Tested_t Example{ Data_t{} };
37 const ITested_t & IExample = Example;
38
39 auto itCreator = IExample.GetCreators().find(uT("State"));
40 ASSERT_NE(IExample.GetCreators().end(), itCreator);
41
42 auto Render = itCreator->second(Component_t::Make(
43 {
44 { uT("kind"), uT("Blend") }
45 }));
46 ASSERT_NE(nullptr, Render);
47
48 using namespace ::testing;
49
50 InSequence Dummy;
51
52 EXPECT_CALL(GLProxy, Enable(GL_BLEND))
53 .Times(1);
54
55 EXPECT_CALL(GLProxy, BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA))
56 .Times(1);
57
58 Render();
59}
60
61// ************************************************************************** //
62TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Sampler_Texture)
63{
64 using GLProxy_t = ::mock::GLProxy;
65 GLProxy_t GLProxy;
66 GLProxy_t::GetInstance() = &GLProxy;
67
68 const Tested_t Example{ Data_t{} };
69 const ITested_t & IExample = Example;
70
71 auto itStateCreator = IExample.GetCreators().find(uT("State"));
72 ASSERT_NE(IExample.GetCreators().end(), itStateCreator);
73
74 auto itTextureCreator = IExample.GetCreators().find(uT("Texture"));
75 ASSERT_NE(IExample.GetCreators().end(), itTextureCreator);
76
77 auto SamplerRender = itStateCreator->second(Component_t::Make(
78 {
79 { uT("kind"), uT("Sampler") }
80 }));
81 ASSERT_NE(nullptr, SamplerRender);
82
83 auto TextureRender = itTextureCreator->second(Component_t::Make({ }));
84 ASSERT_NE(nullptr, TextureRender);
85
86 using namespace ::testing;
87
88 EXPECT_CALL(GLProxy, TexParameteri(_, _, _))
89 .Times(0);
90
91 SamplerRender();
92
93 InSequence Dummy;
94
95 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, _))
96 .Times(1);
97
98 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
99 GL_LINEAR))
100 .Times(1);
101
102 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
103 GL_LINEAR))
104 .Times(1);
105
106 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT))
107 .Times(1);
108
109 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT))
110 .Times(1);
111
112 TextureRender();
113}
114
115// ************************************************************************** //
116TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Sampler_TextureArray)
117{
118 using GLProxy_t = ::mock::GLProxy;
119 GLProxy_t GLProxy;
120 GLProxy_t::GetInstance() = &GLProxy;
121
122 const Tested_t Example{ Data_t{} };
123 const ITested_t & IExample = Example;
124
125 auto itStateCreator = IExample.GetCreators().find(uT("State"));
126 ASSERT_NE(IExample.GetCreators().end(), itStateCreator);
127
128 auto itTextureCreator = IExample.GetCreators().find(uT("TextureArray"));
129 ASSERT_NE(IExample.GetCreators().end(), itTextureCreator);
130
131 auto SamplerRender = itStateCreator->second(Component_t::Make(
132 {
133 { uT("kind"), uT("Sampler") }
134 }));
135 ASSERT_NE(nullptr, SamplerRender);
136
137 auto TextureRender = itTextureCreator->second(Component_t::Make({ }));
138 ASSERT_NE(nullptr, TextureRender);
139
140 using namespace ::testing;
141
142 EXPECT_CALL(GLProxy, TexParameteri(_, _, _))
143 .Times(0);
144
145 SamplerRender();
146
147 InSequence Dummy;
148
149 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, _))
150 .Times(1);
151
152 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER,
153 GL_LINEAR))
154 .Times(1);
155
156 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER,
157 GL_LINEAR))
158 .Times(1);
159
160 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT))
161 .Times(1);
162
163 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT))
164 .Times(1);
165
166 TextureRender();
167}
168
169// ************************************************************************** //
170TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Scissor_Enable)
171{
172 using GLProxy_t = ::mock::GLProxy;
173 GLProxy_t GLProxy;
174 GLProxy_t::GetInstance() = &GLProxy;
175
176 const Tested_t Example{ Data_t{} };
177 const ITested_t & IExample = Example;
178
179 const auto pScissorData = Component_t::Make(
180 {
181 { uT("kind"), uT("Rect") },
182 });
183
184 auto itCreatorState = IExample.GetCreators().find(uT("State"));
185 ASSERT_NE(IExample.GetCreators().end(), itCreatorState);
186
187 const auto pScissor = Component_t::Make(
188 {
189 { uT("kind"), uT("Scissor") },
190 { uT("enabled"), true },
191 { uT("service"), Object_t{ pScissorData } },
192 });
193
194 auto Render = itCreatorState->second(pScissor);
195 ASSERT_NE(nullptr, Render);
196
197 auto TestCallRender =
198 [&](int _X, int _Y, int _Width, int _Height, int _WindowHeight)
199 {
200 const int Yo = _WindowHeight - (_Y + _Height);
201
202 (*pScissorData)[uT("left")] = _X;
203 (*pScissorData)[uT("top")] = _Y;
204 (*pScissorData)[uT("right")] = _X + _Width;
205 (*pScissorData)[uT("bottom")] = _Y + _Height;
206
207 using namespace ::testing;
208
209 InSequence Dummy;
210
211 EXPECT_CALL(GLProxy, Enable(GL_SCISSOR_TEST))
212 .Times(1);
213
214 const int Viewport[4] = { 0, 0, 0, _WindowHeight };
215
216 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
217 .Times(1)
218 .WillOnce(Return(Viewport));
219
220 EXPECT_CALL(GLProxy, Scissor(_X, Yo, _Width, _Height))
221 .Times(1);
222
223 Render();
224 };
225
226 // Два вызова, чтобы убедиться, что изменение исходных данных приводит
227 // к изменению результата рендеринга.
228 TestCallRender(1509, 1510, 1511, 1512, 1513);
229 TestCallRender(1514, 1515, 1516, 1517, 1518);
230}
231
232// ************************************************************************** //
233TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Scissor_Disable)
234{
235 using GLProxy_t = ::mock::GLProxy;
236 GLProxy_t GLProxy;
237 GLProxy_t::GetInstance() = &GLProxy;
238
239 const Tested_t Example{ Data_t{} };
240 const ITested_t & IExample = Example;
241
242 auto itCreator = IExample.GetCreators().find(uT("State"));
243 ASSERT_NE(IExample.GetCreators().end(), itCreator);
244
245 const auto pComponent = Component_t::Make(
246 {
247 { uT("kind"), uT("Scissor") },
248 { uT("enabled"), false },
249 });
250
251 auto Render = itCreator->second(pComponent);
252 ASSERT_NE(nullptr, Render);
253
254 using namespace ::testing;
255
256 EXPECT_CALL(GLProxy, Disable(GL_SCISSOR_TEST))
257 .Times(1);
258
259 Render();
260}
261
262// ************************************************************************** //
263TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Depth_Disabled)
264{
265 using GLProxy_t = ::mock::GLProxy;
266 GLProxy_t GLProxy;
267 GLProxy_t::GetInstance() = &GLProxy;
268
269 const Tested_t Example{ Data_t{} };
270 const ITested_t & IExample = Example;
271
272 auto itCreator = IExample.GetCreators().find(uT("State"));
273 ASSERT_NE(IExample.GetCreators().end(), itCreator);
274
275 using namespace ::testing;
276
277 const auto TestCallRender = [&](const Component_t::ComponentPtr_t & _pState)
278 {
279 auto Render = itCreator->second(_pState);
280 ASSERT_NE(nullptr, Render);
281
282 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
283 .Times(1);
284
285 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
286 .Times(0);
287
288 EXPECT_CALL(GLProxy, DepthFunc(_))
289 .Times(0);
290
291 EXPECT_CALL(GLProxy, ClearDepth(_))
292 .Times(0);
293
294 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
295 .Times(0);
296
297 Render();
298 };
299
300 TestCallRender(Component_t::Make(
301 {
302 { uT("kind"), uT("Depth") },
303 }));
304
305 TestCallRender(Component_t::Make(
306 {
307 { uT("kind"), uT("Depth") },
308 { uT("enabled"), false },
309 }));
310}
311
312// ************************************************************************** //
313TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Depth_Enable_NoClear_Overwrite)
314{
315 using GLProxy_t = ::mock::GLProxy;
316 GLProxy_t GLProxy;
317 GLProxy_t::GetInstance() = &GLProxy;
318
319 const Tested_t Example{ Data_t{} };
320 const ITested_t & IExample = Example;
321
322 auto itCreator = IExample.GetCreators().find(uT("State"));
323 ASSERT_NE(IExample.GetCreators().end(), itCreator);
324
325 using namespace ::testing;
326
327 const auto Render = itCreator->second(Component_t::Make(
328 {
329 { uT("kind"), uT("Depth") },
330 { uT("enabled"), true },
331 { uT("clear"), false },
332 }));
333 ASSERT_NE(nullptr, Render);
334
335 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
336 .Times(0);
337
338 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
339 .Times(1);
340
341 EXPECT_CALL(GLProxy, DepthMask(GL_TRUE))
342 .Times(1);
343
344 EXPECT_CALL(GLProxy, DepthFunc(GL_GREATER))
345 .Times(1);
346
347 EXPECT_CALL(GLProxy, ClearDepth(_))
348 .Times(0);
349
350 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
351 .Times(0);
352
353 Render();
354}
355
356// ************************************************************************** //
357TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Depth_Enable_Clear_Overwrite)
358{
359 using GLProxy_t = ::mock::GLProxy;
360 GLProxy_t GLProxy;
361 GLProxy_t::GetInstance() = &GLProxy;
362
363 const Tested_t Example{ Data_t{} };
364 const ITested_t & IExample = Example;
365
366 auto itCreator = IExample.GetCreators().find(uT("State"));
367 ASSERT_NE(IExample.GetCreators().end(), itCreator);
368
369 using namespace ::testing;
370
371 const auto Render = itCreator->second(Component_t::Make(
372 {
373 { uT("kind"), uT("Depth") },
374 { uT("enabled"), true },
375 { uT("clear"), true },
376 }));
377 ASSERT_NE(nullptr, Render);
378
379 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
380 .Times(0);
381
382 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
383 .Times(1);
384
385 EXPECT_CALL(GLProxy, DepthMask(GL_TRUE))
386 .Times(1);
387
388 EXPECT_CALL(GLProxy, DepthFunc(GL_GREATER))
389 .Times(1);
390
391 EXPECT_CALL(GLProxy, ClearDepth(0.0f))
392 .Times(1);
393
394 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
395 .Times(1);
396
397 Render();
398}
399
400// ************************************************************************** //
401TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Depth_Enable_NoClear_NoOverwrite)
402{
403 using GLProxy_t = ::mock::GLProxy;
404 GLProxy_t GLProxy;
405 GLProxy_t::GetInstance() = &GLProxy;
406
407 const Tested_t Example{ Data_t{} };
408 const ITested_t & IExample = Example;
409
410 auto itCreator = IExample.GetCreators().find(uT("State"));
411 ASSERT_NE(IExample.GetCreators().end(), itCreator);
412
413 using namespace ::testing;
414
415 const auto Render = itCreator->second(Component_t::Make(
416 {
417 { uT("kind"), uT("Depth") },
418 { uT("enabled"), true },
419 { uT("clear"), false },
420 { uT("overwrite"), false },
421 }));
422 ASSERT_NE(nullptr, Render);
423
424 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
425 .Times(0);
426
427 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
428 .Times(1);
429
430 EXPECT_CALL(GLProxy, DepthMask(GL_FALSE))
431 .Times(1);
432
433 EXPECT_CALL(GLProxy, DepthFunc(GL_GREATER))
434 .Times(1);
435
436 EXPECT_CALL(GLProxy, ClearDepth(_))
437 .Times(0);
438
439 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
440 .Times(0);
441
442 Render();
443}
444
445// ************************************************************************** //
446TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Depth_Enable_Clear_NoOverwrite)
447{
448 using GLProxy_t = ::mock::GLProxy;
449 GLProxy_t GLProxy;
450 GLProxy_t::GetInstance() = &GLProxy;
451
452 const Tested_t Example{ Data_t{} };
453 const ITested_t & IExample = Example;
454
455 auto itCreator = IExample.GetCreators().find(uT("State"));
456 ASSERT_NE(IExample.GetCreators().end(), itCreator);
457
458 using namespace ::testing;
459
460 const auto Render = itCreator->second(Component_t::Make(
461 {
462 { uT("kind"), uT("Depth") },
463 { uT("enabled"), true },
464 { uT("clear"), true },
465 { uT("overwrite"), false },
466 }));
467 ASSERT_NE(nullptr, Render);
468
469 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
470 .Times(0);
471
472 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
473 .Times(1);
474
475 EXPECT_CALL(GLProxy, DepthMask(GL_FALSE))
476 .Times(1);
477
478 EXPECT_CALL(GLProxy, DepthFunc(GL_GREATER))
479 .Times(1);
480
481 EXPECT_CALL(GLProxy, ClearDepth(0.0f))
482 .Times(1);
483
484 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
485 .Times(1);
486
487 Render();
488}
489
490// ************************************************************************** //
491TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_State_Clear)
492{
493 using Color_t = ::std::vector<float>;
494
495 using GLProxy_t = ::mock::GLProxy;
496 GLProxy_t GLProxy;
497 GLProxy_t::GetInstance() = &GLProxy;
498
499 Tested_t Example{ Data_t{ } };
500 ITested_t & IExample = Example;
501
502 auto itCreator = IExample.GetCreators().find(uT("State"));
503 ASSERT_NE(IExample.GetCreators().end(), itCreator);
504
505 const auto TestCallRender = [&](
506 const Component_t::ComponentPtr_t & _pState,
507 const Color_t & _ExpectedColor)
508 {
509 const auto Render = itCreator->second(_pState);
510 ASSERT_NE(nullptr, Render);
511
512 using namespace ::testing;
513
514 InSequence Dummy;
515
516 ASSERT_EQ(4, _ExpectedColor.size());
517
518 EXPECT_CALL(GLProxy, ClearColor(_ExpectedColor[0], _ExpectedColor[1],
519 _ExpectedColor[2], _ExpectedColor[3]))
520 .Times(1);
521
522 EXPECT_CALL(GLProxy, Clear(GL_COLOR_BUFFER_BIT))
523 .Times(1);
524
525 Render();
526 };
527
528 {
529 const ::std::vector<FLOAT> DefaultColor =
530 {
531 0.0f,
532 0.0f,
533 0.0f,
534 1.0f,
535 };
536
537 TestCallRender(Component_t::Make(
538 {
539 { uT("kind"), uT("Clear") },
540 }), DefaultColor);
541 }
542
543 {
544 const ::std::vector<FLOAT> Color =
545 {
546 0.86274509803921568627450980392157f, // DC
547 0.72941176470588235294117647058824f, // BA
548 0.5960784313725490196078431372549f, // 98
549 0.9960784313725490196078431372549f, // FE
550 };
551
552 TestCallRender(Component_t::Make(
553 {
554 { uT("kind"), uT("Clear") },
555 { uT("color"), 0xFEDCBA98 },
556 }), Color);
557 }
558}
559
560// ************************************************************************** //
561TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_Texture_glTexImage2D_Fail)
562{
563 using GLProxy_t = ::mock::GLProxy;
564 GLProxy_t GLProxy;
565 GLProxy_t::GetInstance() = &GLProxy;
566
567 const ::mock::GLuint TextureId = 1612182301;
568
569 const Tested_t Example{ Data_t{} };
570 const ITested_t & IExample = Example;
571
572 auto itCreator = IExample.GetCreators().find(uT("Texture"));
573 ASSERT_NE(IExample.GetCreators().end(), itCreator);
574
575 using namespace ::testing;
576
577 InSequence Dummy;
578
579 EXPECT_CALL(GLProxy, GenTextures(1))
580 .Times(1)
581 .WillOnce(Return(TextureId));
582
583 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
584 .Times(1);
585
586 EXPECT_CALL(GLProxy, TexImage2D(_, _, _, _, _, _, _, _, _))
587 .Times(1);
588
589 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
590 .Times(1);
591
592 EXPECT_CALL(GLProxy, GetError())
593 .Times(1)
594 .WillOnce(Return(1808261916));
595
596 EXPECT_THROW(itCreator->second(Component_t::Make({})), ::std::exception);
597}
598
599// ************************************************************************** //
600TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_Texture_UnknownDestination)
601{
602 using GLProxy_t = ::mock::GLProxy;
603 GLProxy_t GLProxy;
604 GLProxy_t::GetInstance() = &GLProxy;
605
606 const Tested_t Example{ Data_t{} };
607 const ITested_t & IExample = Example;
608
609 auto itCreator = IExample.GetCreators().find(uT("Texture"));
610 ASSERT_NE(IExample.GetCreators().end(), itCreator);
611
612 const auto TestCall = [&](const Component_t::ComponentPtr_t & _pTexture)
613 {
614 const ::mock::GLuint TextureId = 1812181809;
615
616 using namespace ::testing;
617
618 InSequence Dummy;
619
620 EXPECT_CALL(GLProxy, GenTextures(_))
621 .Times(0);
622
623 EXPECT_CALL(GLProxy, BindTexture(_, _))
624 .Times(0);
625
626 EXPECT_CALL(GLProxy, TexImage2D(_, _, _, _, _, _, _, _, _))
627 .Times(0);
628
629 EXPECT_CALL(GLProxy, GetError())
630 .Times(0);
631
632 EXPECT_THROW(itCreator->second(_pTexture), ::std::exception);
633 };
634
635 {
636 const auto pTexture = Component_t::Make(
637 {
638 { uT("destination"), uT("1907251102") },
639 });
640
641 TestCall(pTexture);
642 }
643
644 {
645 const auto pData = Component_t::Make(
646 {
647 { uT("kind"), uT("Texture") },
648 { uT("destination"), uT("1907251103") },
649 });
650
651 TestCall(Component_t::Make({ { uT("service"), Object_t{ pData } } }));
652 }
653}
654
655// ************************************************************************** //
656TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_TextureArray_Create_Fail)
657{
658 using GLProxy_t = ::mock::GLProxy;
659 GLProxy_t GLProxy;
660 GLProxy_t::GetInstance() = &GLProxy;
661
662 const ::mock::GLuint TextureId = 2504062041;
663
664 const Tested_t Example{ Data_t{} };
665 const ITested_t & IExample = Example;
666
667 auto itCreator = IExample.GetCreators().find(uT("TextureArray"));
668 ASSERT_NE(IExample.GetCreators().end(), itCreator);
669
670 using namespace ::testing;
671
672 InSequence Dummy;
673
674 EXPECT_CALL(GLProxy, GenTextures(1))
675 .Times(1)
676 .WillOnce(Return(TextureId));
677
678 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
679 .Times(1);
680
681 EXPECT_CALL(GLProxy, TexStorage3D(_, _, _, _, _, _))
682 .Times(1);
683
684 EXPECT_CALL(GLProxy, TexSubImage3D_1(_, _, _, _, _, _, _))
685 .Times(1);
686
687 EXPECT_CALL(GLProxy, TexSubImage3D_2(_, _, _, _))
688 .Times(1);
689
690 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
691 .Times(1);
692
693 EXPECT_CALL(GLProxy, GetError())
694 .Times(1)
695 .WillOnce(Return(2504062042));
696
697 EXPECT_THROW(itCreator->second(Component_t::Make({})), ::std::exception);
698}
699
700// ************************************************************************** //
701TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_TextureArray_UnknownDestination)
702{
703 using GLProxy_t = ::mock::GLProxy;
704 GLProxy_t GLProxy;
705 GLProxy_t::GetInstance() = &GLProxy;
706
707 const Tested_t Example{ Data_t{} };
708 const ITested_t & IExample = Example;
709
710 auto itCreator = IExample.GetCreators().find(uT("TextureArray"));
711 ASSERT_NE(IExample.GetCreators().end(), itCreator);
712
713 const auto TestCall = [&](const Component_t::ComponentPtr_t & _pTexture)
714 {
715 const ::mock::GLuint TextureId = 2504062208;
716
717 using namespace ::testing;
718
719 InSequence Dummy;
720
721 EXPECT_CALL(GLProxy, GenTextures(_))
722 .Times(0);
723
724 EXPECT_CALL(GLProxy, BindTexture(_, _))
725 .Times(0);
726
727 EXPECT_CALL(GLProxy, TexStorage3D(_, _, _, _, _, _))
728 .Times(0);
729
730 EXPECT_CALL(GLProxy, TexSubImage3D_1(_, _, _, _, _, _, _))
731 .Times(0);
732
733 EXPECT_CALL(GLProxy, TexSubImage3D_2(_, _, _, _))
734 .Times(0);
735
736 EXPECT_CALL(GLProxy, GetError())
737 .Times(0);
738
739 EXPECT_THROW(itCreator->second(_pTexture), ::std::exception);
740 };
741
742 {
743 const auto pTexture = Component_t::Make(
744 {
745 { uT("destination"), uT("2504062206") },
746 });
747
748 TestCall(pTexture);
749 }
750
751 {
752 const auto pData = Component_t::Make(
753 {
754 { uT("kind"), uT("TextureArray") },
755 { uT("destination"), uT("2504062207") },
756 });
757
758 TestCall(Component_t::Make({ { uT("service"), Object_t{ pData } } }));
759 }
760}
761
762// ************************************************************************** //
763TEST_F(OpenGLCommon_test, /*DISABLED_*/Test_Buffer_UnknownType)
764{
765 const ::std::vector<float> Source = { 0.0f };
766
767 const Tested_t Example{ Data_t{} };
768 const ITested_t & IExample = Example;
769
770 auto itCreator = IExample.GetCreators().find(uT("Buffer"));
771 ASSERT_NE(IExample.GetCreators().end(), itCreator);
772
773 // ***************** Передача данных в объекте компонента ***************** //
774
775 {
776 const auto pBuffer = Component_t::Make(
777 {
778 { uT("id"), uT("id.1905081956") },
779 { uT("type"), uT("type.1905081956") },
780 { uT("kind"), uT("kind.1905081956") },
781 { uT("content"), Source },
782 });
783
784 EXPECT_STDEXCEPTION(itCreator->second(pBuffer),
785 ".+\\.cpp\\([0-9]+\\): Unexpected buffer format \\["
786 "id: id.1905081956, "
787 "type: type.1905081956, "
788 "kind: kind.1905081956\\]\\.");
789 }
790
791 // ************** Передача данных в объекте компонента Data *************** //
792
793 {
794 const auto pData = Component_t::Make(
795 {
796 { uT("kind"), uT("Buffer") },
797 { uT("content"), Source },
798 });
799
800 const auto pBuffer = Component_t::Make(
801 {
802 { uT("id"), uT("id.1905082000") },
803 { uT("type"), uT("type.1905082000") },
804 { uT("kind"), uT("kind.1905082000") },
805 { uT("service"), Object_t{ pData } }
806 });
807
808 EXPECT_STDEXCEPTION(itCreator->second(pBuffer),
809 ".+\\.cpp\\([0-9]+\\): Unexpected buffer format \\["
810 "id: id.1905082000, "
811 "type: type.1905082000, "
812 "kind: kind.1905082000\\]\\.");
813 }
814}
815
816} // unnamed namespace