-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrender_command_tests.cpp
More file actions
133 lines (105 loc) · 3.96 KB
/
Copy pathrender_command_tests.cpp
File metadata and controls
133 lines (105 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "core/vector3.h"
#include "graphics/mesh_loader.h"
#include "graphics/render_command.h"
#include "graphics/render_command_type.h"
#include "graphics/render_pass.h"
#include "graphics/render_pipeline.h"
#include "graphics/scene.h"
#include "graphics/single_entity.h"
#include "fakes/fake_light.h"
#include "fakes/fake_material.h"
#include "fakes/fake_mesh.h"
#include "fakes/fake_render_target.h"
#include "mocks/mock_material_manager.h"
#include "mocks/mock_mesh_manager.h"
#include "mocks/mock_render_target_manager.h"
#include "mocks/mock_resource_manager.h"
TEST(render_command_tests, default_ctor)
{
iris::RenderCommand cmd{};
ASSERT_EQ(cmd.type(), iris::RenderCommandType::PASS_START);
ASSERT_EQ(cmd.render_pass(), nullptr);
ASSERT_EQ(cmd.material(), nullptr);
ASSERT_EQ(cmd.render_entity(), nullptr);
ASSERT_EQ(cmd.shadow_map(), nullptr);
ASSERT_EQ(cmd.light(), nullptr);
}
TEST(render_command_tests, ctor)
{
MockResourceManager resource_manager{};
MockMaterialManager material_manager{};
MockMeshManager mesh_manager{resource_manager};
MockRenderTargetManager render_target_manager{};
iris::RenderPipeline pipeline{material_manager, mesh_manager, render_target_manager, 600u, 600u};
FakeMesh mesh{};
const auto type = iris::RenderCommandType::DRAW;
const FakeMaterial material{};
const iris::SingleEntity render_entity{&mesh, iris::Vector3{}};
const FakeRenderTarget shadow_map{};
const FakeLight light{};
auto *scene = pipeline.create_scene();
const auto *render_pass = pipeline.create_render_pass(scene);
const iris::RenderCommand cmd{type, render_pass, &material, &render_entity, &shadow_map, &light};
ASSERT_EQ(cmd.type(), type);
ASSERT_EQ(cmd.render_pass(), render_pass);
ASSERT_EQ(cmd.material(), &material);
ASSERT_EQ(cmd.render_entity(), &render_entity);
ASSERT_EQ(cmd.shadow_map(), &shadow_map);
ASSERT_EQ(cmd.light(), &light);
}
TEST(render_command_tests, get_set_type)
{
iris::RenderCommand cmd{};
const auto new_value = iris::RenderCommandType::DRAW;
cmd.set_type(new_value);
ASSERT_EQ(cmd.type(), new_value);
}
TEST(render_command_tests, get_set_render_pass)
{
MockResourceManager resource_manager{};
MockMaterialManager material_manager{};
MockMeshManager mesh_manager{resource_manager};
MockRenderTargetManager render_target_manager{};
iris::RenderPipeline pipeline{material_manager, mesh_manager, render_target_manager, 600u, 600u};
auto *scene = pipeline.create_scene();
const auto *render_pass = pipeline.create_render_pass(scene);
iris::RenderCommand cmd{};
cmd.set_render_pass(render_pass);
ASSERT_EQ(cmd.render_pass(), render_pass);
}
TEST(render_command_tests, get_set_material)
{
iris::RenderCommand cmd{};
const FakeMaterial new_value{};
cmd.set_material(&new_value);
ASSERT_EQ(cmd.material(), &new_value);
}
TEST(render_command_tests, get_set_render_entity)
{
FakeMesh mesh{};
iris::RenderCommand cmd{};
const iris::SingleEntity new_value{&mesh, iris::Vector3{}};
cmd.set_render_entity(&new_value);
ASSERT_EQ(cmd.render_entity(), &new_value);
}
TEST(render_command_tests, get_set_shadow_map)
{
iris::RenderCommand cmd{};
const FakeRenderTarget new_value{};
cmd.set_shadow_map(&new_value);
ASSERT_EQ(cmd.shadow_map(), &new_value);
}
TEST(render_command_tests, get_set_light)
{
iris::RenderCommand cmd{};
const FakeLight new_value{};
cmd.set_light(&new_value);
ASSERT_EQ(cmd.light(), &new_value);
}