Index: chrome/browser/android/vr_shell/gltf_parser_unittest.cc |
diff --git a/chrome/browser/android/vr_shell/gltf_parser_unittest.cc b/chrome/browser/android/vr_shell/gltf_parser_unittest.cc |
index b7ff48ee342c367031a6689d985ae551129d705f..b987d7af77c38f853cb428cdb49b58357955ce28 100644 |
--- a/chrome/browser/android/vr_shell/gltf_parser_unittest.cc |
+++ b/chrome/browser/android/vr_shell/gltf_parser_unittest.cc |
@@ -17,18 +17,26 @@ |
namespace vr_shell { |
-class GltfParserTest : public testing::Test { |
+class DataDrivenTest : public testing::Test { |
protected: |
static void SetUpTestCase() { test::RegisterPathProvider(); } |
void SetUp() override { PathService::Get(test::DIR_TEST_DATA, &data_dir_); } |
base::FilePath data_dir_; |
+}; |
+class GltfParserTest : public DataDrivenTest { |
+ protected: |
std::unique_ptr<base::DictionaryValue> Deserialize( |
const base::FilePath& gltf_path); |
}; |
+class BinaryGltfParserTest : public DataDrivenTest { |
+ protected: |
+ base::StringPiece Read(const base::FilePath& path); |
+}; |
+ |
std::unique_ptr<base::DictionaryValue> GltfParserTest::Deserialize( |
const base::FilePath& gltf_path) { |
int error_code; |
@@ -42,6 +50,12 @@ std::unique_ptr<base::DictionaryValue> GltfParserTest::Deserialize( |
return std::unique_ptr<base::DictionaryValue>(asset); |
} |
+base::StringPiece BinaryGltfParserTest::Read(const base::FilePath& path) { |
+ std::string data; |
+ base::ReadFileToString(path, &data); |
+ return base::StringPiece(data); |
+} |
+ |
TEST_F(GltfParserTest, Parse) { |
auto asset = Deserialize(data_dir_.Append("sample_inline.gltf")); |
GltfParser parser; |
@@ -157,4 +171,15 @@ TEST_F(GltfParserTest, ParseExternalNoPath) { |
EXPECT_EQ(nullptr, parser.Parse(*asset, &buffers)); |
} |
+TEST_F(BinaryGltfParserTest, ParseBinary) { |
+ auto glb_data = Read(data_dir_.Append("sample.glb")); |
+ std::vector<std::unique_ptr<gltf::Buffer>> buffers; |
+ auto asset = BinaryGltfParser::Parse(glb_data, &buffers); |
+ EXPECT_TRUE(asset); |
+ EXPECT_EQ(1u, buffers.size()); |
+ const gltf::BufferView* buffer_view = asset->GetBufferView(0); |
+ EXPECT_TRUE(buffer_view); |
+ EXPECT_EQ(0, buffer_view->buffer); |
+} |
+ |
} // namespace vr_shell |