Skip to content

Commit 2e3cbb9

Browse files
committed
Rebase and resolve conflicts
1 parent 64f3211 commit 2e3cbb9

5 files changed

+70
-95
lines changed

shell/platform/tizen/flutter_project_bundle.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
#include "flutter_project_bundle.h"
77

8+
#ifdef __X64_SHELL__
9+
#include "flutter/shell/platform/common/path_utils.h"
10+
#else
811
#include <app_common.h>
12+
#endif
913

1014
#include <filesystem>
1115

1216
#include "flutter/shell/platform/tizen/tizen_log.h"
1317

1418
namespace flutter {
1519

20+
#ifndef __X64_SHELL__
1621
namespace {
1722

1823
// Returns the path of the directory containing the app binary, or an empty
@@ -28,6 +33,7 @@ std::filesystem::path GetExecutableDirectory() {
2833
}
2934

3035
} // namespace
36+
#endif
3137

3238
FlutterProjectBundle::FlutterProjectBundle(
3339
const FlutterDesktopEngineProperties& properties)

shell/platform/tizen/flutter_tizen_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
137137
std::unique_ptr<PlatformViewChannel> platform_view_channel;
138138

139139
private:
140+
// Whether the engine is running in headed or headless mode.
140141
bool IsHeaded() { return renderer != nullptr; }
141142

142143
FlutterDesktopMessage ConvertToDesktopMessage(

shell/platform/tizen/flutter_tizen_engine_unittest.cc

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
2-
// Copyright 2013 The Flutter Authors. All rights reserved.
1+
// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
32
// Use of this source code is governed by a BSD-style license that can be
43
// found in the LICENSE file.
54

@@ -9,52 +8,22 @@
98
namespace flutter {
109
namespace testing {
1110

12-
class FlutterTizenEngineTestSimple : public ::testing::Test {
13-
protected:
14-
void SetUp() { ecore_init(); }
15-
};
16-
17-
TEST_F(FlutterTizenEngineTestSimple, Create_Headless) {
18-
flutter::FlutterTizenEngine* tizen_engine =
19-
new flutter::FlutterTizenEngine(false);
20-
EXPECT_TRUE(tizen_engine != nullptr);
21-
delete tizen_engine;
22-
}
23-
24-
// TODO
25-
TEST_F(FlutterTizenEngineTestSimple, DISABLED_Create_Headed) {
26-
flutter::FlutterTizenEngine* tizen_engine =
27-
new flutter::FlutterTizenEngine(true);
28-
EXPECT_TRUE(tizen_engine != nullptr);
29-
delete tizen_engine;
30-
}
31-
3211
class FlutterTizenEngineTest : public ::testing::Test {
3312
public:
3413
FlutterTizenEngineTest() {
3514
ecore_init();
36-
37-
std::string tpk_root;
38-
char path[256];
39-
EXPECT_TRUE(getcwd(path, sizeof(path)) != NULL);
40-
tpk_root = path + std::string("/tpkroot");
41-
42-
assets_path_ = tpk_root + "/res/flutter_assets";
43-
icu_data_path_ = tpk_root + "/res/icudtl.dat";
44-
aot_lib_path_ = tpk_root + "/lib/libapp.so";
45-
46-
switches_.push_back("--disable-observatory");
15+
elm_init(0, nullptr);
4716
}
4817

4918
protected:
5019
void SetUp() {
51-
engine_prop_.assets_path = assets_path_.c_str();
52-
engine_prop_.icu_data_path = icu_data_path_.c_str();
53-
engine_prop_.aot_library_path = aot_lib_path_.c_str();
54-
engine_prop_.switches = switches_.data();
55-
engine_prop_.switches_count = switches_.size();
20+
FlutterDesktopEngineProperties engine_prop = {};
21+
engine_prop.assets_path = "foo/flutter_assets";
22+
engine_prop.icu_data_path = "foo/icudtl.dat";
23+
engine_prop.aot_library_path = "foo/libapp.so";
5624

57-
auto engine = std::make_unique<flutter::FlutterTizenEngine>(false);
25+
FlutterProjectBundle project(engine_prop);
26+
auto engine = std::make_unique<FlutterTizenEngine>(project);
5827
engine_ = engine.release();
5928
}
6029

@@ -65,49 +34,53 @@ class FlutterTizenEngineTest : public ::testing::Test {
6534
engine_ = nullptr;
6635
}
6736

68-
std::string assets_path_;
69-
std::string icu_data_path_;
70-
std::string aot_lib_path_;
7137
flutter::FlutterTizenEngine* engine_;
72-
FlutterDesktopEngineProperties engine_prop_ = {};
73-
std::vector<const char*> switches_;
38+
};
39+
40+
class FlutterTizenEngineTestHeaded : public FlutterTizenEngineTest {
41+
protected:
42+
void SetUp() {
43+
FlutterTizenEngineTest::SetUp();
44+
engine_->InitializeRenderer(0, 0, 800, 600);
45+
}
7446
};
7547

7648
TEST_F(FlutterTizenEngineTest, Run) {
7749
EXPECT_TRUE(engine_ != nullptr);
78-
EXPECT_TRUE(engine_->RunEngine(engine_prop_));
50+
EXPECT_TRUE(engine_->RunEngine());
7951
EXPECT_TRUE(true);
8052
}
8153

8254
// TODO
8355
TEST_F(FlutterTizenEngineTest, DISABLED_Run_Twice) {
84-
EXPECT_TRUE(engine_ != nullptr);
85-
EXPECT_TRUE(engine_->RunEngine(engine_prop_));
86-
EXPECT_FALSE(engine_->RunEngine(engine_prop_));
56+
EXPECT_TRUE(engine_->RunEngine());
57+
EXPECT_FALSE(engine_->RunEngine());
8758
EXPECT_TRUE(true);
8859
}
8960

9061
TEST_F(FlutterTizenEngineTest, Stop) {
91-
EXPECT_TRUE(engine_ != nullptr);
92-
EXPECT_TRUE(engine_->RunEngine(engine_prop_));
62+
EXPECT_TRUE(engine_->RunEngine());
9363
EXPECT_TRUE(engine_->StopEngine());
9464
}
9565

9666
TEST_F(FlutterTizenEngineTest, Stop_Twice) {
97-
EXPECT_TRUE(engine_ != nullptr);
98-
EXPECT_TRUE(engine_->RunEngine(engine_prop_));
67+
EXPECT_TRUE(engine_->RunEngine());
9968
EXPECT_TRUE(engine_->StopEngine());
10069
EXPECT_FALSE(engine_->StopEngine());
10170
}
10271

10372
TEST_F(FlutterTizenEngineTest, GetPluginRegistrar) {
104-
EXPECT_TRUE(engine_ != nullptr);
73+
EXPECT_TRUE(engine_->RunEngine());
10574
EXPECT_TRUE(engine_->GetPluginRegistrar() != nullptr);
10675
}
10776

108-
// TODO
109-
TEST_F(FlutterTizenEngineTest, DISABLED_GetTextureRegistrar) {
110-
EXPECT_TRUE(engine_ != nullptr);
77+
TEST_F(FlutterTizenEngineTest, GetTextureRegistrar) {
78+
EXPECT_TRUE(engine_->RunEngine());
79+
EXPECT_TRUE(engine_->GetTextureRegistrar() == nullptr);
80+
}
81+
82+
TEST_F(FlutterTizenEngineTestHeaded, GetTextureRegistrar) {
83+
EXPECT_TRUE(engine_->RunEngine());
11184
EXPECT_TRUE(engine_->GetTextureRegistrar() != nullptr);
11285
}
11386

shell/platform/tizen/flutter_tizen_shell.cc

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,58 @@
1-
#include <assert.h>
1+
// Copyright 2021 Samsung Electronics Co., Ltd. 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+
25
#include <unistd.h>
3-
#include <chrono>
4-
#include <iostream>
5-
#include <thread>
6+
7+
#include <string>
8+
#include <vector>
69

710
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
811
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
912

10-
extern int gApp_width;
11-
extern int gApp_height;
12-
13-
std::string TPK_ROOT_PATH = "/tpkroot";
14-
std::string LIB_PATH = "/lib";
15-
std::string RES_PATH = "/res";
16-
1713
class FlutterApp {
1814
public:
1915
explicit FlutterApp() {}
2016
virtual ~FlutterApp() {}
2117

2218
bool OnCreate() {
2319
printf("Launching a Flutter application...\n");
24-
std::string assets_path;
25-
std::string icu_data_path;
26-
std::string aot_lib_path;
27-
FlutterDesktopEngineProperties engine_prop = {};
28-
std::vector<const char*> switches;
2920

30-
std::string tpk_root;
31-
if (app_path_.empty()) {
32-
char path[256];
33-
getcwd(path, sizeof(path));
34-
tpk_root = path + std::string("/tpkroot");
35-
} else {
36-
tpk_root = app_path_;
37-
}
21+
FlutterDesktopWindowProperties window_prop = {};
22+
window_prop.headed = true;
23+
window_prop.x = 0;
24+
window_prop.y = 0;
25+
window_prop.width = window_width_;
26+
window_prop.height = window_height_;
3827

39-
assets_path = tpk_root + "/res/flutter_assets";
40-
icu_data_path = tpk_root + "/res/icudtl.dat";
41-
aot_lib_path = tpk_root + "/lib/libapp.so";
28+
std::string assets_path = app_path_ + "/res/flutter_assets";
29+
std::string icu_data_path = app_path_ + "/res/icudtl.dat";
30+
std::string aot_lib_path = app_path_ + "/lib/libapp.so";
4231

32+
std::vector<const char*> switches;
4333
switches.push_back("--disable-observatory");
4434
switches.push_back("--verbose-logging");
4535
switches.push_back("--enable-dart-profiling");
4636
switches.push_back("--enable-checked-mode");
4737

38+
FlutterDesktopEngineProperties engine_prop = {};
4839
engine_prop.assets_path = assets_path.c_str();
4940
engine_prop.icu_data_path = icu_data_path.c_str();
5041
engine_prop.aot_library_path = aot_lib_path.c_str();
5142
engine_prop.switches = switches.data();
5243
engine_prop.switches_count = switches.size();
53-
engine_ = FlutterDesktopRunEngine(engine_prop, true);
44+
engine_ = FlutterDesktopRunEngine(window_prop, engine_prop);
5445

5546
if (!engine_) {
5647
printf("Could not launch a Flutter application.\n");
5748
return false;
5849
}
59-
// RegisterPlugins(this);
50+
6051
return true;
6152
}
6253

6354
void OnTerminate() {
64-
printf("Shutting down the application...");
55+
printf("Shutting down the application...\n");
6556

6657
FlutterDesktopShutdownEngine(engine_);
6758
engine_ = nullptr;
@@ -71,20 +62,26 @@ class FlutterApp {
7162

7263
int Run(int argc, char** argv) {
7364
ecore_init();
74-
elm_init(0, 0);
65+
elm_init(0, nullptr);
7566
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
7667
elm_config_accel_preference_set("opengl");
7768

7869
for (int i = 1; i < argc; i++) {
7970
if (strstr(argv[i], "--width=") == argv[i]) {
80-
gApp_width = std::atoi(argv[i] + strlen("--width="));
71+
window_width_ = std::atoi(argv[i] + strlen("--width="));
8172
} else if (strstr(argv[i], "--height=") == argv[i]) {
82-
gApp_height = std::atoi(argv[i] + strlen("--height="));
73+
window_height_ = std::atoi(argv[i] + strlen("--height="));
8374
} else if (strstr(argv[i], "--tpkroot=") == argv[i]) {
8475
app_path_ = argv[i] + strlen("--tpkroot=");
8576
}
8677
}
8778

79+
if (app_path_.empty()) {
80+
char path[256];
81+
getcwd(path, sizeof(path));
82+
app_path_ = path + std::string("/tpkroot");
83+
}
84+
8885
ecore_idler_add(
8986
[](void* data) -> Eina_Bool {
9087
FlutterApp* app = (FlutterApp*)data;
@@ -94,6 +91,7 @@ class FlutterApp {
9491
this);
9592
ecore_main_loop_begin();
9693
OnTerminate();
94+
9795
return 0;
9896
}
9997

@@ -107,6 +105,9 @@ class FlutterApp {
107105

108106
private:
109107
std::string app_path_ = {};
108+
int32_t window_width_ = 0;
109+
int32_t window_height_ = 0;
110+
110111
FlutterDesktopEngineRef engine_ = nullptr;
111112
};
112113

shell/platform/tizen/tizen_renderer_evas_gl.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#ifdef __X64_SHELL__
88
#include "tizen_evas_gl_helper.h"
9-
int gApp_width = 800;
10-
int gApp_height = 600;
119
#else
1210
#include <Evas_GL_GLES3_Helpers.h>
1311
#endif
@@ -667,10 +665,6 @@ Evas_Object* TizenRendererEvasGL::SetupEvasWindow(int32_t* width,
667665
int32_t x = initial_geometry_.x;
668666
int32_t y = initial_geometry_.y;
669667

670-
#ifdef __X64_SHELL__
671-
width = gApp_width;
672-
height = gApp_height;
673-
#endif
674668
elm_win_alpha_set(evas_window_, EINA_FALSE);
675669
evas_object_move(evas_window_, x, y);
676670
evas_object_resize(evas_window_, *width, *height);

0 commit comments

Comments
 (0)