Skip to content

Commit

Permalink
Add flutter_tizen_engine TC
Browse files Browse the repository at this point in the history
Signed-off-by: MuHong Byun <mh.byun@samsung.com>
  • Loading branch information
bwikbs committed Jun 29, 2021
1 parent ab269c7 commit 803d7d5
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 112 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import("//flutter/common/config.gni")
import("//flutter/shell/platform/config.gni")
import("//flutter/shell/platform/glfw/config.gni")
import("//flutter/testing/testing.gni")
import("//flutter/shell/platform/tizen/config.gni")
import("//flutter/testing/testing.gni")

# Whether to build the dartdevc sdk, libraries, and source files
# required for the flutter web sdk.
Expand Down
133 changes: 53 additions & 80 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import("//flutter/shell/platform/common/client_wrapper/publish.gni")
import("//flutter/shell/platform/config.gni")
import("//flutter/shell/platform/tizen/config.gni")
import("//flutter/testing/testing.gni")

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

_flutter_tizen_source = [
"channels/key_event_channel.cc",
"channels/lifecycle_channel.cc",
"channels/localization_channel.cc",
"channels/navigation_channel.cc",
"channels/platform_channel.cc",
"channels/platform_view_channel.cc",
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"external_texture_pixel_gl.cc",
"external_texture_surface_gl.cc",
"flutter_tizen.cc",
"flutter_tizen_engine.cc",
"flutter_tizen_texture_registrar.cc",
"key_event_handler.cc",
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"touch_event_handler.cc",
]

_libs_minimum = [
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"evas",
"EGL",
"GLESv2",
"wayland-client",
]

_public_headers = [
"public/flutter_platform_view.h",
"public/flutter_tizen.h",
Expand Down Expand Up @@ -92,56 +125,19 @@ template("embedder_for_profile") {
shared_library("flutter_tizen_${target_name}") {
public = _public_headers

sources = [
"channels/key_event_channel.cc",
"channels/lifecycle_channel.cc",
"channels/localization_channel.cc",
"channels/navigation_channel.cc",
"channels/platform_channel.cc",
"channels/platform_view_channel.cc",
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"external_texture_pixel_gl.cc",
"external_texture_surface_gl.cc",
"flutter_tizen.cc",
"flutter_tizen_engine.cc",
"flutter_tizen_texture_registrar.cc",
"key_event_handler.cc",
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"touch_event_handler.cc",
]
sources = _flutter_tizen_source
libs = _libs_minimum
if (!enable_desktop_embeddings) {
libs = [
libs += [
"base-utils-i18n",
"capi-appfw-application",
"capi-base-common",
"capi-system-info",
"capi-system-system-settings",
"dlog",
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"evas",
"EGL",
"feedback",
"GLESv2",
"tbm",
"tdm-client",
"wayland-client",
]
} else {
libs = [
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"evas",
"EGL",
"GLESv2",
"wayland-client",
]
}

Expand Down Expand Up @@ -217,44 +213,17 @@ embedder_for_profile("common") {
defines = [ "COMMON_PROFILE" ]
}

test_fixtures("flutter_tizen_fixtures") {
fixtures = []
}

executable("flutter_tizen_unittests") {
testonly = true
public = _public_headers
sources = [
"channels/key_event_channel.cc",
"channels/lifecycle_channel.cc",
"channels/localization_channel.cc",
"channels/navigation_channel.cc",
"channels/platform_channel.cc",
"channels/platform_view_channel.cc",
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"external_texture_pixel_gl.cc",
"external_texture_surface_gl.cc",
"flutter_tizen.cc",
"flutter_tizen_engine.cc",
"flutter_tizen_texture_registrar.cc",
"key_event_handler.cc",
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"touch_event_handler.cc",
"flutter_tizen_engine_test.cc",
]

libs = [
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"evas",
"EGL",
"GLESv2",
"wayland-client",
]

sources = _flutter_tizen_source
sources += [ "tizen_renderer_evas_gl.cc" ]

sources += [ "flutter_tizen_engine_test.cc" ]
libs = _libs_minimum
libs += [
"ecore_evas",
"elementary",
Expand All @@ -265,22 +234,26 @@ executable("flutter_tizen_unittests") {
"-Wno-newline-eof",
"-Wno-macro-redefined",
]

public_configs = [ "//flutter:config" ]
configs += [
":tizen_rootstrap_include_dirs",
"//flutter/shell/platform/common:desktop_library_implementation",
]

public_configs = [ "//flutter:config" ]

public_deps = [
":flutter_engine",
"//third_party/googletest:gtest",
]
":flutter_engine",
"//third_party/googletest:gtest",
]
deps = [
":flutter_tizen_fixtures",
"//flutter/runtime:libdart",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/common:common_cpp_library_headers",
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:embedder_headers",
"//flutter/shell/platform/embedder:embedder_test_utils",
"//flutter/testing",
"//third_party/rapidjson",
]
}
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
#ifdef WEARABLE_PROFILE
// Hardware keyboard not supported on watches.
bool is_ime = true;
#elif __X64_SHELL__
bool is_ime = false;
#else
bool is_ime = strcmp(ecore_device_name_get(event->dev), "ime") == 0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static DeviceProfile GetDeviceProfile() {
system_info_get_platform_string("http://tizen.org/feature/profile",
&feature_profile);
#else
feature_profile = (char*)("pc");
return DeviceProfile::kUnknown;
#endif
std::string profile(feature_profile);
free(feature_profile);
Expand Down
148 changes: 118 additions & 30 deletions shell/platform/tizen/flutter_tizen_engine_test.cc
Original file line number Diff line number Diff line change
@@ -1,40 +1,128 @@
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Included first as it collides with the X11 headers.
#include <unistd.h>
#include <chrono>
#include <thread>
#include "gtest/gtest.h"

// #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h"
#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
// #include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/tizen/channels/key_event_channel.h"
#include "flutter/shell/platform/tizen/channels/lifecycle_channel.h"
#include "flutter/shell/platform/tizen/channels/localization_channel.h"
#include "flutter/shell/platform/tizen/channels/navigation_channel.h"
#include "flutter/shell/platform/tizen/channels/platform_channel.h"
#include "flutter/shell/platform/tizen/channels/platform_view_channel.h"
#include "flutter/shell/platform/tizen/channels/settings_channel.h"
#include "flutter/shell/platform/tizen/channels/text_input_channel.h"
#include "flutter/shell/platform/tizen/flutter_tizen_texture_registrar.h"
#include "flutter/shell/platform/tizen/key_event_handler.h"
#include "flutter/shell/platform/tizen/public/flutter_tizen.h"
#include "flutter/shell/platform/tizen/tizen_event_loop.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#ifdef TIZEN_RENDERER_EVAS_GL
#include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h"
#else
#include "flutter/shell/platform/tizen/tizen_renderer_ecore_wl2.h"
#include "flutter/shell/platform/tizen/tizen_vsync_waiter.h"
#endif
#include "flutter/shell/platform/tizen/touch_event_handler.h"


TEST(FlutterTizenEngineTest, Test1) {
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"

using namespace std::chrono_literals;

std::string TPK_ROOT_PATH = "/tpkroot";
std::string LIB_PATH = "/lib";
std::string RES_PATH = "/res";

TEST(FlutterTizenEngineTestSimple, Create_Headless) {
flutter::FlutterTizenEngine* tizen_engine =
new flutter::FlutterTizenEngine(false);
EXPECT_TRUE(tizen_engine != nullptr);
delete tizen_engine;
}

// TODO
TEST(FlutterTizenEngineTestSimple, DISABLED_Create_Headed) {
flutter::FlutterTizenEngine* tizen_engine =
new flutter::FlutterTizenEngine(true);
EXPECT_TRUE(tizen_engine != nullptr);
delete tizen_engine;
}

class FlutterTizenEngineTest : public testing::Test {
public:
FlutterTizenEngineTest() {
std::string tpk_root;
char path[256];
EXPECT_TRUE(getcwd(path, sizeof(path)) != NULL);
tpk_root = path + TPK_ROOT_PATH;

assets_path = tpk_root + RES_PATH + "/flutter_assets";
icu_data_path = tpk_root + RES_PATH + "/icudtl.dat";
aot_lib_path = tpk_root + LIB_PATH + "/libapp.so";

switches.push_back("--disable-observatory");
// switches.push_back("--verbose-logging");
// switches.push_back("--enable-dart-profiling");
// switches.push_back("--enable-checked-mode");
}

protected:
void SetUp() {
engine_prop.assets_path = assets_path.c_str();
engine_prop.icu_data_path = icu_data_path.c_str();
engine_prop.aot_library_path = aot_lib_path.c_str();
engine_prop.switches = switches.data();
engine_prop.switches_count = switches.size();

auto engine = std::make_unique<flutter::FlutterTizenEngine>(false);
engine_ = engine.release();
}

void TearDown() {
if (engine_) {
delete engine_;
}
engine_ = nullptr;
}

std::string assets_path;
std::string icu_data_path;
std::string aot_lib_path;
flutter::FlutterTizenEngine* engine_;
FlutterDesktopEngineProperties engine_prop = {};
std::vector<const char*> switches;
};

TEST_F(FlutterTizenEngineTest, Run) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->RunEngine(engine_prop));
// TODO : FIXME
std::this_thread::sleep_for(1s);
EXPECT_TRUE(true);
}

TEST(FlutterTizenEngineTest, Test2) {
// TODO
TEST_F(FlutterTizenEngineTest, DISABLED_Run_Twice) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->RunEngine(engine_prop));
// TODO : FIXME
std::this_thread::sleep_for(1s);

EXPECT_FALSE(engine_->RunEngine(engine_prop));
std::this_thread::sleep_for(1s);

EXPECT_TRUE(true);
}
}

TEST_F(FlutterTizenEngineTest, Stop) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->RunEngine(engine_prop));
// TODO : FIXME
std::this_thread::sleep_for(1s);

EXPECT_TRUE(engine_->StopEngine());
}

TEST_F(FlutterTizenEngineTest, Stop_Twice) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->RunEngine(engine_prop));
// TODO : FIXME
std::this_thread::sleep_for(1s);

EXPECT_TRUE(engine_->StopEngine());
EXPECT_FALSE(engine_->StopEngine());
}

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

// TODO
TEST_F(FlutterTizenEngineTest, DISABLED_GetTextureRegistrar) {
EXPECT_TRUE(engine_ != nullptr);
EXPECT_TRUE(engine_->GetTextureRegistrar() != nullptr);
}
3 changes: 3 additions & 0 deletions shell/platform/tizen/tizen_event_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id,
TaskExpiredCallback on_task_expired)
: main_thread_id_(main_thread_id),
on_task_expired_(std::move(on_task_expired)) {
#ifdef __X64_SHELL__
ecore_init();
#endif
ecore_pipe_ = ecore_pipe_add(ExcuteTaskEvents, this);
}

Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_event_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TizenEventLoop {
TizenEventLoop& operator=(const TizenEventLoop&) = delete;

static void ExcuteTaskEvents(void* data, void* buffer, unsigned int nbyte);

static Eina_Bool TaskTimerCallback(void* data);

static TaskTimePoint TimePointFromFlutterTime(
Expand Down

0 comments on commit 803d7d5

Please sign in to comment.