1###############################################################################
2#
3# Tests for Excel::Writer::XLSX::Worksheet methods.
4#
5# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org
6#
7
8use lib 't/lib';
9use TestFunctions qw(_expected_to_aref _got_to_aref _is_deep_diff _new_worksheet);
10use strict;
11use warnings;
12
13use Test::More tests => 1;
14
15###############################################################################
16#
17# Tests setup.
18#
19my $expected;
20my $got;
21my $caption;
22my $worksheet;
23
24
25###############################################################################
26#
27# Test the _assemble_xml_file() method.
28#
29# Test conditional formats.
30#
31$caption = " \tWorksheet: _assemble_xml_file()";
32
33$worksheet = _new_worksheet(\$got);
34
35$worksheet->select();
36
37# Start test code.
38$worksheet->write( 'A1', 1 );
39$worksheet->write( 'A2', 2 );
40$worksheet->write( 'A3', 3 );
41$worksheet->write( 'A4', 4 );
42$worksheet->write( 'A5', 5 );
43$worksheet->write( 'A6', 6 );
44$worksheet->write( 'A7', 7 );
45$worksheet->write( 'A8', 8 );
46
47
48$worksheet->conditional_formatting( 'A1',
49    {
50        type         => 'icon_set',
51        icon_style   => '3_arrows_gray',
52    }
53);
54
55$worksheet->conditional_formatting( 'A2',
56    {
57        type         => 'icon_set',
58        icon_style   => '3_traffic_lights',
59    }
60);
61
62$worksheet->conditional_formatting( 'A3',
63    {
64        type         => 'icon_set',
65        icon_style   => '3_signs',
66    }
67);
68
69$worksheet->conditional_formatting( 'A4',
70    {
71        type         => 'icon_set',
72        icon_style   => '3_symbols',
73    }
74);
75
76$worksheet->conditional_formatting( 'A5',
77    {
78        type         => 'icon_set',
79        icon_style   => '4_arrows_gray',
80    }
81);
82
83$worksheet->conditional_formatting( 'A6',
84    {
85        type         => 'icon_set',
86        icon_style   => '4_ratings',
87    }
88);
89
90$worksheet->conditional_formatting( 'A7',
91    {
92        type         => 'icon_set',
93        icon_style   => '5_arrows',
94    }
95);
96
97$worksheet->conditional_formatting( 'A8',
98    {
99        type         => 'icon_set',
100        icon_style   => '5_ratings',
101    }
102);
103
104# End test code.
105
106$worksheet->_assemble_xml_file();
107
108$expected = _expected_to_aref();
109$got      = _got_to_aref( $got );
110
111_is_deep_diff( $got, $expected, $caption );
112
113__DATA__
114<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
115<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
116  <dimension ref="A1:A8"/>
117  <sheetViews>
118    <sheetView tabSelected="1" workbookViewId="0"/>
119  </sheetViews>
120  <sheetFormatPr defaultRowHeight="15"/>
121  <sheetData>
122    <row r="1" spans="1:1">
123      <c r="A1">
124        <v>1</v>
125      </c>
126    </row>
127    <row r="2" spans="1:1">
128      <c r="A2">
129        <v>2</v>
130      </c>
131    </row>
132    <row r="3" spans="1:1">
133      <c r="A3">
134        <v>3</v>
135      </c>
136    </row>
137    <row r="4" spans="1:1">
138      <c r="A4">
139        <v>4</v>
140      </c>
141    </row>
142    <row r="5" spans="1:1">
143      <c r="A5">
144        <v>5</v>
145      </c>
146    </row>
147    <row r="6" spans="1:1">
148      <c r="A6">
149        <v>6</v>
150      </c>
151    </row>
152    <row r="7" spans="1:1">
153      <c r="A7">
154        <v>7</v>
155      </c>
156    </row>
157    <row r="8" spans="1:1">
158      <c r="A8">
159        <v>8</v>
160      </c>
161    </row>
162  </sheetData>
163  <conditionalFormatting sqref="A1">
164    <cfRule type="iconSet" priority="1">
165      <iconSet iconSet="3ArrowsGray">
166        <cfvo type="percent" val="0"/>
167        <cfvo type="percent" val="33"/>
168        <cfvo type="percent" val="67"/>
169      </iconSet>
170    </cfRule>
171  </conditionalFormatting>
172  <conditionalFormatting sqref="A2">
173    <cfRule type="iconSet" priority="2">
174      <iconSet>
175        <cfvo type="percent" val="0"/>
176        <cfvo type="percent" val="33"/>
177        <cfvo type="percent" val="67"/>
178      </iconSet>
179    </cfRule>
180  </conditionalFormatting>
181  <conditionalFormatting sqref="A3">
182    <cfRule type="iconSet" priority="3">
183      <iconSet iconSet="3Signs">
184        <cfvo type="percent" val="0"/>
185        <cfvo type="percent" val="33"/>
186        <cfvo type="percent" val="67"/>
187      </iconSet>
188    </cfRule>
189  </conditionalFormatting>
190  <conditionalFormatting sqref="A4">
191    <cfRule type="iconSet" priority="4">
192      <iconSet iconSet="3Symbols2">
193        <cfvo type="percent" val="0"/>
194        <cfvo type="percent" val="33"/>
195        <cfvo type="percent" val="67"/>
196      </iconSet>
197    </cfRule>
198  </conditionalFormatting>
199  <conditionalFormatting sqref="A5">
200    <cfRule type="iconSet" priority="5">
201      <iconSet iconSet="4ArrowsGray">
202        <cfvo type="percent" val="0"/>
203        <cfvo type="percent" val="25"/>
204        <cfvo type="percent" val="50"/>
205        <cfvo type="percent" val="75"/>
206      </iconSet>
207    </cfRule>
208  </conditionalFormatting>
209  <conditionalFormatting sqref="A6">
210    <cfRule type="iconSet" priority="6">
211      <iconSet iconSet="4Rating">
212        <cfvo type="percent" val="0"/>
213        <cfvo type="percent" val="25"/>
214        <cfvo type="percent" val="50"/>
215        <cfvo type="percent" val="75"/>
216      </iconSet>
217    </cfRule>
218  </conditionalFormatting>
219  <conditionalFormatting sqref="A7">
220    <cfRule type="iconSet" priority="7">
221      <iconSet iconSet="5Arrows">
222        <cfvo type="percent" val="0"/>
223        <cfvo type="percent" val="20"/>
224        <cfvo type="percent" val="40"/>
225        <cfvo type="percent" val="60"/>
226        <cfvo type="percent" val="80"/>
227      </iconSet>
228    </cfRule>
229  </conditionalFormatting>
230  <conditionalFormatting sqref="A8">
231    <cfRule type="iconSet" priority="8">
232      <iconSet iconSet="5Rating">
233        <cfvo type="percent" val="0"/>
234        <cfvo type="percent" val="20"/>
235        <cfvo type="percent" val="40"/>
236        <cfvo type="percent" val="60"/>
237        <cfvo type="percent" val="80"/>
238      </iconSet>
239    </cfRule>
240  </conditionalFormatting>
241  <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
242</worksheet>
243