|
|
@@ -5,12 +5,12 @@
|
|
|
// Created by Sam Jaffe on 6/6/19.
|
|
|
// Copyright © 2019 Sam Jaffe. All rights reserved.
|
|
|
//
|
|
|
+#include "game/graphics/manager.hpp"
|
|
|
|
|
|
-#include <gmock/gmock.h>
|
|
|
+#include <testing/xcode_gtest_helper.h>
|
|
|
|
|
|
#include "../src/helper.hpp"
|
|
|
#include "game/graphics/exception.h"
|
|
|
-#include "game/graphics/manager.hpp"
|
|
|
#include "game/graphics/material.hpp"
|
|
|
#include "game/graphics/shader.hpp"
|
|
|
#include "game/graphics/shader_program.hpp"
|
|
|
@@ -112,39 +112,39 @@ TEST_F(TextureTest, ThrowsOnNonExistantFile) {
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, NoExceptIfFileExists) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(1);
|
|
|
EXPECT_NO_THROW(mock.get("resources/black.bmp"));
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, CreatedTextureCanBeRefetched) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(1);
|
|
|
auto id_1 = mock.get("resources/black.bmp");
|
|
|
auto id_2 = mock.get("resources/black.bmp");
|
|
|
EXPECT_THAT(id_1, Eq(id_2));
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, CanGetTextureFromId) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(1);
|
|
|
auto texture_id = mock.get("resources/black.bmp");
|
|
|
auto texture = mock.get(texture_id);
|
|
|
EXPECT_THAT(texture, Eq(texture_id));
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, SizeOfTexturePassedIntoCompile) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(0);
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(2, 2), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(0);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(2, 2), _)).Times(1);
|
|
|
mock.get("resources/black2.bmp");
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, CanReadRGBFormat) {
|
|
|
using graphics::textures::format;
|
|
|
- EXPECT_CALL(mock, compile(format::RGB, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(format::RGB, math::vec2i(1, 1), _)).Times(1);
|
|
|
mock.get("resources/black_rgb.png");
|
|
|
}
|
|
|
|
|
|
TEST_F(TextureTest, CanReadRGBAFormat) {
|
|
|
using graphics::textures::format;
|
|
|
- EXPECT_CALL(mock, compile(format::RGBA, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(format::RGBA, math::vec2i(1, 1), _)).Times(1);
|
|
|
mock.get("resources/black_rgba.png");
|
|
|
}
|
|
|
|
|
|
@@ -158,13 +158,13 @@ TEST_F(MaterialTest, ThrowsExceptionIfNoTexOrUniform) {
|
|
|
|
|
|
TEST_F(MaterialTest, GeneratesUniformTexturesIfNoTexFile) {
|
|
|
using graphics::materials::uniform;
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(3);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(3);
|
|
|
EXPECT_NO_THROW(mock.get(cast_p(1), "", "u_normalMap"));
|
|
|
}
|
|
|
|
|
|
TEST_F(MaterialTest, CreatedMaterialCanBeRefetched) {
|
|
|
// Three times and no more
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(3);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(3);
|
|
|
auto id_1 = mock.get(cast_p(1), "", "u_normalMap");
|
|
|
auto id_2 = mock.get(cast_p(1), "", "u_normalMap");
|
|
|
EXPECT_THAT(id_1, Eq(id_2));
|
|
|
@@ -181,13 +181,13 @@ TEST_F(MaterialTest, CanGetMaterialFromId) {
|
|
|
TEST_F(MaterialTest, UniformMaterialIsOneByOne) {
|
|
|
auto material = mock.get(mock.get(cast_p(1), "", "u_normalMap"));
|
|
|
// Uniforms are always sized 1x1
|
|
|
- EXPECT_THAT(material.size, Eq(make_vector(1, 1)));
|
|
|
+ EXPECT_THAT(material.size, Eq(math::vec2i(1, 1)));
|
|
|
}
|
|
|
|
|
|
TEST_F(MaterialTest, SizeCapturesTextureSize) {
|
|
|
auto material =
|
|
|
mock.get(mock.get(cast_p(1), "resources/black2.bmp", "u_normalMap"));
|
|
|
- EXPECT_THAT(material.size, Eq(make_vector(2, 2)));
|
|
|
+ EXPECT_THAT(material.size, Eq(math::vec2i(2, 2)));
|
|
|
}
|
|
|
|
|
|
TEST_F(MaterialTest, UniformMaterialHasDataBindingToNormalTex) {
|
|
|
@@ -202,14 +202,14 @@ TEST_F(MaterialTest, UniformMaterialHasDataBindingToNormalTex) {
|
|
|
}
|
|
|
|
|
|
TEST_F(MaterialTest, DifferentProgramMakesDifferentMaterial) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(3);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(3);
|
|
|
auto id_1 = mock.get(cast_p(1), "", "u_normalMap");
|
|
|
auto id_2 = mock.get(cast_p(2), "", "u_normalMap");
|
|
|
EXPECT_THAT(id_1, Ne(id_2));
|
|
|
}
|
|
|
|
|
|
TEST_F(MaterialTest, DifferentProgramDoesntChangeUniformId) {
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(3);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(3);
|
|
|
auto mat_1 = mock.get(mock.get(cast_p(1), "", "u_normalMap"));
|
|
|
auto mat_2 = mock.get(mock.get(cast_p(2), "", "u_normalMap"));
|
|
|
EXPECT_THAT(mat_1.uniforms[0].texture, Eq(mat_2.uniforms[0].texture));
|
|
|
@@ -217,7 +217,7 @@ TEST_F(MaterialTest, DifferentProgramDoesntChangeUniformId) {
|
|
|
|
|
|
TEST_F(MaterialTest, TexFileSkipsUniformLoad) {
|
|
|
using graphics::materials::uniform;
|
|
|
- EXPECT_CALL(mock, compile(_, make_vector(1, 1), _)).Times(1);
|
|
|
+ EXPECT_CALL(mock, compile(_, math::vec2i(1, 1), _)).Times(1);
|
|
|
auto material =
|
|
|
mock.get(mock.get(cast_p(1), "resources/black.bmp", "u_normalMap"));
|
|
|
EXPECT_THAT(material.uniforms, SizeIs(1));
|