BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(ecore-wayland)
+BuildRequires: pkgconfig(gmock)
%description
API for creating a new instance of the widget and managing its life-cycle.
%attr(0644,root,root) %{_libdir}/%{name}_remote_surface_evas.so
+#################################################
+# gtest-screen-connector
+#################################################
+%package -n gtest-screen-connector
+Summary: GTest for screen-connector
+Group: Development/Libraries
+Requires: %{name}_watcher_evas
+
+%description -n gtest-screen-connector
+GTest for screen-connector
+
+%files -n gtest-screen-connector
+%{_bindir}/gtest-screen-connector
+
+
# End of a file
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(gtest-screen-connector CXX)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(gtest-screen-connector REQUIRED
+ glib-2.0
+ gmock
+ aul
+ elementary
+)
+
+FOREACH(flag ${gtest-screen-connector_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+AUX_SOURCE_DIRECTORY(src SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME}
+ ${SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest-screen-connector_LDFLAGS} screen_connector_watcher_evas screen_connector_remote_surface_evas screen_connector_remote_surface)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
--- /dev/null
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <iostream>
+#include <stdbool.h>
+#include <stdexcept>
+#include <glib.h>
+#include "screen_connector_remote_surface/buffer_event_interface.h"
+#include "screen_connector_remote_surface/remote_surface_implementation.h"
+#include "screen_connector_remote_surface/remote_surface.h"
+
+using namespace std;
+using ::testing::AtLeast;
+
+GMainLoop *mainloop = NULL;
+class SimpleRs : public screen_connector::RemoteSurface {
+ public:
+ enum Event {
+ None,
+ Added,
+ Removed,
+ Changed
+ };
+
+ Event curEvent;
+ string curInstId;
+ int curType = -1;
+ SimpleRs(const std::string& id,
+ screen_connector::RemoteSurface::Type type, bool mock, Event evType)
+ : screen_connector::RemoteSurface(id, type, mock), curEvent(evType) {
+ }
+ void OnBufferAdded(const std::string& appId,
+ const std::string& instId, int pid) override {
+ cout << "OnBufferAdded " << instId << endl;
+ if (curEvent == Added && g_main_loop_is_running(mainloop)) {
+ g_main_loop_quit(mainloop);
+ curInstId = instId;
+ cout << "OnBufferAdded done ?? " << curInstId << endl;
+ }
+ }
+ void OnBufferRemoved(const std::string& appId,
+ const std::string& instId, int pid) override {
+
+ cout << "OnBufferRemoved " << instId << endl;
+ if (curEvent == Removed && g_main_loop_is_running(mainloop)) {
+ g_main_loop_quit(mainloop);
+ curInstId = instId;
+ cout << "OnBufferRemoved done ?? " << curInstId << endl;
+ }
+ }
+ void OnBufferChanged(int type, const screen_connector::WlBuffer& tbm, int fd,
+ uint32_t size, uint32_t time) override {
+ cout << "OnBufferChanged event " << type << endl;
+ if (curEvent == Changed && g_main_loop_is_running(mainloop)) {
+ g_main_loop_quit(mainloop);
+ curType = type;
+ cout << "OnBufferChanged event done " << curType << endl;
+ }
+ }
+};
+
+class SCRemoteSurface : public ::testing::Test {
+ public:
+ string testId = "org.tizen.screen_connector.test.appid.instid";
+ void RunMainLoop() {
+ g_main_loop_run(mainloop);
+ }
+ virtual void SetUp() {
+ mainloop = g_main_loop_new(NULL, FALSE);
+ }
+ virtual void TearDown() {
+ g_main_loop_unref(mainloop);
+ mainloop = NULL;
+ }
+};
+
+TEST_F(SCRemoteSurface, SCRemoteSurface_CONST) {
+ SimpleRs *rs = new SimpleRs(testId.c_str(),
+ screen_connector::RemoteSurface::WIDGET, true, SimpleRs::Event::None);
+ EXPECT_NE(rs, nullptr);
+ delete rs;
+}
+
+TEST_F(SCRemoteSurface, SCRemoteSurface_ADDED) {
+ SimpleRs *rs = new SimpleRs(testId.c_str(),
+ screen_connector::RemoteSurface::WIDGET, true, SimpleRs::Event::Added);
+ RunMainLoop();
+ EXPECT_EQ(testId, rs->curInstId);
+ delete rs;
+}
+
+TEST_F(SCRemoteSurface, SCRemoteSurface_CHANGED) {
+ SimpleRs *rs = new SimpleRs(testId.c_str(),
+ screen_connector::RemoteSurface::WIDGET, true, SimpleRs::Event::Changed);
+ RunMainLoop();
+ EXPECT_EQ(TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM, rs->curType);
+ delete rs;
+}
+
+TEST_F(SCRemoteSurface, SCRemoteSurface_REMOVED) {
+ SimpleRs *rs = new SimpleRs(testId.c_str(),
+ screen_connector::RemoteSurface::WIDGET, true, SimpleRs::Event::Removed);
+ RunMainLoop();
+ EXPECT_EQ(testId, rs->curInstId);
+ delete rs;
+}