Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shell/platform/tizen/flutter_project_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ FlutterProjectBundle::FlutterProjectBundle(
aot_library_path_ = std::filesystem::path(properties.aot_library_path);
}

for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
dart_entrypoint_arguments_.push_back(
std::string(properties.dart_entrypoint_argv[i]));
}

// Resolve any relative paths.
if (assets_path_.is_relative() || icu_path_.is_relative() ||
(!aot_library_path_.empty() && aot_library_path_.is_relative())) {
Expand Down
9 changes: 9 additions & 0 deletions shell/platform/tizen/flutter_project_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ class FlutterProjectBundle {
// Logs and returns nullptr on failure.
UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs);

// Returns the command line arguments to be passed through to the Dart
// entrypoint.
const std::vector<std::string>& dart_entrypoint_arguments() const {
return dart_entrypoint_arguments_;
}

private:
std::filesystem::path assets_path_;
std::filesystem::path icu_path_;
std::vector<std::string> switches_ = {};

// Path to the AOT library file, if any.
std::filesystem::path aot_library_path_;

// Dart entrypoint arguments.
std::vector<std::string> dart_entrypoint_arguments_;
};

} // namespace flutter
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine(
window_properties.height, window_properties.transparent,
window_properties.focusable);
}
if (!engine->RunEngine()) {
if (!engine->RunEngine(engine_properties.entry_point)) {
FT_LOG(Error) << "Failed to start the Flutter engine.";
return nullptr;
}
Expand Down
17 changes: 16 additions & 1 deletion shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void FlutterTizenEngine::InitializeRenderer(int32_t x,
#endif
}

bool FlutterTizenEngine::RunEngine() {
bool FlutterTizenEngine::RunEngine(const char* entrypoint) {
if (engine_ != nullptr) {
FT_LOG(Error) << "The engine has already started.";
return false;
Expand Down Expand Up @@ -149,6 +149,14 @@ bool FlutterTizenEngine::RunEngine() {
Logger::SetLoggingLevel(kLogLevelDebug);
}

const std::vector<std::string>& entrypoint_args =
project_->dart_entrypoint_arguments();
std::vector<const char*> entrypoint_argv;
std::transform(
entrypoint_args.begin(), entrypoint_args.end(),
std::back_inserter(entrypoint_argv),
[](const std::string& arg) -> const char* { return arg.c_str(); });

// Configure task runners.
FlutterTaskRunnerDescription platform_task_runner = {};
platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
Expand Down Expand Up @@ -190,6 +198,9 @@ bool FlutterTizenEngine::RunEngine() {
args.icu_data_path = icu_path_string.c_str();
args.command_line_argc = static_cast<int>(argv.size());
args.command_line_argv = argv.size() > 0 ? argv.data() : nullptr;
args.dart_entrypoint_argc = static_cast<int>(entrypoint_argv.size());
args.dart_entrypoint_argv =
entrypoint_argv.size() > 0 ? entrypoint_argv.data() : nullptr;
args.platform_message_callback =
[](const FlutterPlatformMessage* engine_message, void* user_data) {
if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
Expand All @@ -215,6 +226,10 @@ bool FlutterTizenEngine::RunEngine() {
args.aot_data = aot_data_.get();
}

if (entrypoint) {
args.custom_dart_entrypoint = entrypoint;
}

FlutterRendererConfig renderer_config = GetRendererConfig();

auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
Expand Down
7 changes: 5 additions & 2 deletions shell/platform/tizen/flutter_tizen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
bool transparent,
bool focusable);

// Starts running the engine.
bool RunEngine();
// Starts running the engine with the given entrypoint. If null, defaults to
// main().
//
// Returns false if the engine couldn't be started.
bool RunEngine(const char* entrypoint);

// Stops the engine.
bool StopEngine();
Expand Down
18 changes: 9 additions & 9 deletions shell/platform/tizen/flutter_tizen_engine_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,37 @@ class FlutterTizenEngineTestHeaded : public FlutterTizenEngineTest {

TEST_F(FlutterTizenEngineTest, Run) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
}

TEST_F(FlutterTizenEngineTest, Run_Twice) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_FALSE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_FALSE(engine_->RunEngine(nullptr));
}

TEST_F(FlutterTizenEngineTest, Stop) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_TRUE(engine_->StopEngine());
}

TEST_F(FlutterTizenEngineTest, Stop_Twice) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_TRUE(engine_->StopEngine());
EXPECT_FALSE(engine_->StopEngine());
}

TEST_F(FlutterTizenEngineTest, GetPluginRegistrar) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_TRUE(engine_->GetPluginRegistrar() != nullptr);
}

TEST_F(FlutterTizenEngineTest, GetTextureRegistrar) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_TRUE(engine_->GetTextureRegistrar() == nullptr);
}

TEST_F(FlutterTizenEngineTestHeaded, GetTextureRegistrar) {
EXPECT_TRUE(engine_->RunEngine());
EXPECT_TRUE(engine_->RunEngine(nullptr));
EXPECT_TRUE(engine_->GetTextureRegistrar() != nullptr);
}

Expand Down Expand Up @@ -134,7 +134,7 @@ TEST_F(FlutterTizenEngineTest, RunDoesExpectedInitialization) {
return kSuccess;
}));

engine_->RunEngine();
engine_->RunEngine(nullptr);

EXPECT_TRUE(run_called);
EXPECT_TRUE(update_locales_called);
Expand Down
8 changes: 8 additions & 0 deletions shell/platform/tizen/public/flutter_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ typedef struct {
const char** switches;
// The number of elements in |switches|.
size_t switches_count;
// The optional entry point in the Dart project, if the entry point is null,
// defaults to main().
const char* entry_point;
// Number of elements in the array passed in as dart_entrypoint_argv.
int dart_entrypoint_argc;
// Array of Dart entrypoint arguments. This is deep copied during the call
// to FlutterDesktopEngineCreate.
const char** dart_entrypoint_argv;
} FlutterDesktopEngineProperties;

// Runs an instance of a Flutter engine with the given properties.
Expand Down