#include //#include "cpputest/include/CppUTest/CommandLineTestRunner.h" #include #include #include "applist.hpp" #include "windowmanager-client.hpp" // テストグループの定義 TEST_GROUP(group) // フィクスチャの準備 using std::cout; using std::endl; using std::string; 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 test1_errname = "testApp_false"; const string test_role_err = "testRole_false"; static wm::AppList app_list; class dbtest : public ::testing::Test { public: void SetUp() {} void TearDown() {} protected: }; TEST_F(dbtest, contains) { app_list.addClient(test1, test_role); bool result = app_list.contains(test1); EXPECT_EQ(true, result); result = app_list.contains(test1_errname); EXPECT_EQ(false, result); } TEST_F(dbtest, lookup) { auto test = app_list.lookUpClient(test1); cout << "Check getting client object" << endl; EXPECT_EQ(true, (test) ? true : false); cout << "Check client name" << endl; 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(); } TEST_F(dbtest, remove) { 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); } class reqtest : public ::testing::Test { public: void SetUp() {} void TearDown() {} protected: }; TEST_F(reqtest, currentSequenceNumber) { EXPECT_EQ(1, app_list.currentSequenceNumber()); } TEST_F(reqtest, 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(); EXPECT_EQ(1, current); EXPECT_EQ(1, seq1); EXPECT_EQ(2, seq2); bool result = app_list.requestFinished(); EXPECT_EQ(false, result); result = app_list.setAction(seq1, test1, test_role, test_area); result &= app_list.setAction(seq1, test3, test_role, test_area); EXPECT_EQ(true, result); app_list.req_dump(); result = app_list.setEndDrawFinished(current, test1, test_role); EXPECT_EQ(true, result); result = app_list.endDrawFullfilled(current); EXPECT_EQ(false, result); result = app_list.setEndDrawFinished(current, test3, test_role); EXPECT_EQ(true, result); app_list.req_dump(); result = app_list.endDrawFullfilled(current); EXPECT_EQ(true, result); 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(); EXPECT_EQ(seq2, next_seq); result = app_list.haveRequest(); EXPECT_EQ(true, result); app_list.req_dump(); } TEST_F(reqtest, release_sequence) { } } // namespace int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }