| Flutter Windows Embedder |

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 TEST(FlutterProjectBundle, DartEntrypointArguments) {
51 FlutterDesktopEngineProperties properties = {};
52 properties.assets_path = L"foo\\flutter_assets";
53 properties.icu_data_path = L"foo\\icudtl.dat";
54
55 std::vector<const char*> test_arguments = {"arg1", "arg2"};
56 properties.dart_entrypoint_argc = test_arguments.size();
57 properties.dart_entrypoint_argv = test_arguments.data();
58
59 FlutterProjectBundle project(properties);
60
61 std::vector<std::string> retrieved_arguments =
62 project.dart_entrypoint_arguments();
63 EXPECT_EQ(retrieved_arguments.size(), 2U);
64 EXPECT_EQ(retrieved_arguments[0], "arg1");
65 EXPECT_EQ(retrieved_arguments[1], "arg2");
66 }
67
68 #ifndef FLUTTER_RELEASE
69 TEST(FlutterProjectBundle, Switches) {
70 FlutterDesktopEngineProperties properties = {};
71 properties.assets_path = L"foo\\flutter_assets";
72 properties.icu_data_path = L"foo\\icudtl.dat";
73
74 _putenv_s("FLUTTER_ENGINE_SWITCHES", "2");
75 _putenv_s("FLUTTER_ENGINE_SWITCH_1", "abc");
76 _putenv_s("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
77
78 FlutterProjectBundle project(properties);
79
80 std::vector<std::string> switches = project.GetSwitches();
81 EXPECT_EQ(switches.size(), 2);
82 EXPECT_EQ(switches[0], "--abc");
83 EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
84 }
85 #endif // !FLUTTER_RELEASE
86
87 } // namespace testing
88 } // namespace flutter
flutter::FlutterProjectBundle
Definition: flutter_project_bundle.h:32
flutter::FlutterProjectBundle::assets_path
const std::filesystem::path & assets_path()
Definition: flutter_project_bundle.h:47
flutter::FlutterProjectBundle::HasValidPaths
bool HasValidPaths()
Definition: flutter_project_bundle.cc:58
flutter::FlutterProjectBundle::GetSwitches
const std::vector< std::string > GetSwitches()
Definition: flutter_project_bundle.cc:96
flutter::FlutterProjectBundle::icu_path
const std::filesystem::path & icu_path()
Definition: flutter_project_bundle.h:50
flutter::FlutterProjectBundle::dart_entrypoint_arguments
const std::vector< std::string > & dart_entrypoint_arguments() const
Definition: flutter_project_bundle.h:69
flutter_project_bundle.h
flutter::testing::TEST
TEST(AccessibilityBridgeWindows, GetParent)
Definition: accessibility_bridge_windows_unittests.cc:243
flutter
Definition: accessibility_bridge_windows.cc:11
FlutterDesktopEngineProperties
Definition: flutter_windows.h:60
FlutterDesktopEngineProperties::icu_data_path
const wchar_t * icu_data_path
Definition: flutter_windows.h:69
FlutterDesktopEngineProperties::dart_entrypoint_argc
int dart_entrypoint_argc
Definition: flutter_windows.h:86
FlutterDesktopEngineProperties::assets_path
const wchar_t * assets_path
Definition: flutter_windows.h:64
FlutterDesktopEngineProperties::dart_entrypoint_argv
const char ** dart_entrypoint_argv
Definition: flutter_windows.h:90