summaryrefslogtreecommitdiff
path: root/test/programs
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-15 18:43:58 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-03-22 15:59:10 +0100
commit3c91b6b7de487993e75de552ba44249740644e42 (patch)
tree69b8b2642b3d8496657db92459b0a23e130b501d /test/programs
parentd20327844cac88b6bf42b201eac35e816a189a8a (diff)
downloadqtlocation-mapboxgl-3c91b6b7de487993e75de552ba44249740644e42.tar.gz
[core] cache binary shaders on Android
Diffstat (limited to 'test/programs')
-rw-r--r--test/programs/binary_program.test.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/programs/binary_program.test.cpp b/test/programs/binary_program.test.cpp
new file mode 100644
index 0000000000..ce544e7652
--- /dev/null
+++ b/test/programs/binary_program.test.cpp
@@ -0,0 +1,39 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/programs/binary_program.hpp>
+
+using namespace mbgl;
+
+TEST(BinaryProgram, ObtainValues) {
+ const BinaryProgram binaryProgram{ 42,
+ "binary code",
+ "identifier",
+ { { "a_pos", 1 }, { "a_data", 4 } },
+ { { "u_world", 1 }, { "u_ratio", 3 } } };
+
+ EXPECT_EQ(42u, binaryProgram.format());
+ EXPECT_EQ("binary code", binaryProgram.code());
+ EXPECT_EQ("identifier", binaryProgram.identifier());
+ EXPECT_EQ(1, binaryProgram.attributeLocation("a_pos"));
+ EXPECT_EQ(0, binaryProgram.attributeLocation("u_world"));
+ EXPECT_EQ(4, binaryProgram.attributeLocation("a_data"));
+ EXPECT_EQ(1, binaryProgram.uniformLocation("u_world"));
+ EXPECT_EQ(3, binaryProgram.uniformLocation("u_ratio"));
+ EXPECT_EQ(0, binaryProgram.uniformLocation("a_data"));
+
+ auto serialized = binaryProgram.serialize();
+
+ const BinaryProgram binaryProgram2(std::move(serialized));
+
+ EXPECT_EQ(42u, binaryProgram2.format());
+ EXPECT_EQ("binary code", binaryProgram2.code());
+ EXPECT_EQ("identifier", binaryProgram2.identifier());
+ EXPECT_EQ(1, binaryProgram2.attributeLocation("a_pos"));
+ EXPECT_EQ(0, binaryProgram2.attributeLocation("u_world"));
+ EXPECT_EQ(4, binaryProgram2.attributeLocation("a_data"));
+ EXPECT_EQ(1, binaryProgram2.uniformLocation("u_world"));
+ EXPECT_EQ(3, binaryProgram2.uniformLocation("u_ratio"));
+ EXPECT_EQ(0, binaryProgram2.uniformLocation("a_data"));
+
+ EXPECT_THROW(BinaryProgram(""), std::runtime_error);
+}