Flutter Engine
 
Loading...
Searching...
No Matches
native_assets_unittests.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
6
7#include "gtest/gtest.h"
8
9namespace flutter {
10namespace testing {
11
12// Manifest containing all hosts on which this test is run.
13// In practise, a manifest will only contain a single OS.
14// A manifest might contain multiple architectures if the OS supports
15// multi-arch apps.
16const char* kTestManifest = R"({
17 "format-version": [
18 1,
19 0,
20 0
21 ],
22 "native-assets": {
23 "linux_arm64": {
24 "package:my_package/my_package_bindings_generated.dart": [
25 "absolute",
26 "libmy_package.so"
27 ]
28 },
29 "linux_x64": {
30 "package:my_package/my_package_bindings_generated.dart": [
31 "absolute",
32 "libmy_package.so"
33 ]
34 },
35 "fuchsia_arm64": {
36 "package:my_package/my_package_bindings_generated.dart": [
37 "absolute",
38 "libmy_package.so"
39 ]
40 },
41 "fuchsia_x64": {
42 "package:my_package/my_package_bindings_generated.dart": [
43 "absolute",
44 "libmy_package.so"
45 ]
46 },
47 "macos_arm64": {
48 "package:my_package/my_package_bindings_generated.dart": [
49 "absolute",
50 "my_package.framework/my_package"
51 ]
52 },
53 "macos_x64": {
54 "package:my_package/my_package_bindings_generated.dart": [
55 "absolute",
56 "my_package.framework/my_package"
57 ]
58 },
59 "windows_x64": {
60 "package:my_package/my_package_bindings_generated.dart": [
61 "absolute",
62 "my_package.dll"
63 ]
64 }
65 }
66})";
67
68TEST(NativeAssetsManagerTest, NoAvailableAssets) {
70 std::string available_assets = manager.AvailableNativeAssets();
71 ASSERT_EQ(available_assets, "No available native assets.");
72}
73
74TEST(NativeAssetsManagerTest, NativeAssetsManifestParsing) {
76 manager.RegisterNativeAssets(reinterpret_cast<const uint8_t*>(kTestManifest),
77 strlen(kTestManifest));
78
79 std::string available_assets = manager.AvailableNativeAssets();
80 ASSERT_EQ(available_assets,
81 "Available native assets: "
82 "package:my_package/my_package_bindings_generated.dart.");
83
84 std::vector<std::string> existing_asset = manager.LookupNativeAsset(
85 "package:my_package/my_package_bindings_generated.dart");
86 ASSERT_EQ(existing_asset.size(), 2u);
87 ASSERT_EQ(existing_asset[0], "absolute");
88#if defined(FML_OS_MACOSX)
89 ASSERT_EQ(existing_asset[1], "my_package.framework/my_package");
90#elif defined(FML_OS_LINUX) || defined(FML_OS_FUCHSIA)
91 ASSERT_EQ(existing_asset[1], "libmy_package.so");
92#elif defined(FML_OS_WIN)
93 ASSERT_EQ(existing_asset[1], "my_package.dll");
94#endif
95
96 std::vector<std::string> non_existing_asset =
97 manager.LookupNativeAsset("non_existing_asset");
98 ASSERT_EQ(non_existing_asset.size(), 0u);
99}
100
101} // namespace testing
102} // namespace flutter
void RegisterNativeAssets(const uint8_t *manifest, size_t manifest_size)
TEST(NativeAssetsManagerTest, NoAvailableAssets)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager