Salome HOME
Improve SQUISH test suite_OBJECT_BROWSER/tst_ACTIVE_DOC_MANAGEMENT
[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 findMenuItem(menuObject, item):
56     for child in object.children(menuObject):
57         if child.text == item:
58             return child    
59     return None
60
61 def main():
62     source(findFile("scripts", "common.py"))
63     
64     startApplication("salome_run.sh")
65     activate_newgeom()
66
67     #[step] Check that default elements are enabled: Parameters (0), Constructions (4), Parts (0)
68     waitForObjectItem(":Object browser_XGUI_DataTree", "Constructions (4)")
69     clickItem(":Object browser_XGUI_DataTree", "Constructions (4)", -10, 10, 0, Qt.LeftButton)
70      
71     allPartSetElements = [
72                 "Parameters (0)", 
73                 "Constructions (4)", 
74                 "Constructions (4).Origin", 
75                 "Constructions (4).YOZ",
76                 "Constructions (4).XOZ",
77                 "Constructions (4).XOY",
78                 "Parts (0)"]
79     for element in allPartSetElements:
80         test.compare(ENABLE_COLOR, waitForObjectItem(":Object browser_XGUI_DataTree", element).foregroundColor, "%s is enabled by default" % element)
81
82     #[step] Create Part
83     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
84     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
85      
86     checkPartActivatedState("Part creation")
87  
88     #[step] Deactivate 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     checkPartDeactivatedState("Part deactivation by double click")
93
94     #[step] Activate part by double click 
95     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
96     doubleClickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
97
98     checkPartActivatedState("Part activation by double click")
99
100     #[step] Check that Activate is disabled in Part context menu  
101     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 10, 10, 0)
102     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active Part")
103
104     #[step] Deactivate part by context menu on PartSet 
105     openContextMenu(waitForObject(":Object browser_QLineEdit"), 10, 10, 0)
106     activateItem(waitForObjectItem(":_QMenu", "Activate"))
107     
108     checkPartDeactivatedState("Part deactivation by context menu on PartSet")
109
110     #[step] Check that Activate is disabled in PartSet context menu  
111     openContextMenu(waitForObject(":Object browser_QLineEdit"), 10, 10, 0)
112     test.compare(False, findMenuItem(waitForObject(":_QMenu"), "Activate").enabled, "Activate is disabled on active PartSet")
113
114     #[step] Activate part by context menu on Part
115     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1", 104, 6, 0)
116     activateItem(waitForObjectItem(":_QMenu", "Activate"))
117
118     checkPartActivatedState("Part activation by context menu on Part")
119
120     close_application()