Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / test.squish / suite_OBJECT_BROWSER / tst_ACTIVE_DOC_MANAGEMENT / test.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 #[tested functionality]
22
23 ENABLE_COLOR='#FF000000'
24 DISABLE_COLOR='#FFC0C0C0'
25
26 def checkPartActivatedState(scenario):
27     #[step] Check that Part is activated
28     allPartSetElements = [
29                 "Parameters (0)",
30                 "Constructions (4)",
31                 "Constructions (4).Origin",
32                 "Constructions (4).YOZ",
33                 "Constructions (4).XOZ",
34                 "Constructions (4).XOY",
35                 "Parts (1)",
36                 "Parts (1).Part\\_1"]
37     for element in allPartSetElements:
38         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
39
40     partElements = [
41                 "Part\\_1",
42                 "Part\\_1.Parameters (0)",
43                 "Part\\_1.Constructions (0)",
44                 "Part\\_1.Bodies (0)"]
45     for element in partElements:
46         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
47
48     #[step] Check that Part tree is unfolded
49     test.compare(False, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
50
51 def checkPartDeactivatedState(scenario):
52     #[step] Check that Part id disabled and folded
53     partElements = [
54                 "Part\\_1.Parameters (0)",
55                 "Part\\_1.Constructions (0)",
56                 "Part\\_1.Bodies (0)"]
57     for element in partElements:
58         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
59     test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").foregroundColor, "Part is enable after: %s" % scenario)
60     test.compare(True, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
61
62     #[step] Check that PartSet is enabled
63     allPartSetElements = [
64                 "Parameters (0)",
65                 "Constructions (4)",
66                 "Constructions (4).Origin",
67                 "Constructions (4).YOZ",
68                 "Constructions (4).XOZ",
69                 "Constructions (4).XOY",
70                 "Parts (1)",
71                 "Parts (1).Part\\_1"]
72     for element in allPartSetElements:
73         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
74
75 def main():
76     source(findFile("scripts", "common.py"))
77
78     startApplication("salome_run.sh")
79     activate_SHAPER()
80
81     #[step] Check that default elements are enabled: Parameters (0), Constructions (4), Parts (0)
82     waitForObjectItem(":Object browser_XGUI_DataTree", "Constructions (4)")
83     clickItem(":Object browser_XGUI_DataTree", "Constructions (4)", -10, 10, 0, Qt.LeftButton)
84
85     allPartSetElements = [
86                 "Parameters (0)",
87                 "Constructions (4)",
88                 "Constructions (4).Origin",
89                 "Constructions (4).YOZ",
90                 "Constructions (4).XOZ",
91                 "Constructions (4).XOY",
92                 "Parts (0)"]
93     for element in allPartSetElements:
94         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled by default" % element)
95
96     #[step] Create Part
97     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
98     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
99
100     checkPartActivatedState("Part creation")
101
102     #[step] Deactivate part by double click
103     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
104     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
105
106     checkPartDeactivatedState("Part deactivation by double click")
107
108     #[step] Activate part by double click
109     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
110     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
111
112     checkPartActivatedState("Part activation by double click")
113
114     #[step] Check that Activate is disabled in Part context menu
115     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 10, 10, 0)
116     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active Part")
117
118     #[step] Deactivate part by context menu on PartSet
119     openContextMenu(waitForObject(":Object browser.Part set_XGUI_ActiveDocLbl"), 10, 10, 0)
120     activateItem(waitForObjectItem(":_QMenu", "Activate"))
121
122     checkPartDeactivatedState("Part deactivation by context menu on PartSet")
123
124     #[step] Check that Activate is disabled in PartSet context menu
125     openContextMenu(waitForObject(":Object browser.Part set_XGUI_ActiveDocLbl"), 10, 10, 0)
126     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active PartSet")
127
128     #[step] Activate part by context menu on Part
129     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 104, 6, 0)
130     activateItem(waitForObjectItem(":_QMenu", "Activate"))
131
132     checkPartActivatedState("Part activation by context menu on Part")
133
134     close_application()