tests: add TCs for DSSeat 74/243474/1
authorSung-Jin Park <sj76.park@samsung.com>
Mon, 7 Sep 2020 07:27:30 +0000 (16:27 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 7 Sep 2020 10:53:42 +0000 (19:53 +0900)
Change-Id: I37796ace107edb7763eb433f40fbb888b17f62e0
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
tests/DSSeat-test.cpp

index e20da03..881a66c 100644 (file)
@@ -24,6 +24,7 @@
 #include "libds-tests.h"
 #include "DSSeat.h"
 #include "DSCompositor.h"
+#include "DSZone.h"
 
 using namespace display_server;
 
@@ -76,15 +77,125 @@ TEST_F(DSSeatTest, NewDSSeat)
                delete seat;
 }
 
-TEST_F(DSSeatTest, BasicMethods)
+TEST_F(DSSeatTest, GetName)
 {
        std::string seatName{"default"};
-       std::shared_ptr<DSCompositor> compositor = std::make_shared<MockCompositor>();
+       auto compositor = std::make_shared<MockCompositor>();
        EXPECT_TRUE(compositor != nullptr);
 
        if (compositor)
        {
-               std::shared_ptr<DSSeat> seat = std::make_shared<DSSeat>(compositor.get(), seatName);
+               auto seat = std::make_shared<DSSeat>(compositor.get(), seatName);
                EXPECT_TRUE(seat != nullptr);
+
+               if (seat)
+               {
+                       EXPECT_TRUE(seat->getName().compare(seatName) == 0);
+               }
+       }
+}
+
+TEST_F(DSSeatTest, HasPointerKeyboardTouch)
+{
+       std::string seatName{"default"};
+       auto compositor = std::make_shared<MockCompositor>();
+       EXPECT_TRUE(compositor != nullptr);
+
+       if (compositor)
+       {
+               auto seat = std::make_shared<DSSeat>(compositor.get(), seatName);
+               EXPECT_TRUE(seat != nullptr);
+
+               if (seat)
+               {
+                       seat->addPointer();
+                       seat->addKeyboard();
+                       seat->addTouch();
+
+                       EXPECT_TRUE(seat->hasPointer() == true);
+                       EXPECT_TRUE(seat->hasKeyboard() == true);
+                       EXPECT_TRUE(seat->hasTouch() == true);
+
+                       seat->removePointer();
+                       seat->removeKeyboard();
+                       seat->removeTouch();
+               }
        }
 }
+
+TEST_F(DSSeatTest, AttachGetDetachZone)
+{
+       std::string seatName{"default"};
+       auto compositor = std::make_shared<MockCompositor>();
+       EXPECT_TRUE(compositor != nullptr);
+
+       if (compositor)
+       {
+               auto seat = std::make_shared<DSSeat>(compositor.get(), seatName);
+               EXPECT_TRUE(seat != nullptr);
+
+               if (seat)
+               {
+                       auto zone = std::make_shared<DSZone>();
+                       EXPECT_TRUE(zone != nullptr);
+
+                       if (zone)
+                       {
+                               EXPECT_TRUE(seat->attachZone(zone) == true);
+                               EXPECT_TRUE(seat->getZone().get() == zone.get());
+                               EXPECT_TRUE(seat->detachZone() == true);
+                       }
+               }
+       }
+}
+
+TEST_F(DSSeatTest, GetXKB)
+{
+       std::string seatName{"default"};
+       auto compositor = std::make_shared<MockCompositor>();
+       EXPECT_TRUE(compositor != nullptr);
+
+       if (compositor)
+       {
+               auto seat = std::make_shared<DSSeat>(compositor.get(), seatName);
+               EXPECT_TRUE(seat != nullptr);
+
+               if (seat)
+               {
+                       EXPECT_TRUE(seat->getXkb() != nullptr);
+               }
+       }
+}
+
+TEST_F(DSSeatTest, getTopWindow)
+{
+       std::string seatName{"default"};
+       auto compositor = std::make_shared<MockCompositor>();
+       EXPECT_TRUE(compositor != nullptr);
+
+       if (compositor)
+       {
+               auto seat = std::make_shared<DSSeat>(compositor.get(), seatName);
+               EXPECT_TRUE(seat != nullptr);
+
+               if (seat)
+               {
+                       auto zone = std::make_shared<DSZone>();
+                       EXPECT_TRUE(zone != nullptr);
+
+                       if (zone)
+                       {
+                               EXPECT_TRUE(seat->attachZone(zone) == true);
+
+                               auto winTop = seat->getTopWindow(nullptr);
+                               EXPECT_TRUE(winTop == nullptr);
+
+                               auto winTopOnPosition = seat->getTopWindowOnPosition(100, 100);
+                               EXPECT_TRUE(winTopOnPosition == nullptr);
+
+                               EXPECT_TRUE(seat->detachZone() == true);
+                       }
+               }
+       }
+}
+