Skip to content

Commit 66599c2

Browse files
committed
Add flutter_tizen_engine TC
Signed-off-by: MuHong Byun <mh.byun@samsung.com>
1 parent c91fc4c commit 66599c2

File tree

7 files changed

+178
-111
lines changed

7 files changed

+178
-111
lines changed

BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import("//flutter/common/config.gni")
66
import("//flutter/shell/platform/config.gni")
77
import("//flutter/shell/platform/glfw/config.gni")
8-
import("//flutter/testing/testing.gni")
98
import("//flutter/shell/platform/tizen/config.gni")
9+
import("//flutter/testing/testing.gni")
1010

1111
# Whether to build the dartdevc sdk, libraries, and source files
1212
# required for the flutter web sdk.

shell/platform/tizen/BUILD.gn

Lines changed: 52 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import("//flutter/shell/platform/common/client_wrapper/publish.gni")
66
import("//flutter/shell/platform/config.gni")
77
import("//flutter/shell/platform/tizen/config.gni")
8+
import("//flutter/testing/testing.gni")
89

910
# Sets the rpath of dependent targets (shared libs) to $ORIGIN.
1011
# We assume that the flutter_engine library exists next to the embedder library
@@ -25,6 +26,37 @@ source_set("flutter_engine") {
2526
deps = [ "//flutter/shell/platform/embedder:flutter_engine" ]
2627
}
2728

29+
_flutter_tizen_source = [
30+
"channels/key_event_channel.cc",
31+
"channels/lifecycle_channel.cc",
32+
"channels/localization_channel.cc",
33+
"channels/navigation_channel.cc",
34+
"channels/platform_channel.cc",
35+
"channels/platform_view_channel.cc",
36+
"channels/settings_channel.cc",
37+
"channels/text_input_channel.cc",
38+
"external_texture_pixel_gl.cc",
39+
"external_texture_surface_gl.cc",
40+
"flutter_tizen.cc",
41+
"flutter_tizen_engine.cc",
42+
"flutter_tizen_texture_registrar.cc",
43+
"key_event_handler.cc",
44+
"tizen_event_loop.cc",
45+
"tizen_log.cc",
46+
"tizen_renderer.cc",
47+
"touch_event_handler.cc",
48+
]
49+
50+
_libs_minimum = [
51+
"ecore",
52+
"ecore_imf",
53+
"ecore_input",
54+
"eina",
55+
"EGL",
56+
"GLESv2",
57+
"wayland-client",
58+
]
59+
2860
_public_headers = [
2961
"public/flutter_platform_view.h",
3062
"public/flutter_tizen.h",
@@ -72,7 +104,6 @@ config("tizen_rootstrap_include_dirs") {
72104
local_prefix + "/include/elementary-1",
73105
local_prefix + "/include/ethumb-1",
74106
local_prefix + "/include/ethumb-client-1",
75-
local_prefix + "/include/evas-1",
76107
]
77108
lib_dirs = [ local_prefix + "/lib" ]
78109
}
@@ -92,54 +123,19 @@ template("embedder_for_profile") {
92123
shared_library("flutter_tizen_${target_name}") {
93124
public = _public_headers
94125

95-
sources = [
96-
"channels/key_event_channel.cc",
97-
"channels/lifecycle_channel.cc",
98-
"channels/localization_channel.cc",
99-
"channels/navigation_channel.cc",
100-
"channels/platform_channel.cc",
101-
"channels/platform_view_channel.cc",
102-
"channels/settings_channel.cc",
103-
"channels/text_input_channel.cc",
104-
"external_texture_pixel_gl.cc",
105-
"external_texture_surface_gl.cc",
106-
"flutter_tizen.cc",
107-
"flutter_tizen_engine.cc",
108-
"flutter_tizen_texture_registrar.cc",
109-
"key_event_handler.cc",
110-
"tizen_event_loop.cc",
111-
"tizen_log.cc",
112-
"tizen_renderer.cc",
113-
"touch_event_handler.cc",
114-
]
126+
sources = _flutter_tizen_source
127+
libs = _libs_minimum
115128
if (!enable_desktop_embeddings) {
116-
libs = [
129+
libs += [
117130
"base-utils-i18n",
118131
"capi-appfw-application",
119132
"capi-base-common",
120133
"capi-system-info",
121134
"capi-system-system-settings",
122135
"dlog",
123-
"ecore",
124-
"ecore_imf",
125-
"ecore_input",
126-
"eina",
127-
"EGL",
128136
"feedback",
129-
"GLESv2",
130137
"tbm",
131138
"tdm-client",
132-
"wayland-client",
133-
]
134-
} else {
135-
libs = [
136-
"ecore",
137-
"ecore_imf",
138-
"ecore_input",
139-
"eina",
140-
"EGL",
141-
"GLESv2",
142-
"wayland-client",
143139
]
144140
}
145141

@@ -217,44 +213,17 @@ embedder_for_profile("common") {
217213
defines = [ "COMMON_PROFILE" ]
218214
}
219215

216+
test_fixtures("flutter_tizen_fixtures") {
217+
fixtures = []
218+
}
219+
220220
executable("flutter_tizen_unittests") {
221221
testonly = true
222222
public = _public_headers
223-
sources = [
224-
"channels/key_event_channel.cc",
225-
"channels/lifecycle_channel.cc",
226-
"channels/localization_channel.cc",
227-
"channels/navigation_channel.cc",
228-
"channels/platform_channel.cc",
229-
"channels/platform_view_channel.cc",
230-
"channels/settings_channel.cc",
231-
"channels/text_input_channel.cc",
232-
"external_texture_pixel_gl.cc",
233-
"external_texture_surface_gl.cc",
234-
"flutter_tizen.cc",
235-
"flutter_tizen_engine.cc",
236-
"flutter_tizen_texture_registrar.cc",
237-
"key_event_handler.cc",
238-
"tizen_event_loop.cc",
239-
"tizen_log.cc",
240-
"tizen_renderer.cc",
241-
"touch_event_handler.cc",
242-
"flutter_tizen_engine_test.cc",
243-
]
244-
245-
libs = [
246-
"ecore",
247-
"ecore_imf",
248-
"ecore_input",
249-
"eina",
250-
"evas",
251-
"EGL",
252-
"GLESv2",
253-
"wayland-client",
254-
]
255-
223+
sources = _flutter_tizen_source
256224
sources += [ "tizen_renderer_evas_gl.cc" ]
257-
225+
sources += [ "flutter_tizen_engine_test.cc" ]
226+
libs = _libs_minimum
258227
libs += [
259228
"ecore_evas",
260229
"elementary",
@@ -265,22 +234,26 @@ executable("flutter_tizen_unittests") {
265234
"-Wno-newline-eof",
266235
"-Wno-macro-redefined",
267236
]
237+
238+
public_configs = [ "//flutter:config" ]
268239
configs += [
269240
":tizen_rootstrap_include_dirs",
270241
"//flutter/shell/platform/common:desktop_library_implementation",
271242
]
272-
273-
public_configs = [ "//flutter:config" ]
274-
275243
public_deps = [
276-
":flutter_engine",
277-
"//third_party/googletest:gtest",
278-
]
244+
":flutter_engine",
245+
"//third_party/googletest:gtest",
246+
]
279247
deps = [
248+
":flutter_tizen_fixtures",
249+
"//flutter/runtime:libdart",
280250
"//flutter/shell/platform/common:common_cpp",
281251
"//flutter/shell/platform/common:common_cpp_input",
282252
"//flutter/shell/platform/common:common_cpp_library_headers",
283253
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
254+
"//flutter/shell/platform/embedder:embedder_headers",
255+
"//flutter/shell/platform/embedder:embedder_test_utils",
256+
"//flutter/testing",
284257
"//third_party/rapidjson",
285258
]
286259
}

shell/platform/tizen/channels/text_input_channel.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
409409
#ifdef WEARABLE_PROFILE
410410
// Hardware keyboard not supported on watches.
411411
bool is_ime = true;
412+
#elif __X64_SHELL__
413+
bool is_ime = false;
412414
#else
413415
bool is_ime = strcmp(ecore_device_name_get(event->dev), "ime") == 0;
414416
#endif

shell/platform/tizen/flutter_tizen_engine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static DeviceProfile GetDeviceProfile() {
2929
system_info_get_platform_string("http://tizen.org/feature/profile",
3030
&feature_profile);
3131
#else
32-
feature_profile = (char*)("pc");
32+
return DeviceProfile::kUnknown;
3333
#endif
3434
std::string profile(feature_profile);
3535
free(feature_profile);
Lines changed: 118 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,128 @@
1+
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
12
// Copyright 2013 The Flutter Authors. All rights reserved.
23
// Use of this source code is governed by a BSD-style license that can be
34
// found in the LICENSE file.
45

5-
// Included first as it collides with the X11 headers.
6+
#include <unistd.h>
7+
#include <chrono>
8+
#include <thread>
69
#include "gtest/gtest.h"
710

8-
// #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
9-
#include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h"
10-
#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
11-
// #include "flutter/shell/platform/embedder/embedder.h"
12-
#include "flutter/shell/platform/tizen/channels/key_event_channel.h"
13-
#include "flutter/shell/platform/tizen/channels/lifecycle_channel.h"
14-
#include "flutter/shell/platform/tizen/channels/localization_channel.h"
15-
#include "flutter/shell/platform/tizen/channels/navigation_channel.h"
16-
#include "flutter/shell/platform/tizen/channels/platform_channel.h"
17-
#include "flutter/shell/platform/tizen/channels/platform_view_channel.h"
18-
#include "flutter/shell/platform/tizen/channels/settings_channel.h"
19-
#include "flutter/shell/platform/tizen/channels/text_input_channel.h"
20-
#include "flutter/shell/platform/tizen/flutter_tizen_texture_registrar.h"
21-
#include "flutter/shell/platform/tizen/key_event_handler.h"
22-
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
23-
#include "flutter/shell/platform/tizen/tizen_event_loop.h"
24-
#include "flutter/shell/platform/tizen/tizen_renderer.h"
25-
#ifdef TIZEN_RENDERER_EVAS_GL
26-
#include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h"
27-
#else
28-
#include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h"
29-
#include "flutter/shell/platform/tizen/tizen_vsync_waiter.h"
30-
#endif
31-
#include "flutter/shell/platform/tizen/touch_event_handler.h"
32-
33-
34-
TEST(FlutterTizenEngineTest, Test1) {
11+
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
12+
13+
using namespace std::chrono_literals;
14+
15+
std::string TPK_ROOT_PATH = "/tpkroot";
16+
std::string LIB_PATH = "/lib";
17+
std::string RES_PATH = "/res";
18+
19+
TEST(FlutterTizenEngineTestSimple, Create_Headless) {
20+
flutter::FlutterTizenEngine* tizen_engine =
21+
new flutter::FlutterTizenEngine(false);
22+
EXPECT_TRUE(tizen_engine != nullptr);
23+
delete tizen_engine;
24+
}
25+
26+
// TODO
27+
TEST(FlutterTizenEngineTestSimple, DISABLED_Create_Headed) {
28+
flutter::FlutterTizenEngine* tizen_engine =
29+
new flutter::FlutterTizenEngine(true);
30+
EXPECT_TRUE(tizen_engine != nullptr);
31+
delete tizen_engine;
32+
}
33+
34+
class FlutterTizenEngineTest : public testing::Test {
35+
public:
36+
FlutterTizenEngineTest() {
37+
std::string tpk_root;
38+
char path[256];
39+
EXPECT_TRUE(getcwd(path, sizeof(path)) != NULL);
40+
tpk_root = path + TPK_ROOT_PATH;
41+
42+
assets_path = tpk_root + RES_PATH + "/flutter_assets";
43+
icu_data_path = tpk_root + RES_PATH + "/icudtl.dat";
44+
aot_lib_path = tpk_root + LIB_PATH + "/libapp.so";
45+
46+
switches.push_back("--disable-observatory");
47+
// switches.push_back("--verbose-logging");
48+
// switches.push_back("--enable-dart-profiling");
49+
// switches.push_back("--enable-checked-mode");
50+
}
51+
52+
protected:
53+
void SetUp() {
54+
engine_prop.assets_path = assets_path.c_str();
55+
engine_prop.icu_data_path = icu_data_path.c_str();
56+
engine_prop.aot_library_path = aot_lib_path.c_str();
57+
engine_prop.switches = switches.data();
58+
engine_prop.switches_count = switches.size();
59+
60+
auto engine = std::make_unique<flutter::FlutterTizenEngine>(false);
61+
engine_ = engine.release();
62+
}
63+
64+
void TearDown() {
65+
if (engine_) {
66+
delete engine_;
67+
}
68+
engine_ = nullptr;
69+
}
70+
71+
std::string assets_path;
72+
std::string icu_data_path;
73+
std::string aot_lib_path;
74+
flutter::FlutterTizenEngine* engine_;
75+
FlutterDesktopEngineProperties engine_prop = {};
76+
std::vector<const char*> switches;
77+
};
78+
79+
TEST_F(FlutterTizenEngineTest, Run) {
80+
EXPECT_TRUE(engine_ != nullptr);
81+
EXPECT_TRUE(engine_->RunEngine(engine_prop));
82+
// TODO : FIXME
83+
std::this_thread::sleep_for(1s);
3584
EXPECT_TRUE(true);
3685
}
3786

38-
TEST(FlutterTizenEngineTest, Test2) {
87+
// TODO
88+
TEST_F(FlutterTizenEngineTest, DISABLED_Run_Twice) {
89+
EXPECT_TRUE(engine_ != nullptr);
90+
EXPECT_TRUE(engine_->RunEngine(engine_prop));
91+
// TODO : FIXME
92+
std::this_thread::sleep_for(1s);
93+
94+
EXPECT_FALSE(engine_->RunEngine(engine_prop));
95+
std::this_thread::sleep_for(1s);
96+
3997
EXPECT_TRUE(true);
40-
}
98+
}
99+
100+
TEST_F(FlutterTizenEngineTest, Stop) {
101+
EXPECT_TRUE(engine_ != nullptr);
102+
EXPECT_TRUE(engine_->RunEngine(engine_prop));
103+
// TODO : FIXME
104+
std::this_thread::sleep_for(1s);
105+
106+
EXPECT_TRUE(engine_->StopEngine());
107+
}
108+
109+
TEST_F(FlutterTizenEngineTest, Stop_Twice) {
110+
EXPECT_TRUE(engine_ != nullptr);
111+
EXPECT_TRUE(engine_->RunEngine(engine_prop));
112+
// TODO : FIXME
113+
std::this_thread::sleep_for(1s);
114+
115+
EXPECT_TRUE(engine_->StopEngine());
116+
EXPECT_FALSE(engine_->StopEngine());
117+
}
118+
119+
TEST_F(FlutterTizenEngineTest, GetPluginRegistrar) {
120+
EXPECT_TRUE(engine_ != nullptr);
121+
EXPECT_TRUE(engine_->GetPluginRegistrar() != nullptr);
122+
}
123+
124+
// TODO
125+
TEST_F(FlutterTizenEngineTest, DISABLED_GetTextureRegistrar) {
126+
EXPECT_TRUE(engine_ != nullptr);
127+
EXPECT_TRUE(engine_->GetTextureRegistrar() != nullptr);
128+
}

shell/platform/tizen/tizen_event_loop.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id,
1818
TaskExpiredCallback on_task_expired)
1919
: main_thread_id_(main_thread_id),
2020
on_task_expired_(std::move(on_task_expired)) {
21+
#ifdef __X64_SHELL__
22+
ecore_init();
23+
#endif
2124
ecore_pipe_ = ecore_pipe_add(ExcuteTaskEvents, this);
2225
}
2326

0 commit comments

Comments
 (0)