Debian Codegraph @

src/plan/tests/SharedResourcesTester.cpp

raw
1 /* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2022 Dag Andersen <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 // clazy:excludeall=qstring-arg
8 #include "SharedResourcesTester.h"
9
10 #include <kptpart.h>
11 #include <kptmaindocument.h>
12 #include <RemoveResourceCmd.h>
13 #include <Resource.h>
14 #include <ResourceGroup.h>
15
16 #include <ExtraProperties.h>
17 #include <KoXmlReader.h>
18
19 #include <QTest>
20 #include <QTemporaryFile>
21 #include <QString>
22
23 #include <tests/debug.cpp>
24
25 using namespace KPlato;
26
27 void SharedResources::init()
28 {
29 part = nullptr;
30 }
31
32 void SharedResources::cleanup()
33 {
34 delete part;
35 part = nullptr;
36 }
37
38 QString resourceData_1()
39 {
40 return QStringLiteral(
41 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
42 "<!DOCTYPE plan>"
43 "<plan editor=\"Plan\" mime=\"application/x-vnd.kde.plan\" version=\"0.7.0\">"
44 "<project scheduling=\"MustStartOn\" id=\"20211006081203ph1H0qup6f\" end-time=\"2023-10-06T00:00:00+02:00\" name=\"Version 0.7\" leader=\"\" timezone=\"Europe/Copenhagen\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; &quot;>&amp;nbsp;&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" start-time=\"2021-10-06T00:00:00+02:00\">"
45 "<project-settings>"
46 "<wbs-definition project-separator=\"\" project-code=\"\" levels-enabled=\"0\">"
47 "<default code=\"Number\" separator=\".\"/>"
48 "</wbs-definition>"
49 "<locale language=\"29\" country=\"58\" currency-digits=\"2\" currency-symbol=\"kr.\"/>"
50 "<shared-resources file=\"\" use=\"0\"/>"
51 "<workpackageinfo delete-after-retrieval=\"0\" check-for-workpackages=\"1\" archive-url=\"\" publish-url=\"\" archive-after-retrieval=\"1\" retrieve-url=\"\"/>"
52 "<task-modules use-local-task-modules=\"1\"/>"
53 "<standard-worktime month=\"176h0m\" year=\"1760h0m\" day=\"8h0m\" week=\"40h0m\"/>"
54 "</project-settings>"
55 "<calendars>"
56 "<calendar origin=\"local\" id=\"20211006081255aRV6e7i99a\" holiday-region=\"Default\" name=\"Base\" timezone=\"Europe/Copenhagen\" default=\"1\">"
57 "<weekday state=\"2\" day=\"0\">"
58 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
59 "</weekday>"
60 "<weekday state=\"2\" day=\"1\">"
61 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
62 "</weekday>"
63 "<weekday state=\"2\" day=\"2\">"
64 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
65 "</weekday>"
66 "<weekday state=\"2\" day=\"3\">"
67 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
68 "</weekday>"
69 "<weekday state=\"2\" day=\"4\">"
70 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
71 "</weekday>"
72 "<weekday state=\"1\" day=\"5\"/>"
73 "<weekday state=\"1\" day=\"6\"/>"
74 "<cache version=\"11\"/>"
75 "</calendar>"
76 "</calendars>"
77 "<resource-groups>"
78 "<resource-group type=\"Work\" id=\"20211006081344t9ZgYiKN5y\" name=\"G1\" coordinator=\"\" shared=\"local\"/>"
79 "<resource-group type=\"Material\" id=\"20211006081526jm5j2tne1F\" name=\"G2\" coordinator=\"\" shared=\"local\"/>"
80 "</resource-groups>"
81 "<resources>"
82 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081359ejV35m5lJA\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
83 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081420J3YXxkpnL2\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R2\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
84 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081430tze2MXczbe\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R3\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
85 "<resource units=\"100\" type=\"Team\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081436rDOG9kV5Gp\" name=\"Team 1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
86 "<resource units=\"100\" type=\"Material\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081537NGbGyDTwBI\" name=\"M1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
87 "<resource units=\"100\" type=\"Material\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081545GOUuPpIwEX\" name=\"M2\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
88 "</resources>"
89 "<resource-group-relations>"
90 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081359ejV35m5lJA\"/>"
91 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081420J3YXxkpnL2\"/>"
92 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081430tze2MXczbe\"/>"
93 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081436rDOG9kV5Gp\"/>"
94 "<resource-group-relation group-id=\"20211006081526jm5j2tne1F\" resource-id=\"20211006081537NGbGyDTwBI\"/>"
95 "<resource-group-relation group-id=\"20211006081526jm5j2tne1F\" resource-id=\"20211006081545GOUuPpIwEX\"/>"
96 "</resource-group-relations>"
97 "<required-resources>"
98 "<required-resource required-id=\"20211006081537NGbGyDTwBI\" resource-id=\"20211006081359ejV35m5lJA\"/>"
99 "<required-resource required-id=\"20211006081545GOUuPpIwEX\" resource-id=\"20211006081420J3YXxkpnL2\"/>"
100 "</required-resources>"
101 "<resource-teams>"
102 "<team member-id=\"20211006081359ejV35m5lJA\" team-id=\"20211006081436rDOG9kV5Gp\"/>"
103 "<team member-id=\"20211006081420J3YXxkpnL2\" team-id=\"20211006081436rDOG9kV5Gp\"/>"
104 "</resource-teams>"
105 "</project>"
106 "</plan>"
107 );
108 }
109
110 QString projectData_1()
111 {
112 return QStringLiteral(
113 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
114 "<!DOCTYPE plan>"
115 "<plan editor=\"Plan\" mime=\"application/x-vnd.kde.plan\" version=\"0.7.0\">"
116 "<project scheduling=\"MustStartOn\" id=\"20211006081203ph1H0qup6f\" end-time=\"2023-10-06T00:00:00+02:00\" name=\"Version 0.7\" leader=\"\" timezone=\"Europe/Copenhagen\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; &quot;>&amp;nbsp;&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" start-time=\"2021-10-06T00:00:00+02:00\">"
117 "<project-settings>"
118 "<wbs-definition project-separator=\"\" project-code=\"\" levels-enabled=\"0\">"
119 "<default code=\"Number\" separator=\".\"/>"
120 "</wbs-definition>"
121 "<locale language=\"29\" country=\"58\" currency-digits=\"2\" currency-symbol=\"kr.\"/>"
122 "<shared-resources file=\"\" use=\"0\"/>"
123 "<workpackageinfo delete-after-retrieval=\"0\" check-for-workpackages=\"1\" archive-url=\"\" publish-url=\"\" archive-after-retrieval=\"1\" retrieve-url=\"\"/>"
124 "<task-modules use-local-task-modules=\"1\"/>"
125 "<standard-worktime month=\"176h0m\" year=\"1760h0m\" day=\"8h0m\" week=\"40h0m\"/>"
126 "</project-settings>"
127 "<accounts>"
128 "<account name=\"Konto.1\" description=\"\">"
129 "<account name=\"Konto.1.1\" description=\"\">"
130 "<costplace startup-cost=\"0\" shutdown-cost=\"0\" running-cost=\"1\" object-id=\"202110060817364rucEZwY1J\"/>"
131 "<costplace startup-cost=\"1\" shutdown-cost=\"0\" running-cost=\"0\" object-id=\"202110060818152MaYHDMFKB\"/>"
132 "<costplace startup-cost=\"0\" shutdown-cost=\"1\" running-cost=\"0\" object-id=\"20211006081826IDvVovMHEG\"/>"
133 "</account>"
134 "</account>"
135 "</accounts>"
136 "<calendars>"
137 "<calendar origin=\"local\" id=\"20211006081255aRV6e7i99a\" holiday-region=\"Default\" name=\"Base\" timezone=\"Europe/Copenhagen\" default=\"1\">"
138 "<weekday state=\"2\" day=\"0\">"
139 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
140 "</weekday>"
141 "<weekday state=\"2\" day=\"1\">"
142 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
143 "</weekday>"
144 "<weekday state=\"2\" day=\"2\">"
145 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
146 "</weekday>"
147 "<weekday state=\"2\" day=\"3\">"
148 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
149 "</weekday>"
150 "<weekday state=\"2\" day=\"4\">"
151 "<time-interval start=\"08:00:00\" length=\"28800000\"/>"
152 "</weekday>"
153 "<weekday state=\"1\" day=\"5\"/>"
154 "<weekday state=\"1\" day=\"6\"/>"
155 "<cache version=\"11\"/>"
156 "</calendar>"
157 "</calendars>"
158 "<resource-groups>"
159 "<resource-group type=\"Work\" id=\"20211006081344t9ZgYiKN5y\" name=\"G1\" coordinator=\"\" shared=\"local\"/>"
160 "<resource-group type=\"Material\" id=\"20211006081526jm5j2tne1F\" name=\"G2\" coordinator=\"\" shared=\"local\"/>"
161 "</resource-groups>"
162 "<resources>"
163 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081359ejV35m5lJA\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
164 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081420J3YXxkpnL2\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R2\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
165 "<resource units=\"100\" type=\"Work\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081430tze2MXczbe\" calendar-id=\"20211006081255aRV6e7i99a\" name=\"R3\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
166 "<resource units=\"100\" type=\"Team\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081436rDOG9kV5Gp\" name=\"Team 1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
167 "<resource units=\"100\" type=\"Material\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081537NGbGyDTwBI\" name=\"M1\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
168 "<resource units=\"100\" type=\"Material\" origin=\"local\" overtime-rate=\"0\" id=\"20211006081545GOUuPpIwEX\" name=\"M2\" initials=\"\" normal-rate=\"100\" auto-allocate=\"0\" email=\"\"/>"
169 "</resources>"
170 "<resource-group-relations>"
171 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081359ejV35m5lJA\"/>"
172 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081420J3YXxkpnL2\"/>"
173 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081430tze2MXczbe\"/>"
174 "<resource-group-relation group-id=\"20211006081344t9ZgYiKN5y\" resource-id=\"20211006081436rDOG9kV5Gp\"/>"
175 "<resource-group-relation group-id=\"20211006081526jm5j2tne1F\" resource-id=\"20211006081537NGbGyDTwBI\"/>"
176 "<resource-group-relation group-id=\"20211006081526jm5j2tne1F\" resource-id=\"20211006081545GOUuPpIwEX\"/>"
177 "</resource-group-relations>"
178 "<required-resources>"
179 "<required-resource required-id=\"20211006081537NGbGyDTwBI\" resource-id=\"20211006081359ejV35m5lJA\"/>"
180 "<required-resource required-id=\"20211006081545GOUuPpIwEX\" resource-id=\"20211006081420J3YXxkpnL2\"/>"
181 "</required-resources>"
182 "<resource-teams>"
183 "<team member-id=\"20211006081359ejV35m5lJA\" team-id=\"20211006081436rDOG9kV5Gp\"/>"
184 "<team member-id=\"20211006081420J3YXxkpnL2\" team-id=\"20211006081436rDOG9kV5Gp\"/>"
185 "</resource-teams>"
186 "<tasks>"
187 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:17:30+02:00\" constraint-starttime=\"2021-10-06T08:17:30+02:00\" id=\"20211006081730Uss92rsFaL\" shutdown-cost=\"0\" name=\"S1\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1\">"
188 "<estimate pessimistic=\"16\" type=\"Effort\" risk=\"None\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
189 "<task-schedules>"
190 "<schedule start=\"2021-10-06T00:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T00:00:00+02:00\" in-critical-path=\"0\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-07T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-07T16:00:00+02:00\" resource-error=\"0\" duration=\"1 16:0:0.0\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
191 "<schedule start=\"2021-10-06T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T08:25:24+02:00\" in-critical-path=\"0\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-08T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-08T08:25:24+02:00\" resource-error=\"0\" duration=\"2 0:0:0.0\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
192 "</task-schedules>"
193 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
194 "<workpackage owner=\"\" owner-id=\"\"/>"
195 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:17:36+02:00\" constraint-starttime=\"2021-10-06T08:17:36+02:00\" id=\"202110060817364rucEZwY1J\" shutdown-cost=\"0\" name=\"T1\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1.1\">"
196 "<estimate pessimistic=\"16\" type=\"Effort\" risk=\"None\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
197 "<task-schedules>"
198 "<schedule start=\"2021-10-06T08:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T08:00:00+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-06T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-06T16:00:00+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-06T16:00:00+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-06T08:00:00+02:00\" resource-not-available=\"0\" free-float=\"0 16:0:0.0\"/>"
199 "<schedule start=\"2021-10-06T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T08:25:24+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-07T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-07T08:25:24+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-07T08:25:24+02:00\" duration=\"1 0:0:0.0\" latestart=\"2021-10-06T08:25:24+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
200 "</task-schedules>"
201 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
202 "<workpackage owner=\"\" owner-id=\"\"/>"
203 "</task>"
204 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:18:15+02:00\" constraint-starttime=\"2021-10-06T08:18:15+02:00\" id=\"202110060818152MaYHDMFKB\" shutdown-cost=\"0\" name=\"T2\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1.2\">"
205 "<estimate pessimistic=\"16\" type=\"Effort\" risk=\"None\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
206 "<task-schedules>"
207 "<schedule start=\"2021-10-07T08:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:00:00+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-07T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-07T16:00:00+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-07T16:00:00+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-07T08:00:00+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
208 "<schedule start=\"2021-10-07T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:25:24+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-08T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-08T08:25:24+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-08T08:25:24+02:00\" duration=\"1 0:0:0.0\" latestart=\"2021-10-07T08:25:24+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
209 "</task-schedules>"
210 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
211 "<workpackage owner=\"\" owner-id=\"\"/>"
212 "</task>"
213 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:18:26+02:00\" constraint-starttime=\"2021-10-06T08:18:26+02:00\" id=\"20211006081826IDvVovMHEG\" shutdown-cost=\"0\" name=\"T3\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1.3\">"
214 "<estimate pessimistic=\"16\" type=\"Effort\" risk=\"None\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
215 "<task-schedules>"
216 "<schedule start=\"2021-10-07T08:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:00:00+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-07T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-07T16:00:00+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-07T12:00:00+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-07T12:00:00+02:00\" resource-not-available=\"1\" free-float=\"0 0:0:0.0\"/>"
217 "<schedule start=\"2021-10-07T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:25:24+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-08T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-08T08:25:24+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-07T12:25:24+02:00\" duration=\"1 0:0:0.0\" latestart=\"2021-10-07T12:25:24+02:00\" resource-not-available=\"1\" free-float=\"0 0:0:0.0\"/>"
218 "</task-schedules>"
219 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
220 "<workpackage owner=\"\" owner-id=\"\"/>"
221 "</task>"
222 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:18:45+02:00\" constraint-starttime=\"2021-10-06T08:18:45+02:00\" id=\"20211006081845PmuFUf7lQz\" shutdown-cost=\"0\" name=\"T4\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1.4\">"
223 "<estimate pessimistic=\"16\" type=\"Duration\" risk=\"None\" calendar-id=\"20211006081255aRV6e7i99a\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
224 "<task-schedules>"
225 "<schedule start=\"2021-10-07T08:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:00:00+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-07T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-07T16:00:00+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-07T16:00:00+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-07T08:00:00+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
226 "<schedule start=\"2021-10-07T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-07T08:25:24+02:00\" in-critical-path=\"1\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"0 0:0:0.0\" latefinish=\"2021-10-08T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-08T08:25:24+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-08T08:25:24+02:00\" duration=\"1 0:0:0.0\" latestart=\"2021-10-07T08:25:24+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
227 "</task-schedules>"
228 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
229 "<workpackage owner=\"\" owner-id=\"\"/>"
230 "</task>"
231 "<task scheduling=\"ASAP\" startup-cost=\"0\" constraint-endtime=\"2021-10-06T08:20:09+02:00\" constraint-starttime=\"2021-10-06T08:20:09+02:00\" id=\"2021100608200930vDAd9r1G\" shutdown-cost=\"0\" name=\"T5\" leader=\"\" description=\"&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>&lt;br />&lt;/p>&lt;/body>&lt;/html>\" priority=\"0\" wbs=\"1.5\">"
232 "<estimate pessimistic=\"16\" type=\"Duration\" risk=\"None\" optimistic=\"2\" expected=\"8\" unit=\"h\"/>"
233 "<task-schedules>"
234 "<schedule start=\"2021-10-06T00:00:00+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T00:00:00+02:00\" in-critical-path=\"0\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"1\" positive-float=\"1 8:0:0.0\" latefinish=\"2021-10-07T16:00:00+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan\" end=\"2021-10-06T08:00:00+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-06T08:00:00+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-07T08:00:00+02:00\" resource-not-available=\"1\" free-float=\"0 0:0:0.0\"/>"
235 "<schedule start=\"2021-10-06T08:25:24+02:00\" resource-overbooked=\"0\" scheduling-conflict=\"0\" earlystart=\"2021-10-06T08:25:24+02:00\" in-critical-path=\"0\" scheduling-error=\"0\" negative-float=\"0 0:0:0.0\" id=\"2\" positive-float=\"1 16:0:0.0\" latefinish=\"2021-10-08T08:25:24+02:00\" type=\"Expected\" not-scheduled=\"0\" name=\"Schedule: Plan.1\" end=\"2021-10-06T16:25:24+02:00\" resource-error=\"0\" earlyfinish=\"2021-10-06T16:25:24+02:00\" duration=\"0 8:0:0.0\" latestart=\"2021-10-08T00:25:24+02:00\" resource-not-available=\"0\" free-float=\"0 0:0:0.0\"/>"
236 "</task-schedules>"
237 "<progress entrymode=\"EnterEffortPerResource\" startTime=\"\" finishTime=\"\" started=\"0\" finished=\"0\"/>"
238 "<workpackage owner=\"\" owner-id=\"\"/>"
239 "</task>"
240 "</task>"
241 "</tasks>"
242 "<relations>"
243 "<relation child-id=\"202110060818152MaYHDMFKB\" type=\"Finish-Start\" parent-id=\"202110060817364rucEZwY1J\" lag=\"0 0:0:0.0\"/>"
244 "<relation child-id=\"20211006081826IDvVovMHEG\" type=\"Start-Start\" parent-id=\"202110060818152MaYHDMFKB\" lag=\"0 0:0:0.0\"/>"
245 "<relation child-id=\"20211006081845PmuFUf7lQz\" type=\"Finish-Finish\" parent-id=\"20211006081826IDvVovMHEG\" lag=\"0 0:0:0.0\"/>"
246 "</relations>"
247 "<project-schedules>"
248 "<schedule-management scheduling-mode=\"0\" id=\"DOeTk4zjIO\" baselined=\"0\" recalculate-from=\"\" overbooking=\"0\" scheduler-plugin-id=\"\" name=\"Plan\" scheduling-direction=\"0\" distribution=\"0\" granularityIndex=\"0\" check-external-appointments=\"1\" recalculate=\"0\">"
249 "<schedule start=\"2021-10-06T00:00:00+02:00\" type=\"Expected\" id=\"1\" name=\"Schedule: Plan\" not-scheduled=\"0\" scheduling-conflict=\"0\" duration=\"1 16:0:0.0\" end=\"2021-10-07T16:00:00+02:00\" scheduling-error=\"0\">"
250 "<criticalpath-list>"
251 "<criticalpath>"
252 "<node id=\"202110060817364rucEZwY1J\"/>"
253 "<node id=\"202110060818152MaYHDMFKB\"/>"
254 "<node id=\"20211006081826IDvVovMHEG\"/>"
255 "<node id=\"20211006081845PmuFUf7lQz\"/>"
256 "</criticalpath>"
257 "</criticalpath-list>"
258 "<appointment resource-id=\"20211006081359ejV35m5lJA\" task-id=\"202110060817364rucEZwY1J\">"
259 "<appointment-interval start=\"2021-10-06T08:00:00+02:00\" load=\"100\" end=\"2021-10-06T16:00:00+02:00\"/>"
260 "</appointment>"
261 "<appointment resource-id=\"20211006081537NGbGyDTwBI\" task-id=\"202110060817364rucEZwY1J\">"
262 "<appointment-interval start=\"2021-10-06T08:00:00+02:00\" load=\"100\" end=\"2021-10-06T16:00:00+02:00\"/>"
263 "</appointment>"
264 "<appointment resource-id=\"20211006081420J3YXxkpnL2\" task-id=\"202110060818152MaYHDMFKB\">"
265 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
266 "</appointment>"
267 "<appointment resource-id=\"20211006081545GOUuPpIwEX\" task-id=\"202110060818152MaYHDMFKB\">"
268 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
269 "</appointment>"
270 "<appointment resource-id=\"20211006081359ejV35m5lJA\" task-id=\"20211006081826IDvVovMHEG\">"
271 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
272 "</appointment>"
273 "<appointment resource-id=\"20211006081430tze2MXczbe\" task-id=\"20211006081845PmuFUf7lQz\">"
274 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
275 "</appointment>"
276 "</schedule>"
277 "<schedule-management scheduling-mode=\"0\" id=\"UwMZ3fq6BM\" baselined=\"0\" recalculate-from=\"2021-10-06T08:25:24+02:00\" overbooking=\"0\" scheduler-plugin-id=\"\" name=\"Plan.1\" scheduling-direction=\"0\" distribution=\"0\" granularityIndex=\"0\" check-external-appointments=\"1\" recalculate=\"1\">"
278 "<schedule start=\"2021-10-06T00:00:00+02:00\" type=\"Expected\" id=\"2\" name=\"Schedule: Plan.1\" not-scheduled=\"0\" scheduling-conflict=\"0\" duration=\"0 0:0:0.0\" end=\"2021-10-08T08:25:24+02:00\" scheduling-error=\"0\">"
279 "<criticalpath-list>"
280 "<criticalpath>"
281 "<node id=\"202110060817364rucEZwY1J\"/>"
282 "<node id=\"202110060818152MaYHDMFKB\"/>"
283 "<node id=\"20211006081826IDvVovMHEG\"/>"
284 "<node id=\"20211006081845PmuFUf7lQz\"/>"
285 "</criticalpath>"
286 "</criticalpath-list>"
287 "<appointment resource-id=\"20211006081359ejV35m5lJA\" task-id=\"202110060817364rucEZwY1J\">"
288 "<appointment-interval start=\"2021-10-06T08:25:24+02:00\" load=\"100\" end=\"2021-10-06T16:00:00+02:00\"/>"
289 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T08:25:24+02:00\"/>"
290 "</appointment>"
291 "<appointment resource-id=\"20211006081537NGbGyDTwBI\" task-id=\"202110060817364rucEZwY1J\">"
292 "<appointment-interval start=\"2021-10-06T08:25:24+02:00\" load=\"100\" end=\"2021-10-06T16:00:00+02:00\"/>"
293 "<appointment-interval start=\"2021-10-07T08:00:00+02:00\" load=\"100\" end=\"2021-10-07T08:25:24+02:00\"/>"
294 "</appointment>"
295 "<appointment resource-id=\"20211006081420J3YXxkpnL2\" task-id=\"202110060818152MaYHDMFKB\">"
296 "<appointment-interval start=\"2021-10-07T08:25:24+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
297 "<appointment-interval start=\"2021-10-08T08:00:00+02:00\" load=\"100\" end=\"2021-10-08T08:25:24+02:00\"/>"
298 "</appointment>"
299 "<appointment resource-id=\"20211006081545GOUuPpIwEX\" task-id=\"202110060818152MaYHDMFKB\">"
300 "<appointment-interval start=\"2021-10-07T08:25:24+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
301 "<appointment-interval start=\"2021-10-08T08:00:00+02:00\" load=\"100\" end=\"2021-10-08T08:25:24+02:00\"/>"
302 "</appointment>"
303 "<appointment resource-id=\"20211006081359ejV35m5lJA\" task-id=\"20211006081826IDvVovMHEG\">"
304 "<appointment-interval start=\"2021-10-07T08:25:24+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
305 "<appointment-interval start=\"2021-10-08T08:00:00+02:00\" load=\"100\" end=\"2021-10-08T08:25:24+02:00\"/>"
306 "</appointment>"
307 "<appointment resource-id=\"20211006081430tze2MXczbe\" task-id=\"20211006081845PmuFUf7lQz\">"
308 "<appointment-interval start=\"2021-10-07T08:25:24+02:00\" load=\"100\" end=\"2021-10-07T16:00:00+02:00\"/>"
309 "<appointment-interval start=\"2021-10-08T08:00:00+02:00\" load=\"100\" end=\"2021-10-08T08:25:24+02:00\"/>"
310 "</appointment>"
311 "<appointment resource-id=\"20211006081430tze2MXczbe\" task-id=\"2021100608200930vDAd9r1G\">"
312 "<appointment-interval start=\"2021-10-06T08:25:24+02:00\" load=\"100\" end=\"2021-10-06T16:00:00+02:00\"/>"
313 "</appointment>"
314 "</schedule>"
315 "</schedule-management>"
316 "</schedule-management>"
317 "</project-schedules>"
318 "<resource-requests>"
319 "<resource-request units=\"100\" request-id=\"1\" resource-id=\"20211006081430tze2MXczbe\" task-id=\"20211006081845PmuFUf7lQz\"/>"
320 "<resource-request units=\"100\" request-id=\"1\" resource-id=\"20211006081420J3YXxkpnL2\" task-id=\"202110060818152MaYHDMFKB\"/>"
321 "<resource-request units=\"100\" request-id=\"1\" resource-id=\"20211006081430tze2MXczbe\" task-id=\"2021100608200930vDAd9r1G\"/>"
322 "<resource-request units=\"100\" request-id=\"1\" resource-id=\"20211006081359ejV35m5lJA\" task-id=\"202110060817364rucEZwY1J\"/>"
323 "<resource-request units=\"100\" request-id=\"1\" resource-id=\"20211006081436rDOG9kV5Gp\" task-id=\"20211006081826IDvVovMHEG\"/>"
324 "</resource-requests>"
325 "<required-resource-requests>"
326 "<required-resource-request required-id=\"20211006081545GOUuPpIwEX\" request-id=\"1\" task-id=\"202110060818152MaYHDMFKB\"/>"
327 "<required-resource-request required-id=\"20211006081537NGbGyDTwBI\" request-id=\"1\" task-id=\"202110060817364rucEZwY1J\"/>"
328 "</required-resource-requests>"
329 "</project>"
330 "</plan>"
331 );
332 }
333
334 MainDocument *loadXml(const QString &xml)
335 {
336 Part *part = new Part(nullptr);
337 auto doc = part->createDocument(part);
338 KoXmlDocument xmlDoc;
339 xmlDoc.setContent(xml);
340 doc->loadXML(xmlDoc, nullptr);
341 return qobject_cast<MainDocument*>(doc);
342 }
343
344 void checkSharedResources(const Project *sharedProject)
345 {
346 QCOMPARE(sharedProject->calendarCount(), 1);
347 QCOMPARE(sharedProject->resourceGroupCount(), 2);
348 QCOMPARE(sharedProject->resourceCount(), 6);
349
350 const auto G1 = sharedProject->resourceGroups().value(0);
351 const auto G2 = sharedProject->resourceGroups().value(1);
352 QCOMPARE(G1->resources().count(), 4);
353 QCOMPARE(G1->resources().value(0), sharedProject->resourceAt(0));
354 QCOMPARE(G1->resources().value(1), sharedProject->resourceAt(1));
355 QCOMPARE(G1->resources().value(2), sharedProject->resourceAt(2));
356 QCOMPARE(G1->resources().value(3), sharedProject->resourceAt(3));
357
358 QCOMPARE(G2->resources().value(0), sharedProject->resourceAt(4));
359 QCOMPARE(G2->resources().value(1), sharedProject->resourceAt(5));
360 }
361
362 void SharedResources::testEmpty()
363 {
364 auto sharedDoc = loadXml(resourceData_1());
365 QVERIFY(sharedDoc);
366 auto sharedProject = sharedDoc->project();
367 checkSharedResources(sharedProject);
368 QCOMPARE(sharedProject->calendarCount(), 1);
369 QCOMPARE(sharedProject->resourceGroupCount(), 2);
370 QCOMPARE(sharedProject->resourceCount(), 6);
371
372 Part part(nullptr);
373 auto doc = qobject_cast<MainDocument*>(part.createDocument(&part));
374 part.setDocument(doc);
375 doc->setProperty(NOUI, true);
376 // doc->setProperty(DEFAULTSHAREDRESOURCESRESULT, 2 /*keep*/);
377
378 QVERIFY(static_cast<MainDocument*>(doc)->mergeResources(*sharedProject));
379 Debug::print(doc->project(), "", true);
380 QCOMPARE(doc->project()->calendarCount(), 1);
381 QCOMPARE(doc->project()->resourceGroupCount(), 2);
382 QCOMPARE(doc->project()->resourceCount(), 6);
383
384 delete sharedDoc;
385 }
386
387 void SharedResources::testRemoveResource()
388 {
389 auto sharedDoc = loadXml(resourceData_1());
390 QVERIFY(sharedDoc);
391 auto sharedProject = sharedDoc->project();
392 checkSharedResources(sharedProject);
393
394 Part part(nullptr);
395 auto doc = qobject_cast<MainDocument*>(part.createDocument(&part));
396 part.setDocument(doc);
397
398 QVERIFY(doc->mergeResources(*sharedProject));
399 QCOMPARE(doc->project()->calendarCount(), 1);
400 QCOMPARE(doc->project()->resourceGroupCount(), 2);
401 QCOMPARE(doc->project()->resourceCount(), 6);
402
403 delete sharedDoc;
404 sharedDoc = loadXml(resourceData_1());
405 sharedProject = sharedDoc->project();
406
407 RemoveResourceCmd cmd(sharedProject->resourceList().value(0));
408 cmd.redo();
409 QCOMPARE(sharedProject->resourceCount(), 5);
410
411 doc->setProperty(NOUI, true);
412 doc->setProperty(SHAREDRESOURCESACTION, SHAREDRESOURCESREMOVE);
413 auto project = doc->project();
414 doc->mergeResources(*sharedProject);
415
416 QCOMPARE(project->calendarCount(), 1);
417 QCOMPARE(project->resourceGroupCount(), 2);
418 QCOMPARE(project->resourceCount(), 5);
419
420 const auto G1 = project->resourceGroups().value(0);
421 const auto G2 = project->resourceGroups().value(1);
422 QCOMPARE(G1->resources().count(), 3);
423 QStringList names = {QStringLiteral("R2"),QStringLiteral("R3"),QStringLiteral("Team 1")};
424 for (const auto r : G1->resources()) {
425 QVERIFY(names.contains(r->name()));
426 }
427
428 QStringList names2 = {QStringLiteral("M1"), QStringLiteral("M2")};
429 for (const auto r : G2->resources()) {
430 QVERIFY(names2.contains(r->name()));
431 }
432
433 delete sharedDoc;
434 }
435
436 void SharedResources::testConvertResource()
437 {
438 auto sharedDoc = loadXml(resourceData_1());
439 QVERIFY(sharedDoc);
440 auto sharedProject = sharedDoc->project();
441 checkSharedResources(sharedProject);
442
443 Part part(nullptr);
444 auto doc = qobject_cast<MainDocument*>(part.createDocument(&part));
445 part.setDocument(doc);
446
447 QVERIFY(doc->mergeResources(*sharedProject));
448 QCOMPARE(doc->project()->calendarCount(), 1);
449 QCOMPARE(doc->project()->resourceGroupCount(), 2);
450 QCOMPARE(doc->project()->resourceCount(), 6);
451
452 delete sharedDoc;
453 sharedDoc = loadXml(resourceData_1());
454 sharedProject = sharedDoc->project();
455
456 RemoveResourceCmd cmd(sharedProject->resourceList().value(0));
457 cmd.redo();
458 QCOMPARE(sharedProject->resourceCount(), 5);
459
460 doc->setProperty(NOUI, true);
461 doc->setProperty(SHAREDRESOURCESACTION, SHAREDRESOURCESCONVERT);
462 auto project = doc->project();
463 doc->mergeResources(*sharedProject);
464
465 QCOMPARE(project->calendarCount(), 1);
466 QCOMPARE(project->resourceGroupCount(), 2);
467 QCOMPARE(project->resourceCount(), 6);
468
469 //Debug::print(project, "", true);
470
471 QVERIFY(!project->resourceList().value(0)->isShared());
472
473 const auto G1 = project->resourceGroups().value(0);
474 const auto G2 = project->resourceGroups().value(1);
475 QCOMPARE(G1->resources().count(), 4);
476 QStringList names = {QStringLiteral("R1"), QStringLiteral("R2"),QStringLiteral("R3"),QStringLiteral("Team 1")};
477 for (const auto r : G1->resources()) {
478 QVERIFY(names.contains(r->name()));
479 }
480
481 QStringList names2 = {QStringLiteral("M1"), QStringLiteral("M2")};
482 for (const auto r : G2->resources()) {
483 QVERIFY(names2.contains(r->name()));
484 }
485
486 delete sharedDoc;
487 }
488
489
490 QTEST_MAIN(SharedResources)