Salome HOME
Merge with Dev_1.5.0
[modules/shaper.git] / test.squish / suite_OBJECT_BROWSER / tst_ACTIVE_DOC_MANAGEMENT / test.py
1 #[tested functionality] 
2
3 ENABLE_COLOR='#FF000000'
4 DISABLE_COLOR='#FFC0C0C0'
5
6 def checkPartActivatedState(scenario):
7     #[step] Check that Part is activated
8     allPartSetElements = [
9                 "Parameters (0)", 
10                 "Constructions (4)", 
11                 "Constructions (4).Origin", 
12                 "Constructions (4).YOZ",
13                 "Constructions (4).XOZ",
14                 "Constructions (4).XOY",
15                 "Parts (1)",
16                 "Parts (1).Part\\_1"]
17     for element in allPartSetElements:
18         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
19
20     partElements = [
21                 "Part\\_1", 
22                 "Part\\_1.Parameters (0)",
23                 "Part\\_1.Constructions (0)",
24                 "Part\\_1.Bodies (0)"]
25     for element in partElements:
26         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
27     
28     #[step] Check that Part tree is unfolded
29     test.compare(False, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
30
31 def checkPartDeactivatedState(scenario):
32     #[step] Check that Part id disabled and folded 
33     partElements = [
34                 "Part\\_1.Parameters (0)",
35                 "Part\\_1.Constructions (0)",
36                 "Part\\_1.Bodies (0)"]
37     for element in partElements:
38         test.compare(DISABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is disabled after: %s" % (element, scenario))
39     test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").foregroundColor, "Part is enable after: %s" % scenario)
40     test.compare(True, waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1").collapsed, "Part is unfolded after: %s" % scenario)
41     
42     #[step] Check that PartSet is enabled  
43     allPartSetElements = [
44                 "Parameters (0)", 
45                 "Constructions (4)", 
46                 "Constructions (4).Origin", 
47                 "Constructions (4).YOZ",
48                 "Constructions (4).XOZ",
49                 "Constructions (4).XOY",
50                 "Parts (1)",
51                 "Parts (1).Part\\_1"]
52     for element in allPartSetElements:
53         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled after: %s" % (element, scenario))
54
55 def main():
56     source(findFile("scripts", "common.py"))
57     
58     startApplication("salome_run.sh")
59     activate_newgeom()
60
61     #[step] Check that default elements are enabled: Parameters (0), Constructions (4), Parts (0)
62     waitForObjectItem(":Object browser_XGUI_DataTree", "Constructions (4)")
63     clickItem(":Object browser_XGUI_DataTree", "Constructions (4)", -10, 10, 0, Qt.LeftButton)
64      
65     allPartSetElements = [
66                 "Parameters (0)", 
67                 "Constructions (4)", 
68                 "Constructions (4).Origin", 
69                 "Constructions (4).YOZ",
70                 "Constructions (4).XOZ",
71                 "Constructions (4).XOY",
72                 "Parts (0)"]
73     for element in allPartSetElements:
74         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled by default" % element)
75
76     #[step] Create Part
77     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
78     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
79      
80     checkPartActivatedState("Part creation")
81  
82     #[step] Deactivate part by double click 
83     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
84     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
85
86     checkPartDeactivatedState("Part deactivation by double click")
87
88     #[step] Activate part by double click 
89     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
90     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
91
92     checkPartActivatedState("Part activation by double click")
93
94     #[step] Check that Activate is disabled in Part context menu  
95     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 10, 10, 0)
96     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active Part")
97
98     #[step] Deactivate part by context menu on PartSet 
99     openContextMenu(waitForObject(":Object browser_QLineEdit"), 10, 10, 0)
100     activateItem(waitForObjectItem(":_QMenu", "Activate"))
101     
102     checkPartDeactivatedState("Part deactivation by context menu on PartSet")
103
104     #[step] Check that Activate is disabled in PartSet context menu  
105     openContextMenu(waitForObject(":Object browser_QLineEdit"), 10, 10, 0)
106     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active PartSet")
107
108     #[step] Activate part by context menu on Part
109     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 104, 6, 0)
110     activateItem(waitForObjectItem(":_QMenu", "Activate"))
111
112     checkPartActivatedState("Part activation by context menu on Part")
113
114     close_application()