Flutter Engine
flutter_project_bundle_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 
5 #include "flutter/shell/platform/windows/flutter_project_bundle.h"
6 #include "gtest/gtest.h"
7 
8 namespace flutter {
9 namespace testing {
10 
11 TEST(FlutterProjectBundle, BasicPropertiesAbsolutePaths) {
12  FlutterDesktopEngineProperties properties = {};
13  properties.assets_path = L"C:\\foo\\flutter_assets";
14  properties.icu_data_path = L"C:\\foo\\icudtl.dat";
15 
16  FlutterProjectBundle project(properties);
17 
18  EXPECT_TRUE(project.HasValidPaths());
19  EXPECT_EQ(project.assets_path().string(), "C:\\foo\\flutter_assets");
20  EXPECT_EQ(project.icu_path().string(), "C:\\foo\\icudtl.dat");
21 }
22 
23 TEST(FlutterProjectBundle, BasicPropertiesRelativePaths) {
24  FlutterDesktopEngineProperties properties = {};
25  properties.assets_path = L"foo\\flutter_assets";
26  properties.icu_data_path = L"foo\\icudtl.dat";
27 
28  FlutterProjectBundle project(properties);
29 
30  EXPECT_TRUE(project.HasValidPaths());
31  EXPECT_TRUE(project.assets_path().is_absolute());
32  EXPECT_EQ(project.assets_path().filename().string(), "flutter_assets");
33  EXPECT_TRUE(project.icu_path().is_absolute());
34  EXPECT_EQ(project.icu_path().filename().string(), "icudtl.dat");
35 }
36 
37 TEST(FlutterProjectBundle, SwitchesEmpty) {
38  FlutterDesktopEngineProperties properties = {};
39  properties.assets_path = L"foo\\flutter_assets";
40  properties.icu_data_path = L"foo\\icudtl.dat";
41 
42  // Clear the main environment variable, since test order is not guaranteed.
43  _putenv_s("FLUTTER_ENGINE_SWITCHES", "");
44 
45  FlutterProjectBundle project(properties);
46 
47  EXPECT_EQ(project.GetSwitches().size(), 0);
48 }
49 
50 #ifndef FLUTTER_RELEASE
52  FlutterDesktopEngineProperties properties = {};
53  properties.assets_path = L"foo\\flutter_assets";
54  properties.icu_data_path = L"foo\\icudtl.dat";
55 
56  _putenv_s("FLUTTER_ENGINE_SWITCHES", "2");
57  _putenv_s("FLUTTER_ENGINE_SWITCH_1", "abc");
58  _putenv_s("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
59 
60  FlutterProjectBundle project(properties);
61 
62  std::vector<std::string> switches = project.GetSwitches();
63  EXPECT_EQ(switches.size(), 2);
64  EXPECT_EQ(switches[0], "--abc");
65  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
66 }
67 #endif // !FLUTTER_RELEASE
68 
69 } // namespace testing
70 } // namespace flutter
const std::filesystem::path & icu_path()
const std::vector< std::string > GetSwitches()
const std::filesystem::path & assets_path()
TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithNoMutations)