2 //#include "cpputest/include/CppUTest/CommandLineTestRunner.h"
3 #include <gtest/gtest.h>
6 #include "windowmanager-client.hpp"
8 // テストグループの定義 TEST_GROUP(group)
17 const string test1 = "testApp";
18 const string test2 = "testApp2";
19 const string test3 = "testApp3";
20 const string test_role = "testRole";
21 const string test_area = "testArea";
22 const string test1_errname = "testApp_false";
23 const string test_role_err = "testRole_false";
24 static wm::AppList app_list;
26 class dbtest : public ::testing::Test
35 TEST_F(dbtest, contains)
37 app_list.addClient(test1, test_role);
38 bool result = app_list.contains(test1);
39 EXPECT_EQ(true, result);
40 result = app_list.contains(test1_errname);
41 EXPECT_EQ(false, result);
44 TEST_F(dbtest, lookup)
46 auto test = app_list.lookUpClient(test1);
47 cout << "Check getting client object" << endl;
48 EXPECT_EQ(true, (test) ? true : false);
49 cout << "Check client name" << endl;
50 EXPECT_EQ(test1, test->appID());
51 cout << "Check exception throwing of out_of_range" << endl;
52 ASSERT_THROW(app_list.lookUpClient(test1_errname), std::out_of_range);
53 app_list.client_dump();
56 TEST_F(dbtest, remove)
58 ASSERT_NO_THROW(app_list.removeClient(test1_errname));
59 ASSERT_NO_THROW(app_list.removeClient(test1));
60 EXPECT_EQ(0, app_list.countClient());
61 app_list.addClient(test1, test_role);
64 class reqtest : public ::testing::Test
73 TEST_F(reqtest, currentSequenceNumber)
75 EXPECT_EQ(1, app_list.currentSequenceNumber());
78 TEST_F(reqtest, allocate_sequence)
80 app_list.addClient(test2, test_role);
82 wm::WMRequest req1(test1, test_role, test_area, wm::Task::TASK_ALLOCATE);
83 wm::WMRequest req2(test2, test_role, test_area, wm::Task::TASK_RELEASE);
84 unsigned seq1 = app_list.addAllocateRequest(req1);
85 unsigned seq2 = app_list.addAllocateRequest(req2);
87 unsigned current = app_list.currentSequenceNumber();
88 EXPECT_EQ(1, current);
92 bool result = app_list.requestFinished();
93 EXPECT_EQ(false, result);
95 auto trg = app_list.getRequest(seq1);
97 result = app_list.setAction(seq1, trg.appid, trg.role, trg.area);
98 result &= app_list.setAction(seq1, test3, test_role, test_area);
99 EXPECT_EQ(true, result);
103 result = app_list.setEndDrawFinished(current, test1, test_role);
104 EXPECT_EQ(true, result);
106 result = app_list.endDrawFullfilled(current);
107 EXPECT_EQ(false, result);
109 result = app_list.setEndDrawFinished(current, test3, test_role);
110 EXPECT_EQ(true, result);
114 result = app_list.endDrawFullfilled(current);
115 EXPECT_EQ(true, result);
117 auto actions = app_list.getActions(current);
118 EXPECT_EQ(test1, actions[0].appid);
119 EXPECT_EQ(test_role, actions[0].role);
120 EXPECT_EQ(test_area, actions[0].area);
121 EXPECT_EQ(test3, actions[1].appid);
122 EXPECT_EQ(test_role, actions[1].role);
123 EXPECT_EQ(test_area, actions[1].area);
125 app_list.removeRequest(current);
126 /* lookup_seq_err = app_list.lookUpAllocatingApp(test1);
127 EXPECT_EQ(0, lookup_seq_err); */
130 unsigned next_seq = app_list.currentSequenceNumber();
131 EXPECT_EQ(seq2, next_seq);
132 result = app_list.haveRequest();
133 EXPECT_EQ(true, result);
138 TEST_F(reqtest, release_sequence)
145 int main(int argc, char **argv)
147 ::testing::InitGoogleTest(&argc, argv);
148 return RUN_ALL_TESTS();