X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Ftest.cpp;h=6fad4bfd177d946342f4c9e41224b9659f276030;hb=81a6d5f63b77f2ffaeef25cea30d2ecc486c7426;hp=a4e630ccd34870ef8573bbcc77c8625fc8939113;hpb=0602a4156ef549a2a229ba32b141f508230b43ad;p=apps%2Fagl-service-windowmanager.git diff --git a/test/test.cpp b/test/test.cpp index a4e630c..6fad4bf 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,12 +1,10 @@ #include -//#include "cpputest/include/CppUTest/CommandLineTestRunner.h" #include #include #include "applist.hpp" -#include "wm-client.hpp" +#include "wm_client.hpp" +#include "wm_error.hpp" -// テストグループの定義 TEST_GROUP(group) -// フィクスチャの準備 using std::cout; using std::endl; using std::string; @@ -17,10 +15,21 @@ namespace const string test1 = "testApp"; const string test2 = "testApp2"; const string test3 = "testApp3"; -const string test_role = "testRole"; -const string test_area = "testArea"; +const string test_role1 = "testRole1"; +const string test_role2 = "testRole2"; +const string test_role3 = "testRole3"; +const string test_area1 = "testArea1"; +const string test_area2 = "testArea2"; +const string test_area3 = "testArea3"; const string test1_errname = "testApp_false"; const string test_role_err = "testRole_false"; +const string test_area_err = "testRole_false"; + +const unsigned test_surface1 = 1; +const unsigned test_surface2 = 2; +const unsigned test_surface3 = 3; +const unsigned test_layer = 1; + static wm::AppList app_list; class dbtest : public ::testing::Test @@ -28,20 +37,29 @@ class dbtest : public ::testing::Test public: void SetUp() {} void TearDown() {} + void createTestClient(){ + app_list.addClient(test1, test_layer, test_surface1, test_role1); + app_list.addClient(test2, test_layer, test_surface2, test_role2); + app_list.addClient(test3, test_layer, test_surface3, test_role2); + } protected: }; -TEST_F(dbtest, contains) +TEST_F(dbtest, add_and_contains_client) { - app_list.addClient(test1, test_role); + app_list.addClient(test1, test_layer, test_surface1, test_role1); + app_list.addClient(test2, test_layer, test_surface2, test_role2); + app_list.addClient(test3, test_layer, test_surface3, test_role2); bool result = app_list.contains(test1); EXPECT_EQ(true, result); + result = app_list.contains(test2); + EXPECT_EQ(true, result); result = app_list.contains(test1_errname); EXPECT_EQ(false, result); } -TEST_F(dbtest, lookup) +TEST_F(dbtest, lookup_client) { auto test = app_list.lookUpClient(test1); cout << "Check getting client object" << endl; @@ -50,15 +68,70 @@ TEST_F(dbtest, lookup) EXPECT_EQ(test1, test->appID()); cout << "Check exception throwing of out_of_range" << endl; ASSERT_THROW(app_list.lookUpClient(test1_errname), std::out_of_range); - app_list.client_dump(); + app_list.clientDump(); +} + +TEST_F(dbtest, get_app_id) +{ + bool found = false; + string appid = app_list.getAppID(test_surface1, test_role1, &found); + EXPECT_EQ(true, found); + EXPECT_EQ(test1, appid); + appid = app_list.getAppID(test_surface2, test_role1, &found); + EXPECT_EQ(false, found); + EXPECT_EQ("", appid); } -TEST_F(dbtest, remove) +TEST_F(dbtest, remove_surface) +{ + bool ret = app_list.contains(test1); + EXPECT_EQ(true, ret); + auto client = app_list.lookUpClient(test1); + unsigned surface = client->surfaceID(test_role1); + EXPECT_NE(0, surface); + app_list.removeSurface(test_surface1); + surface = client->surfaceID(test_role1); + EXPECT_EQ(0, surface); +} + +TEST_F(dbtest, remove_client) { ASSERT_NO_THROW(app_list.removeClient(test1_errname)); ASSERT_NO_THROW(app_list.removeClient(test1)); - EXPECT_EQ(0, app_list.countClient()); - app_list.addClient(test1, test_role); + EXPECT_EQ(2, app_list.countClient()); +} + +TEST_F(dbtest, cl_get_function) +{ + bool ret = app_list.contains(test2); + EXPECT_EQ(true, ret); + auto client = app_list.lookUpClient(test2); + EXPECT_EQ(test2, client->appID()); + EXPECT_EQ(test_surface2, client->surfaceID(test_role2)); + EXPECT_EQ(test_layer, client->layerID()); + EXPECT_EQ(test_role2, client->role(test_surface2)); + unsigned layer2 = 1000; + client->registerLayer(layer2); + EXPECT_EQ(layer2, client->layerID()); + unsigned surface_1000 = 1000; + client->addSurface(test_role3, surface_1000); + EXPECT_EQ(test_surface2, client->surfaceID(test_role2)); + EXPECT_EQ(surface_1000, client->surfaceID(test_role3)); +} + +TEST_F(dbtest, cl_remove_function) +{ + bool ret = app_list.contains(test2); + EXPECT_EQ(true, ret); + auto client = app_list.lookUpClient(test2); + EXPECT_EQ(false, client->removeSurfaceIfExist(test_surface1)); + EXPECT_EQ(true, client->removeSurfaceIfExist(test_surface2)); + EXPECT_EQ(false, client->removeRole(test_role1)); + EXPECT_EQ(true, client->removeRole(test_role3)); + app_list.removeClient(test2); + app_list.removeClient(test3); + app_list.clientDump(); + this->createTestClient(); } class reqtest : public ::testing::Test @@ -70,74 +143,72 @@ public: protected: }; -TEST_F(reqtest, currentSequenceNumber) +TEST_F(reqtest, currentRequestNumber) { - EXPECT_EQ(1, app_list.currentSequenceNumber()); + EXPECT_EQ(1, app_list.currentRequestNumber()); } -TEST_F(reqtest, allocate_sequence) +TEST_F(reqtest, 3_allocate_sequence) { - app_list.addClient(test2, test_role); - - wm::WMRequest req1(test1, test_role, test_area, wm::Task::TASK_ALLOCATE); - wm::WMRequest req2(test2, test_role, test_area, wm::Task::TASK_RELEASE); - unsigned seq1 = app_list.addAllocateRequest(req1); - unsigned seq2 = app_list.addAllocateRequest(req2); - - unsigned current = app_list.currentSequenceNumber(); + wm::WMRequest req1(test1, test_role1, test_area1, wm::Task::TASK_ALLOCATE); + wm::WMRequest req2(test2, test_role2, test_area2, wm::Task::TASK_RELEASE); + wm::WMRequest req3(test3, test_role3, test_area3, wm::Task::TASK_ALLOCATE); + unsigned seq1 = app_list.addRequest(req1); + unsigned seq2 = app_list.addRequest(req2); + unsigned seq3 = app_list.addRequest(req3); + bool found = false; + bool result = false; + + unsigned current = app_list.currentRequestNumber(); EXPECT_EQ(1, current); EXPECT_EQ(1, seq1); EXPECT_EQ(2, seq2); + EXPECT_EQ(3, seq3); - bool result = app_list.requestFinished(); - EXPECT_EQ(false, result); - - auto trg = app_list.getRequest(seq1); + auto trg = app_list.getRequest(seq1, &found); + EXPECT_EQ(true, found); - result = app_list.setAction(seq1, trg.appid, trg.role, trg.area); - result &= app_list.setAction(seq1, test3, test_role, test_area); - EXPECT_EQ(true, result); + wm::WMError werr = app_list.setAction(seq1, trg.appid, trg.role, trg.area, wm::TaskVisible::VISIBLE); + wm::WMError werr_sub = app_list.setAction(seq1, test3, test_role1, test_area3, wm::TaskVisible::VISIBLE); + EXPECT_EQ(wm::WMError::SUCCESS, werr); + EXPECT_EQ(wm::WMError::SUCCESS, werr_sub); - app_list.req_dump(); + app_list.reqDump(); - result = app_list.setEndDrawFinished(current, test1, test_role); + result = app_list.setEndDrawFinished(current, test1, test_role1); EXPECT_EQ(true, result); result = app_list.endDrawFullfilled(current); EXPECT_EQ(false, result); - result = app_list.setEndDrawFinished(current, test3, test_role); + result = app_list.setEndDrawFinished(current, test3, test_role1); EXPECT_EQ(true, result); - app_list.req_dump(); + app_list.reqDump(); result = app_list.endDrawFullfilled(current); EXPECT_EQ(true, result); - auto actions = app_list.getActions(current); + auto actions = app_list.getActions(current, &found); + EXPECT_EQ(true, found); EXPECT_EQ(test1, actions[0].appid); - EXPECT_EQ(test_role, actions[0].role); - EXPECT_EQ(test_area, actions[0].area); + EXPECT_EQ(test_role1, actions[0].role); + EXPECT_EQ(test_area1, actions[0].area); EXPECT_EQ(test3, actions[1].appid); - EXPECT_EQ(test_role, actions[1].role); - EXPECT_EQ(test_area, actions[1].area); + EXPECT_EQ(test_role1, actions[1].role); + EXPECT_EQ(test_area3, actions[1].area); app_list.removeRequest(current); /* lookup_seq_err = app_list.lookUpAllocatingApp(test1); EXPECT_EQ(0, lookup_seq_err); */ app_list.next(); - unsigned next_seq = app_list.currentSequenceNumber(); + unsigned next_seq = app_list.currentRequestNumber(); EXPECT_EQ(seq2, next_seq); result = app_list.haveRequest(); EXPECT_EQ(true, result); - app_list.req_dump(); -} - -TEST_F(reqtest, release_sequence) -{ - + app_list.reqDump(); } } // namespace