Flutter Engine
component_unittest.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/shell/platform/fuchsia/flutter/component.h"
6 
7 #include <gtest/gtest.h>
8 
9 namespace flutter_runner {
10 namespace {
11 
12 TEST(Component, ParseProgramMetadata) {
13  std::string data_path;
14  std::string assets_path;
15 
16  // The ProgramMetadata field may be null. We should parse this as if no
17  // fields were specified.
18  Application::ParseProgramMetadata(nullptr, &data_path, &assets_path);
19 
20  EXPECT_EQ(data_path, "");
21  EXPECT_EQ(assets_path, "");
22 
23  // The ProgramMetadata field may be empty. Treat this the same as null.
24  fidl::VectorPtr<fuchsia::sys::ProgramMetadata> program_metadata(size_t{0});
25 
26  Application::ParseProgramMetadata(program_metadata, &data_path, &assets_path);
27 
28  EXPECT_EQ(data_path, "");
29  EXPECT_EQ(assets_path, "");
30 
31  // The assets_path defaults to the "data" value if unspecified
32  program_metadata = {{"data", "foobar"}};
33 
34  Application::ParseProgramMetadata(program_metadata, &data_path, &assets_path);
35 
36  EXPECT_EQ(data_path, "pkg/foobar");
37  EXPECT_EQ(assets_path, "pkg/foobar");
38 
39  data_path = "";
40  assets_path = "";
41 
42  program_metadata = {{"not_data", "foo"}, {"data", "bar"}, {"assets", "baz"}};
43 
44  Application::ParseProgramMetadata(program_metadata, &data_path, &assets_path);
45 
46  EXPECT_EQ(data_path, "pkg/bar");
47  EXPECT_EQ(assets_path, "pkg/baz");
48 }
49 
50 } // anonymous namespace
51 } // namespace flutter_runner
static void ParseProgramMetadata(const fidl::VectorPtr< fuchsia::sys::ProgramMetadata > &program_metadata, std::string *data_path, std::string *assets_path)
Definition: component.cc:61
TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent)