--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <watch.hh>
+#include <watch_mirror.hh>
+
+using namespace std;
+using namespace tizen_base;
+using namespace watch_holder;
+
+class WatchMirrorStub : public WatchMirror {
+ public:
+ WatchMirrorStub(Evas_Object* win)
+ : WatchMirror(win) {
+ }
+
+ void OnChanged(const ISharableWatch& watch) override {}
+ void OnAdded(const ISharableWatch& watch) override {}
+ void OnUpdated(const ISharableWatch& watch) override {}
+ void OnRemoved(const ISharableWatch& watch) override {}
+};
+
+class WatchStub : public Watch{
+ public:
+ WatchStub(string appid, Evas_Object* win, WatchMirrorStub* listener)
+ : Watch(appid, win, listener, true) {
+ }
+ WatchStub(int rid, std::string id, string appid, Evas_Object* win, WatchMirrorStub* listener)
+ : Watch(rid, id, appid, win, listener, true) {
+ }
+ WatchStub(string appid, Evas_Object* win, tizen_base::Bundle extra,WatchMirrorStub* listener)
+ : Watch(appid, win, extra, listener, true) {
+ }
+ WatchStub(int rid, std::string id, string appid, Evas_Object* win, tizen_base::Bundle extra, WatchMirrorStub* listener)
+ : Watch(rid, id, appid, win, extra, listener, true) {
+ }
+};
+
+class WatchTest : public ::testing::Test {
+ public:
+ WatchStub* stub;
+ WatchMirrorStub* mirrorstub;
+
+ virtual void SetUp() {
+ Evas_Object* mirwin = elm_win_add(NULL, "Watch Mirror", ELM_WIN_BASIC);
+ mirrorstub = new WatchMirrorStub(mirwin);
+ Evas_Object* win = elm_win_add(NULL, "Watch", ELM_WIN_BASIC);
+ stub = new WatchStub(string("test"), win, mirrorstub);
+ }
+ virtual void TearDown() {
+ delete stub;
+ delete mirrorstub;
+ }
+};
+
+TEST_F(WatchTest, CreateInstance) {
+ EXPECT_NE(WatchTest::stub, nullptr);
+}
+
+TEST_F(WatchTest, CreateInstance2) {
+ Evas_Object* mirwin = elm_win_add(NULL, "Watch Mirror", ELM_WIN_BASIC);
+ WatchMirrorStub* mirrorstub = new WatchMirrorStub(mirwin);
+ Evas_Object* win = elm_win_add(NULL, "Watch", ELM_WIN_BASIC);
+ WatchStub* stub = new WatchStub(0, string("id"), string("test"), win, mirrorstub);
+ EXPECT_NE(stub, nullptr);
+ delete stub;
+ delete mirrorstub;
+}
+
+TEST_F(WatchTest, CreateInstance3) {
+ Bundle b;
+ b.Add("__APP_AMBIENT_EVENT__", "1");
+ b.Add("__APP_AMBIENT_SENDER__", "test");
+ Evas_Object* mirwin = elm_win_add(NULL, "Watch Mirror", ELM_WIN_BASIC);
+ WatchMirrorStub* mirrorstub = new WatchMirrorStub(mirwin);
+ Evas_Object* win = elm_win_add(NULL, "Watch", ELM_WIN_BASIC);
+ WatchStub* stub = new WatchStub(string("test"), win, b, mirrorstub);
+ EXPECT_NE(stub, nullptr);
+ delete stub;
+ delete mirrorstub;
+}
+
+TEST_F(WatchTest, CreateInstance4) {
+ Bundle b;
+ b.Add("__APP_AMBIENT_EVENT__", "1");
+ b.Add("__APP_AMBIENT_SENDER__", "test");
+ Evas_Object* mirwin = elm_win_add(NULL, "Watch Mirror", ELM_WIN_BASIC);
+ WatchMirrorStub* mirrorstub = new WatchMirrorStub(mirwin);
+ Evas_Object* win = elm_win_add(NULL, "Watch", ELM_WIN_BASIC);
+ WatchStub* stub = new WatchStub(0, string("id"), string("test"), win, b,mirrorstub);
+ EXPECT_NE(stub, nullptr);
+ delete stub;
+ delete mirrorstub;
+}
+
+TEST_F(WatchTest, Terminate) {
+ WatchTest::stub->Terminate();
+}
+
+TEST_F(WatchTest, GetPid) {
+ WatchTest::stub->GetPid();
+}
+
+TEST_F(WatchTest, IsBound) {
+ WatchTest::stub->IsBound();
+}
+
+TEST_F(WatchTest, GetAppId) {
+ WatchTest::stub->GetAppId();
+}
+
+TEST_F(WatchTest, GetCurrentImage) {
+ WatchTest::stub->GetCurrentImage();
+}
+
+TEST_F(WatchTest, GetExtra) {
+ WatchTest::stub->GetExtra();
+}
+
+TEST_F(WatchTest, IsFaulted) {
+ WatchTest::stub->IsFaulted();
+}
\ No newline at end of file
using namespace screen_connector;
namespace watch_holder {
-Watch::Watch(string appid, Evas_Object* viewer_win, Watch::IEvent* listener)
+Watch::Watch(string appid, Evas_Object* viewer_win, Watch::IEvent* listener, bool mock)
: RemoteSurfaceEvas(appid, RemoteSurface::WATCH,
- make_shared<screen_connector::EvasObject>(viewer_win, false)),
+ make_shared<screen_connector::EvasObject>(viewer_win, false), mock),
appid_(appid), listener_(listener) {
RemoteSurfaceEvas::SetAutoVisibility(false);
}
-Watch::Watch(int rid, string id, string appid, Evas_Object* viewer_win, Watch::IEvent* listener)
+Watch::Watch(int rid, string id, string appid, Evas_Object* viewer_win, Watch::IEvent* listener, bool mock)
: RemoteSurfaceEvas(rid, id, RemoteSurface::WATCH,
- make_shared<screen_connector::EvasObject>(viewer_win, false)),
+ make_shared<screen_connector::EvasObject>(viewer_win, false), mock),
appid_(appid), listener_(listener) {
RemoteSurfaceEvas::SetAutoVisibility(false);
}
-Watch::Watch(string appid, Evas_Object* viewer_win, tizen_base::Bundle extra, Watch::IEvent* listener)
+Watch::Watch(string appid, Evas_Object* viewer_win, tizen_base::Bundle extra, Watch::IEvent* listener, bool mock)
: RemoteSurfaceEvas(appid, RemoteSurface::WATCH,
- make_shared<screen_connector::EvasObject>(viewer_win, false)),
+ make_shared<screen_connector::EvasObject>(viewer_win, false), mock),
appid_(appid), listener_(listener), extra_data_(extra) {
RemoteSurfaceEvas::SetAutoVisibility(false);
}
-Watch::Watch(int rid, string id, string appid, Evas_Object* viewer_win, tizen_base::Bundle extra, Watch::IEvent* listener)
+Watch::Watch(int rid, string id, string appid, Evas_Object* viewer_win, tizen_base::Bundle extra, Watch::IEvent* listener, bool mock)
: RemoteSurfaceEvas(rid, id, RemoteSurface::WATCH,
- make_shared<screen_connector::EvasObject>(viewer_win, false)),
+ make_shared<screen_connector::EvasObject>(viewer_win, false), mock),
appid_(appid), listener_(listener), extra_data_(extra) {
RemoteSurfaceEvas::SetAutoVisibility(false);
}