Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/android/vr_shell/gltf_parser_unittest.cc

Issue 2774653002: Support for parsing external file references in a glTF resource. (Closed)
Patch Set: Modifying comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/gltf_parser.h" 5 #include "chrome/browser/android/vr_shell/gltf_parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/android/vr_shell/test/paths.h" 15 #include "chrome/browser/android/vr_shell/test/paths.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace vr_shell { 18 namespace vr_shell {
19 19
20 TEST(GltfParser, Parse) { 20 class GltfParserTest : public testing::Test {
21 test::RegisterPathProvider(); 21 protected:
22 base::FilePath gltf_path; 22 void SetUp() override {
23 PathService::Get(test::DIR_TEST_DATA, &gltf_path); 23 test::RegisterPathProvider();
24 gltf_path = gltf_path.Append("sample_inline.gltf"); 24 PathService::Get(test::DIR_TEST_DATA, &data_dir_);
25 }
26
27 base::FilePath data_dir_;
28 };
29
30 TEST_F(GltfParserTest, Parse) {
31 auto gltf_path = data_dir_.Append("sample_inline.gltf");
25 32
26 int error_code; 33 int error_code;
27 std::string error_msg; 34 std::string error_msg;
28 JSONFileValueDeserializer json_deserializer(gltf_path); 35 JSONFileValueDeserializer json_deserializer(gltf_path);
29 auto asset_value = json_deserializer.Deserialize(&error_code, &error_msg); 36 auto asset_value = json_deserializer.Deserialize(&error_code, &error_msg);
30 EXPECT_NE(nullptr, asset_value); 37 EXPECT_NE(nullptr, asset_value);
31 base::DictionaryValue* asset; 38 base::DictionaryValue* asset;
32 EXPECT_TRUE(asset_value->GetAsDictionary(&asset)); 39 EXPECT_TRUE(asset_value->GetAsDictionary(&asset));
33 40
34 GltfParser parser; 41 GltfParser parser;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 92
86 const gltf::Scene* scene = gltf_model->GetScene(0); 93 const gltf::Scene* scene = gltf_model->GetScene(0);
87 EXPECT_NE(nullptr, scene); 94 EXPECT_NE(nullptr, scene);
88 EXPECT_EQ(nullptr, gltf_model->GetNode(2)); 95 EXPECT_EQ(nullptr, gltf_model->GetNode(2));
89 EXPECT_EQ(1u, scene->nodes.size()); 96 EXPECT_EQ(1u, scene->nodes.size());
90 EXPECT_EQ(node_1, scene->nodes[0]); 97 EXPECT_EQ(node_1, scene->nodes[0]);
91 98
92 EXPECT_EQ(scene, gltf_model->GetMainScene()); 99 EXPECT_EQ(scene, gltf_model->GetMainScene());
93 } 100 }
94 101
102 TEST_F(GltfParserTest, ParseExternal) {
103 auto gltf_path = data_dir_.Append("sample_external.gltf");
104
105 GltfParser parser;
106 auto gltf_model = parser.Parse(gltf_path);
107 EXPECT_NE(nullptr, gltf_model);
108 const gltf::Buffer* buffer = gltf_model->GetBuffer(0);
109 EXPECT_NE(nullptr, buffer);
110 EXPECT_EQ("HELLO WORLD!", *buffer);
111 EXPECT_EQ(12u, buffer->length());
112 }
113
95 } // namespace vr_shell 114 } // namespace vr_shell
cjgrant 2017/03/24 15:11:54 Could you add at least one test that expects a fai
acondor_ 2017/03/24 18:00:55 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698