Skip to content

Commit 4ba8974

Browse files
committed
add test for layer visibility in embedded group
1 parent 35def84 commit 4ba8974

File tree

2 files changed

+82
-45
lines changed

2 files changed

+82
-45
lines changed

tests/src/python/test_qgsproject.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,13 @@ def testEmbeddedGroup(self):
194194
prj.read(prj_path)
195195

196196
layer_tree_group = prj.layerTreeRoot()
197-
layers_ids = layer_tree_group.findLayerIds()
198-
199-
layers_names = []
200-
for layer_id in layers_ids:
197+
for layer_id in layer_tree_group.findLayerIds():
201198
name = prj.mapLayer(layer_id).name()
202-
layers_names.append(name)
203-
204-
expected = ['polys', 'lines']
205-
self.assertEqual(sorted(layers_names), sorted(expected))
199+
self.assertTrue(name in ['polys', 'lines'])
200+
if name == 'polys':
201+
self.assertTrue(layer_tree_group.findLayer(layer_id).itemVisibilityChecked())
202+
elif name == 'lines':
203+
self.assertFalse(layer_tree_group.findLayer(layer_id).itemVisibilityChecked())
206204

207205
def testInstance(self):
208206
""" test retrieving global instance """
+76-37
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
2-
<qgis projectname="" version="2.99.0-Master">
2+
<qgis projectname="" version="3.7.0-Master">
3+
<homePath path=""/>
34
<title></title>
45
<autotransaction active="0"/>
56
<evaluateDefaultValues active="0"/>
6-
<layer-tree-group checked="Qt::Checked" name="" expanded="1">
7+
<trust active="0"/>
8+
<projectCrs>
9+
<spatialrefsys>
10+
<proj4>+proj=longlat +datum=WGS84 +no_defs</proj4>
11+
<srsid>3452</srsid>
12+
<srid>4326</srid>
13+
<authid>EPSG:4326</authid>
14+
<description>WGS 84</description>
15+
<projectionacronym>longlat</projectionacronym>
16+
<ellipsoidacronym>WGS84</ellipsoidacronym>
17+
<geographicflag>true</geographicflag>
18+
</spatialrefsys>
19+
</projectCrs>
20+
<layer-tree-group>
721
<customproperties/>
8-
<layer-tree-group checked="Qt::Checked" name="group1" expanded="1">
22+
<layer-tree-group checked="Qt::Checked" expanded="1" name="group1">
923
<customproperties>
1024
<property key="embedded" value="1"/>
11-
<property key="embedded-invisible-layers"/>
25+
<property key="embedded-invisible-layers" value="lines20170310142652255"/>
1226
<property key="embedded_project" value="./project1.qgs"/>
1327
</customproperties>
1428
</layer-tree-group>
29+
<custom-order enabled="0"/>
1530
</layer-tree-group>
16-
<snapping-settings type="1" mode="2" unit="2" enabled="0" tolerance="0" intersection-snapping="0">
31+
<snapping-settings enabled="0" tolerance="0" intersection-snapping="0" type="1" mode="2" unit="2">
1732
<individual-layer-settings>
18-
<layer-setting type="1" id="polys20170310142652234" enabled="0" tolerance="0" units="2"/>
19-
<layer-setting type="1" id="lines20170310142652255" enabled="0" tolerance="0" units="2"/>
33+
<layer-setting enabled="0" tolerance="0" units="2" id="polys20170310142652234" type="1"/>
34+
<layer-setting enabled="0" tolerance="0" units="2" id="lines20170310142652255" type="1"/>
2035
</individual-layer-settings>
2136
</snapping-settings>
2237
<relations/>
23-
<mapcanvas>
38+
<mapcanvas annotationsVisible="1" name="theMapCanvas">
2439
<units>degrees</units>
2540
<extent>
26-
<xmin>-119.83786762594776576</xmin>
27-
<ymin>22.62025663373795226</ymin>
28-
<xmax>-81.40764418773530053</xmax>
29-
<ymax>47.3141218219175812</ymax>
41+
<xmin>-116.65168838681026386</xmin>
42+
<ymin>15.75771673405715845</ymin>
43+
<xmax>-78.22146494859779864</xmax>
44+
<ymax>40.45158192223678384</ymax>
3045
</extent>
3146
<rotation>0</rotation>
3247
<destinationsrs>
@@ -42,51 +57,75 @@
4257
</spatialrefsys>
4358
</destinationsrs>
4459
<rendermaptile>0</rendermaptile>
45-
<layer_coordinate_transform_info/>
60+
<expressionContextScope/>
4661
</mapcanvas>
47-
<layer-tree-canvas>
48-
<custom-order enabled="0">
49-
<item>polys20170310142652234</item>
50-
<item>lines20170310142652255</item>
51-
</custom-order>
52-
</layer-tree-canvas>
5362
<legend updateDrawingOrder="true">
54-
<legendgroup project="./project1.qgs" embedded="1" checked="Qt::Checked" name="group1" open="true"/>
63+
<legendgroup embedded="1" open="true" checked="Qt::Checked" project="./project1.qgs" name="group1"/>
5564
</legend>
65+
<mapViewDocks/>
5666
<projectlayers/>
67+
<layerorder>
68+
<layer id="polys20170310142652234"/>
69+
<layer id="lines20170310142652255"/>
70+
</layerorder>
5771
<properties>
5872
<Gui>
73+
<CanvasColorBluePart type="int">255</CanvasColorBluePart>
74+
<CanvasColorGreenPart type="int">255</CanvasColorGreenPart>
5975
<CanvasColorRedPart type="int">255</CanvasColorRedPart>
6076
<SelectionColorAlphaPart type="int">255</SelectionColorAlphaPart>
61-
<CanvasColorGreenPart type="int">255</CanvasColorGreenPart>
62-
<SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
6377
<SelectionColorBluePart type="int">0</SelectionColorBluePart>
64-
<CanvasColorBluePart type="int">255</CanvasColorBluePart>
78+
<SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
6579
<SelectionColorRedPart type="int">255</SelectionColorRedPart>
6680
</Gui>
67-
<PositionPrecision>
68-
<DecimalPlaces type="int">2</DecimalPlaces>
69-
<Automatic type="bool">true</Automatic>
70-
</PositionPrecision>
71-
<Paths>
72-
<Absolute type="bool">false</Absolute>
73-
</Paths>
74-
<Legend>
75-
<filterByMap type="bool">false</filterByMap>
76-
</Legend>
7781
<Identify>
7882
<disabledLayers type="QStringList"/>
7983
</Identify>
84+
<Legend>
85+
<filterByMap type="bool">false</filterByMap>
86+
</Legend>
87+
<Measurement>
88+
<AreaUnits type="QString">m2</AreaUnits>
89+
<DistanceUnits type="QString">meters</DistanceUnits>
90+
</Measurement>
91+
<PAL>
92+
<CandidatesLine type="int">50</CandidatesLine>
93+
<CandidatesPoint type="int">16</CandidatesPoint>
94+
<CandidatesPolygon type="int">30</CandidatesPolygon>
95+
<DrawRectOnly type="bool">false</DrawRectOnly>
96+
<SearchMethod type="int">0</SearchMethod>
97+
<ShowingAllLabels type="bool">false</ShowingAllLabels>
98+
<ShowingCandidates type="bool">false</ShowingCandidates>
99+
<ShowingPartialsLabels type="bool">true</ShowingPartialsLabels>
100+
<TextFormat type="int">0</TextFormat>
101+
</PAL>
102+
<Paths>
103+
<Absolute type="bool">false</Absolute>
104+
</Paths>
105+
<PositionPrecision>
106+
<Automatic type="bool">true</Automatic>
107+
<DecimalPlaces type="int">2</DecimalPlaces>
108+
</PositionPrecision>
80109
<SpatialRefSys>
81110
<ProjectCRSID type="int">3452</ProjectCRSID>
82111
<ProjectCRSProj4String type="QString">+proj=longlat +datum=WGS84 +no_defs</ProjectCRSProj4String>
83112
<ProjectCrs type="QString">EPSG:4326</ProjectCrs>
113+
<ProjectionsEnabled type="int">1</ProjectionsEnabled>
84114
</SpatialRefSys>
85-
<Measurement>
86-
<AreaUnits type="QString">m2</AreaUnits>
87-
<DistanceUnits type="QString">meters</DistanceUnits>
88-
</Measurement>
89115
</properties>
90116
<visibility-presets/>
117+
<transformContext/>
118+
<projectMetadata>
119+
<identifier></identifier>
120+
<parentidentifier></parentidentifier>
121+
<language></language>
122+
<type></type>
123+
<title></title>
124+
<abstract></abstract>
125+
<links/>
126+
<author></author>
127+
<creation></creation>
128+
</projectMetadata>
91129
<Annotations/>
130+
<Layouts/>
92131
</qgis>

0 commit comments

Comments
 (0)