-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrender_graph_tests.cpp
More file actions
121 lines (94 loc) · 4.14 KB
/
Copy pathrender_graph_tests.cpp
File metadata and controls
121 lines (94 loc) · 4.14 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
////////////////////////////////////////////////////////////////////////////////
// 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 <functional>
#include <gtest/gtest.h>
#include "fakes/fake_texture.h"
#include "graphics/render_graph/component_node.h"
#include "graphics/render_graph/render_graph.h"
#include "graphics/render_graph/texture_node.h"
#include "graphics/render_graph/value_node.h"
#include "graphics/render_pipeline.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"
class RenderGraphTest : public ::testing::Test
{
public:
RenderGraphTest()
: resource_manager_()
, material_manager_()
, mesh_manager_(resource_manager_)
, render_target_manager_()
, pipeline_(material_manager_, mesh_manager_, render_target_manager_, 600u, 600u)
{
}
iris::RenderGraph *create_render_graph()
{
return pipeline_.create_render_graph();
}
private:
MockResourceManager resource_manager_;
MockMaterialManager material_manager_;
MockMeshManager mesh_manager_;
MockRenderTargetManager render_target_manager_;
iris::RenderPipeline pipeline_;
};
TEST_F(RenderGraphTest, empty_graph_hash_the_same)
{
const auto *rg1 = create_render_graph();
const auto *rg2 = create_render_graph();
ASSERT_EQ(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}
TEST_F(RenderGraphTest, simple_value_node_hash_the_same)
{
auto *rg1 = create_render_graph();
rg1->render_node()->set_colour_input(rg1->create<iris::ValueNode<float>>(1.2f));
auto *rg2 = create_render_graph();
rg2->render_node()->set_colour_input(rg2->create<iris::ValueNode<float>>(1.2f));
ASSERT_EQ(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}
TEST_F(RenderGraphTest, simple_value_node_hash_different)
{
auto *rg1 = create_render_graph();
rg1->render_node()->set_colour_input(rg1->create<iris::ValueNode<float>>(1.2f));
auto *rg2 = create_render_graph();
rg2->render_node()->set_colour_input(rg2->create<iris::ValueNode<float>>(1.3f));
ASSERT_NE(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}
TEST_F(RenderGraphTest, texture_node_single_texture_hash_the_same)
{
FakeTexture texture{};
auto *rg1 = create_render_graph();
rg1->render_node()->set_colour_input(rg1->create<iris::TextureNode>(&texture));
auto *rg2 = create_render_graph();
rg2->render_node()->set_colour_input(rg2->create<iris::TextureNode>(&texture));
ASSERT_EQ(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}
TEST_F(RenderGraphTest, texture_node_multiple_texture_hash_different)
{
FakeTexture texture1{};
FakeTexture texture2{};
auto *rg1 = create_render_graph();
rg1->render_node()->set_colour_input(rg1->create<iris::TextureNode>(&texture1));
auto *rg2 = create_render_graph();
rg2->render_node()->set_colour_input(rg2->create<iris::TextureNode>(&texture2));
ASSERT_NE(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}
TEST_F(RenderGraphTest, complex_graph_hash_the_same)
{
FakeTexture texture1{};
FakeTexture texture2{};
auto *rg1 = create_render_graph();
rg1->render_node()->set_colour_input(rg1->create<iris::TextureNode>(&texture1));
rg1->render_node()->set_specular_amount_input(
rg1->create<iris::ComponentNode>(rg1->create<iris::TextureNode>(&texture2), "r"));
auto *rg2 = create_render_graph();
rg2->render_node()->set_colour_input(rg1->create<iris::TextureNode>(&texture1));
rg2->render_node()->set_specular_amount_input(
rg2->create<iris::ComponentNode>(rg2->create<iris::TextureNode>(&texture2), "r"));
ASSERT_EQ(std::hash<iris::RenderGraph *>{}(rg1), std::hash<iris::RenderGraph *>{}(rg2));
}