From c925d02c0b118300e9a35b53d213c09ea7831085 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 7 Sep 2020 16:27:30 +0900 Subject: [PATCH] tests: add TCs for DSSeat Change-Id: I37796ace107edb7763eb433f40fbb888b17f62e0 Signed-off-by: Sung-Jin Park --- tests/DSSeat-test.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/tests/DSSeat-test.cpp b/tests/DSSeat-test.cpp index e20da03..881a66c 100644 --- a/tests/DSSeat-test.cpp +++ b/tests/DSSeat-test.cpp @@ -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 compositor = std::make_shared(); + auto compositor = std::make_shared(); EXPECT_TRUE(compositor != nullptr); if (compositor) { - std::shared_ptr seat = std::make_shared(compositor.get(), seatName); + auto seat = std::make_shared(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(); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + auto seat = std::make_shared(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(); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + auto seat = std::make_shared(compositor.get(), seatName); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + auto zone = std::make_shared(); + 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(); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + auto seat = std::make_shared(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(); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + auto seat = std::make_shared(compositor.get(), seatName); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + auto zone = std::make_shared(); + 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); + } + } + } +} + -- 2.7.4