未验证 提交 f873cd0c 编写于 作者: G George Wright 提交者: GitHub

Add unit tests for Dart entrypoint arguments on Windows (#27497)

上级 9edde742
......@@ -42,4 +42,17 @@ TEST_F(DartProjectTest, ProjectWithCustomPaths) {
EXPECT_EQ(GetProjectAotLibraryPath(project), L"lib\\file.so");
}
TEST_F(DartProjectTest, DartEntrypointArguments) {
DartProject project(L"test");
std::vector<std::string> test_arguments = {"arg1", "arg2", "arg3"};
project.set_dart_entrypoint_arguments(test_arguments);
auto returned_arguments = project.dart_entrypoint_arguments();
EXPECT_EQ(returned_arguments.size(), 3U);
EXPECT_EQ(returned_arguments[0], "arg1");
EXPECT_EQ(returned_arguments[1], "arg2");
EXPECT_EQ(returned_arguments[2], "arg3");
}
} // namespace flutter
......@@ -47,6 +47,24 @@ TEST(FlutterProjectBundle, SwitchesEmpty) {
EXPECT_EQ(project.GetSwitches().size(), 0);
}
TEST(FlutterProjectBundle, DartEntrypointArguments) {
FlutterDesktopEngineProperties properties = {};
properties.assets_path = L"foo\\flutter_assets";
properties.icu_data_path = L"foo\\icudtl.dat";
std::vector<const char*> test_arguments = {"arg1", "arg2"};
properties.dart_entrypoint_argc = test_arguments.size();
properties.dart_entrypoint_argv = test_arguments.data();
FlutterProjectBundle project(properties);
std::vector<std::string> retrieved_arguments =
project.dart_entrypoint_arguments();
EXPECT_EQ(retrieved_arguments.size(), 2U);
EXPECT_EQ(retrieved_arguments[0], "arg1");
EXPECT_EQ(retrieved_arguments[1], "arg2");
}
#ifndef FLUTTER_RELEASE
TEST(FlutterProjectBundle, Switches) {
FlutterDesktopEngineProperties properties = {};
......
......@@ -19,6 +19,11 @@ std::unique_ptr<FlutterWindowsEngine> GetTestEngine() {
properties.assets_path = L"C:\\foo\\flutter_assets";
properties.icu_data_path = L"C:\\foo\\icudtl.dat";
properties.aot_library_path = L"C:\\foo\\aot.so";
std::vector<const char*> test_arguments = {"arg1", "arg2"};
properties.dart_entrypoint_argc = test_arguments.size();
properties.dart_entrypoint_argv = test_arguments.data();
FlutterProjectBundle project(properties);
auto engine = std::make_unique<FlutterWindowsEngine>(project);
......@@ -52,7 +57,9 @@ TEST(FlutterWindowsEngine, RunDoesExpectedInitialization) {
// Spot-check arguments.
EXPECT_STREQ(args->assets_path, "C:\\foo\\flutter_assets");
EXPECT_STREQ(args->icu_data_path, "C:\\foo\\icudtl.dat");
EXPECT_EQ(args->dart_entrypoint_argc, 0);
EXPECT_EQ(args->dart_entrypoint_argc, 2U);
EXPECT_EQ(strcmp(args->dart_entrypoint_argv[0], "arg1"), 0);
EXPECT_EQ(strcmp(args->dart_entrypoint_argv[1], "arg2"), 0);
EXPECT_NE(args->platform_message_callback, nullptr);
EXPECT_NE(args->custom_task_runners, nullptr);
EXPECT_EQ(args->custom_dart_entrypoint, nullptr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册