Salome HOME
updated copyright message
[modules/shaper.git] / test.squish / suite_OBJECT_BROWSER / tst_ACTIVE_DOC_MANAGEMENT / test.py
1 # Copyright (C) 2014-2023  CEA, EDF
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 #[tested functionality]
21
22 ENABLE_COLOR='#FF000000'
23 DISABLE_COLOR='#FFC0C0C0'
24
25 def checkPartActivatedState(scenario):
26     #[step] Check that Part is activated
27     allPartSetElements = [
28                 "Parameters (0)",
29                 "Constructions (4)",
30                 "Constructions (4).Origin",
31                 "Constructions (4).YOZ",
32                 "Constructions (4).XOZ",
33                 "Constructions (4).XOY",
34                 "Parts (1)",
35                 "Parts (1).Part\\_1"]
36     for element in allPartSetElements:
37         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
38
39     partElements = [
40                 "Part\\_1",
41                 "Part\\_1.Parameters (0)",
42                 "Part\\_1.Constructions (0)",
43                 "Part\\_1.Bodies (0)"]
44     for element in partElements:
45         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
46
47     #[step] Check that Part tree is unfolded
48     test.compare(False, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
49
50 def checkPartDeactivatedState(scenario):
51     #[step] Check that Part id disabled and folded
52     partElements = [
53                 "Part\\_1.Parameters (0)",
54                 "Part\\_1.Constructions (0)",
55                 "Part\\_1.Bodies (0)"]
56     for element in partElements:
57         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
58     test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").foregroundColor, "Part is enable after: %s" % scenario)
59     test.compare(True, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
60
61     #[step] Check that PartSet is enabled
62     allPartSetElements = [
63                 "Parameters (0)",
64                 "Constructions (4)",
65                 "Constructions (4).Origin",
66                 "Constructions (4).YOZ",
67                 "Constructions (4).XOZ",
68                 "Constructions (4).XOY",
69                 "Parts (1)",
70                 "Parts (1).Part\\_1"]
71     for element in allPartSetElements:
72         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
73
74 def main():
75     source(findFile("scripts", "common.py"))
76
77     startApplication("salome_run.sh")
78     activate_SHAPER()
79
80     #[step] Check that default elements are enabled: Parameters (0), Constructions (4), Parts (0)
81     waitForObjectItem(":Object browser_XGUI_DataTree", "Constructions (4)")
82     clickItem(":Object browser_XGUI_DataTree", "Constructions (4)", -10, 10, 0, Qt.LeftButton)
83
84     allPartSetElements = [
85                 "Parameters (0)",
86                 "Constructions (4)",
87                 "Constructions (4).Origin",
88                 "Constructions (4).YOZ",
89                 "Constructions (4).XOZ",
90                 "Constructions (4).XOY",
91                 "Parts (0)"]
92     for element in allPartSetElements:
93         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled by default" % element)
94
95     #[step] Create Part
96     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
97     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
98
99     checkPartActivatedState("Part creation")
100
101     #[step] Deactivate part by double click
102     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
103     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
104
105     checkPartDeactivatedState("Part deactivation by double click")
106
107     #[step] Activate part by double click
108     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
109     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
110
111     checkPartActivatedState("Part activation by double click")
112
113     #[step] Check that Activate is disabled in Part context menu
114     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 10, 10, 0)
115     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active Part")
116
117     #[step] Deactivate part by context menu on PartSet
118     openContextMenu(waitForObject(":Object browser.Part set_XGUI_ActiveDocLbl"), 10, 10, 0)
119     activateItem(waitForObjectItem(":_QMenu", "Activate"))
120
121     checkPartDeactivatedState("Part deactivation by context menu on PartSet")
122
123     #[step] Check that Activate is disabled in PartSet context menu
124     openContextMenu(waitForObject(":Object browser.Part set_XGUI_ActiveDocLbl"), 10, 10, 0)
125     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active PartSet")
126
127     #[step] Activate part by context menu on Part
128     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 104, 6, 0)
129     activateItem(waitForObjectItem(":_QMenu", "Activate"))
130
131     checkPartActivatedState("Part activation by context menu on Part")
132
133     close_application()