win 0.3.24 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,291 +1,304 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'win/gui/menu'
3
3
 
4
- module WinGuiWindowTest
4
+ include WinTestApp
5
+ include Win::Gui::Window
6
+
7
+ describe Win::Gui::Menu, ' defines a set of API functions related to menus' do
8
+ context 'non-destructive methods' do
9
+ before(:each) do
10
+ @app = launch_test_app
11
+ @menu = get_menu(@app.handle)
12
+ @file_menu = get_sub_menu(@menu, 0)
13
+ end
14
+ after(:each) { close_test_app if @launched_test_app }
15
+
16
+ describe "#get_menu" do
17
+
18
+ spec { use { menu = GetMenu(@app.handle) } }
19
+ spec { use { menu = get_menu(@app.handle) } }
20
+
21
+ it "retrieves a handle to the menu assigned to the specified top-level window" do
22
+ menu1 = GetMenu(@app.handle)
23
+ menu2 = get_menu(@app.handle)
24
+ menu1.should be_an Integer
25
+ menu1.should == @menu
26
+ menu1.should == menu2
27
+ end
5
28
 
6
- include WinTestApp
7
- include Win::Gui::Window
29
+ it "returns 0/nil if no menu assigned to the specified top-level window" do
30
+ test_app_with_dialog(:close) do |app, dialog|
31
+ GetMenu(dialog).should == 0
32
+ get_menu(dialog).should == nil
33
+ end
34
+ end
35
+ end # describe get_menu
36
+
37
+ describe "#get_system_menu" do
38
+ spec { use { system_menu = GetSystemMenu(any_handle, reset=0) } }
39
+ spec { use { system_menu = get_system_menu(any_handle, reset=false) } }
40
+
41
+ it "with reset=0/false(default) allows the application to access the window menu (AKA system menu)" do
42
+ menu1 = GetSystemMenu(@app.handle, reset=0)
43
+ menu2 = get_system_menu(@app.handle, false)
44
+ menu3 = get_system_menu(@app.handle)
45
+ menu1.should be_an Integer
46
+ menu1.should == menu2
47
+ menu1.should == menu3
48
+ end
8
49
 
9
- describe Win::Gui::Menu, ' defines a set of API functions related to menus' do
10
- context 'non-destructive methods' do
11
- before(:all)do
12
- @app = launch_test_app
13
- @menu = get_menu(@app.handle)
14
- @file_menu = get_sub_menu(@menu, 0)
50
+ it "with reset=1/true allows the application to reset its window menu to default, returns 0/nil" do
51
+ GetSystemMenu(@app.handle, reset=1).should == 0
52
+ get_system_menu(@app.handle, reset=true).should == nil
15
53
  end
16
- after(:all){ close_test_app if @launched_test_app }
54
+ end # describe get_system_menu
17
55
 
18
- describe "#get_menu" do
56
+ describe "#get_menu_item_count" do
19
57
 
20
- spec{ use{ menu = GetMenu(@app.handle) }}
21
- spec{ use{ menu = get_menu(@app.handle) }}
58
+ spec { use { num_items = GetMenuItemCount(@menu) } }
59
+ spec { use { num_items = get_menu_item_count(@menu) } }
22
60
 
23
- it "retrieves a handle to the menu assigned to the specified top-level window" do
24
- menu1 = GetMenu(@app.handle)
25
- menu2 = get_menu(@app.handle)
26
- menu1.should be_an Integer
27
- menu1.should == @menu
28
- menu1.should == menu2
29
- end
61
+ it "determines the number of items in the specified menu. " do
62
+ GetMenuItemCount(@menu).should == 3
63
+ get_menu_item_count(@menu).should == 3
64
+ end
30
65
 
31
- it "returns 0/nil if no menu assigned to the specified top-level window" do
32
- test_app_with_dialog(:close) do |app, dialog|
33
- GetMenu(dialog).should == 0
34
- get_menu(dialog).should == nil
35
- end
36
- end
37
- end # describe get_menu
38
-
39
- describe "#get_system_menu" do
40
- spec{ use{ system_menu = GetSystemMenu(any_handle, reset=0) }}
41
- spec{ use{ system_menu = get_system_menu(any_handle, reset=false) }}
42
-
43
- it "with reset=0/false(default) allows the application to access the window menu (AKA system menu)" do
44
- menu1 = GetSystemMenu(@app.handle, reset=0)
45
- menu2 = get_system_menu(@app.handle, reset=0)
46
- menu3 = get_system_menu(@app.handle)
47
- menu1.should be_an Integer
48
- menu1.should == menu2
49
- menu1.should == menu3
50
- end
66
+ it "returns -1/nil if function fails " do
67
+ GetMenuItemCount(not_a_handle).should == -1
68
+ get_menu_item_count(not_a_handle).should == nil
69
+ end
70
+ end # describe get_menu_item_count
51
71
 
52
- it "with reset=1/true allows the application to reset its window menu to default, returns 0/nil" do
53
- GetSystemMenu(@app.handle, reset=1).should == 0
54
- get_system_menu(@app.handle, reset=true).should == nil
55
- end
56
- end # describe get_system_menu
72
+ describe "#get_menu_item_id" do
73
+ spec { use { item_id = GetMenuItemID(@menu, pos=0) } }
74
+ spec { use { item_id = get_menu_item_id(@menu, pos=0) } }
75
+
76
+ it "retrieves the menu item identifier of a menu item located at the specified position" do
77
+ GetMenuItemID(@file_menu, pos=0).should == ID_FILE_SAVE_AS
78
+ get_menu_item_id(@file_menu, pos=0).should == ID_FILE_SAVE_AS
79
+ end
57
80
 
58
- describe "#get_menu_item_count" do
81
+ it "returns -1/nil if no menu item at given position" do
82
+ GetMenuItemID(@menu, pos=4).should == -1
83
+ get_menu_item_id(@menu, pos=4).should == nil
84
+ end
59
85
 
60
- spec{ use{ num_items = GetMenuItemCount(@menu) }}
61
- spec{ use{ num_items = get_menu_item_count(@menu) }}
86
+ it "returns -1/nil if given menu item is in fact a sub-menu" do
87
+ GetMenuItemID(@menu, pos=0).should == -1
88
+ get_menu_item_id(@menu, pos=1).should == nil
89
+ end
90
+ end # describe get_menu_item_id
91
+
92
+ describe "#get_sub_menu" do
93
+ spec { use { sub_menu = GetSubMenu(@menu, pos=0) } }
94
+ spec { use { sub_menu = get_sub_menu(@menu, pos=0) } }
95
+
96
+ it "retrieves a handle to the drop-down menu or submenu activated by the specified menu item" do
97
+ sub_menu1 = GetSubMenu(@menu, pos=0)
98
+ sub_menu2 = get_sub_menu(@menu, pos=0)
99
+ sub_menu1.should be_an Integer
100
+ sub_menu1.should == @file_menu
101
+ sub_menu1.should == sub_menu2
102
+ end
62
103
 
63
- it "determines the number of items in the specified menu. " do
64
- GetMenuItemCount(@menu).should == 3
65
- get_menu_item_count(@menu).should == 3
66
- end
104
+ it "returns 0/nil if unable to find submenu activated by the specified menu item" do
105
+ GetSubMenu(@file_menu, pos=0).should == 0
106
+ get_sub_menu(@file_menu, pos=0).should == nil
107
+ end
108
+ end # describe get_sub_menu
109
+
110
+ describe "#is_menu" do
111
+ # before(:all) { @menu = get_menu(@app.handle); p @menu; p @launched_test_app }
112
+
113
+ spec { use { success = IsMenu(@menu) } }
114
+ spec { use { success = menu?(@menu) } }
115
+
116
+ it "determines whether a given handle is a menu handle " do
117
+ IsMenu(@menu).should == 1
118
+ is_menu(@menu).should == true
119
+ menu?(@menu).should == true
120
+ menu?(@file_menu).should == true
121
+ IsMenu(not_a_handle).should == 0
122
+ is_menu(not_a_handle).should == false
123
+ menu?(not_a_handle).should == false
124
+ end
125
+ end # describe is_menu
126
+
127
+ describe "#set_menu" do
128
+ spec { use { success = SetMenu(window_handle=0, menu_handle=0) } }
129
+ spec { use { success = set_menu(window_handle=0, menu_handle=0) } }
130
+
131
+ it "assigns/removes menu of the specified top-level window" do
132
+ SetMenu(@app.handle, 0)
133
+ get_menu(@app.handle).should == nil
134
+ SetMenu(@app.handle, @menu)
135
+ get_menu(@app.handle).should == @menu
136
+ set_menu(@app.handle)
137
+ get_menu(@app.handle).should == nil
138
+ set_menu(@app.handle, @menu)
139
+ get_menu(@app.handle).should == @menu
140
+ end
67
141
 
68
- it "returns -1/nil if function fails " do
69
- GetMenuItemCount(not_a_handle).should == -1
70
- get_menu_item_count(not_a_handle).should == nil
142
+ it "snake_case api with nil, zero or omitted menu_handle removes menu" do
143
+ [[@app.handle, 0], [@app.handle, nil], [@app.handle]].each do |args|
144
+ set_menu(*args)
145
+ menu(@app.handle).should == nil
146
+ set_menu(@app.handle, @menu)
71
147
  end
72
- end # describe get_menu_item_count
148
+ end
149
+ end # describe set_menu
73
150
 
74
- describe "#get_menu_item_id" do
75
- spec{ use{ item_id = GetMenuItemID(@menu, pos=0) }}
76
- spec{ use{ item_id = get_menu_item_id(@menu, pos=0) }}
151
+ describe "#create_menu" do
152
+ after(:each) { destroy_menu(@new_menu) }
77
153
 
78
- it "retrieves the menu item identifier of a menu item located at the specified position" do
79
- GetMenuItemID(@file_menu, pos=0).should == ID_FILE_SAVE_AS
80
- get_menu_item_id(@file_menu, pos=0).should == ID_FILE_SAVE_AS
81
- end
154
+ spec { use { @new_menu = CreateMenu() } }
155
+ spec { use { @new_menu = create_menu() } }
82
156
 
83
- it "returns -1/nil if no menu item at given position" do
84
- GetMenuItemID(@menu, pos=4).should == -1
85
- get_menu_item_id(@menu, pos=4).should == nil
86
- end
157
+ it "original api creates a menu. The menu is initially empty, but it can be filled with menu items" do
158
+ @new_menu = CreateMenu()
159
+ menu?(@new_menu).should == true
160
+ end
87
161
 
88
- it "returns -1/nil if given menu item is in fact a sub-menu" do
89
- GetMenuItemID(@menu, pos=0).should == -1
90
- get_menu_item_id(@menu, pos=1).should == nil
91
- end
92
- end # describe get_menu_item_id
93
-
94
- describe "#get_sub_menu" do
95
- spec{ use{ sub_menu = GetSubMenu(@menu, pos=0) }}
96
- spec{ use{ sub_menu = get_sub_menu(@menu, pos=0) }}
97
-
98
- it "retrieves a handle to the drop-down menu or submenu activated by the specified menu item" do
99
- sub_menu1 = GetSubMenu(@menu, pos=0)
100
- sub_menu2 = get_sub_menu(@menu, pos=0)
101
- sub_menu1.should be_an Integer
102
- sub_menu1.should == @file_menu
103
- sub_menu1.should == sub_menu2
162
+ it "snake_case api creates a menu. The menu is initially empty." do
163
+ @new_menu = create_menu()
164
+ menu?(@new_menu).should == true
165
+ end
166
+ end # describe create_menu
167
+
168
+ describe "#create_popup_menu" do
169
+ after(:each) { destroy_menu(@sub_menu) }
170
+
171
+ spec { use { @sub_menu = CreatePopupMenu() } }
172
+ spec { use { @sub_menu = create_popup_menu() } }
173
+
174
+ context "creates a drop-down menu, submenu, or shortcut menu. The menu is initially empty" do
175
+ it "original api" do
176
+ @sub_menu = CreatePopupMenu()
177
+ menu?(@sub_menu).should == true
104
178
  end
105
179
 
106
- it "returns 0/nil if unable to find submenu activated by the specified menu item" do
107
- GetSubMenu(@file_menu, pos=0).should == 0
108
- get_sub_menu(@file_menu, pos=0).should == nil
180
+ it "snake_case api" do
181
+ @sub_menu = create_popup_menu()
182
+ menu?(@sub_menu).should == true
109
183
  end
110
- end # describe get_sub_menu
111
-
112
- describe "#is_menu" do
113
- before(:all){ @menu = get_menu(@app.handle) }
114
-
115
- spec{ use{ success = IsMenu(@menu) }}
116
- spec{ use{ success = menu?(@menu) }}
117
-
118
- it "determines whether a given handle is a menu handle " do
119
- IsMenu(@menu).should == 1
120
- is_menu(@menu).should == true
121
- menu?(@menu).should == true
122
- menu?(@file_menu).should == true
123
- IsMenu(not_a_handle).should == 0
124
- is_menu(not_a_handle).should == false
125
- menu?(not_a_handle).should == false
184
+ end
185
+ end # describe create_popup_menu
186
+
187
+ context 'functions related to menu item manipulation' do
188
+ before(:each) do
189
+ @new_menu = create_menu()
190
+ @sub_menu = create_menu()
191
+ @text = FFI::MemoryPointer.from_string("Appended Item Text")
192
+ end
193
+ after(:each) { destroy_menu(@new_menu) }
194
+
195
+ describe "#append_menu" do
196
+ spec { use { success = AppendMenu(menu_handle=0, flags=0, id_new_item=0, lp_new_item=nil) } }
197
+ spec { use { success = append_menu(menu_handle=0, flags=0, id_new_item=0, lp_new_item=nil) } }
198
+
199
+ it "appends a new item to the end of the specified menu bar, drop-down or context menu, returns 1/true " do
200
+ AppendMenu(@new_menu, flags=MF_STRING, 333, @text).should == 1
201
+ append_menu(@new_menu, flags=MF_STRING, 333, @text).should == true
202
+ menu_item_count(@new_menu).should == 2
203
+ menu_item_id(@new_menu, pos=0).should == 333
126
204
  end
127
- end # describe is_menu
128
-
129
- describe "#set_menu" do
130
- spec{ use{ success = SetMenu(window_handle=0, menu_handle=0) }}
131
- spec{ use{ success = set_menu(window_handle=0, menu_handle=0) }}
132
-
133
- it "assigns/removes menu of the specified top-level window" do
134
- SetMenu(@app.handle, menu_handle=0)
135
- get_menu(@app.handle).should == nil
136
- SetMenu(@app.handle, @menu)
137
- menu(@app.handle).should == @menu
138
- set_menu(@app.handle)
139
- menu(@app.handle).should == nil
140
- set_menu(@app.handle, @menu)
141
- menu(@app.handle).should == @menu
205
+
206
+ it "appends a submenu to the end of the specified menu bar, drop-down or context menu, returns 1/true " do
207
+ AppendMenu(@new_menu, MF_STRING | MF_POPUP, @sub_menu, @text).should == 1
208
+ append_menu(@new_menu, MF_STRING | MF_POPUP, @sub_menu, @text).should == true
209
+ menu_item_count(@new_menu).should == 2
210
+ get_sub_menu(@new_menu, pos=0).should == @sub_menu
211
+ get_sub_menu(@new_menu, pos=1).should == @sub_menu
142
212
  end
143
213
 
144
- it "snake_case api with nil, zero or omitted menu_handle removes menu" do
145
- [[@app.handle, 0], [@app.handle, nil], [@app.handle]].each do |args|
146
- set_menu(*args)
147
- menu(@app.handle).should == nil
148
- set_menu(@app.handle, @menu)
149
- end
214
+ it "returns 0/false if unable to appends a new item to the end of the specified menu" do
215
+ AppendMenu(0, flags=MF_STRING, 333, @text).should == 0
216
+ append_menu(0, flags=MF_STRING, 333, @text).should == false
150
217
  end
151
- end # describe set_menu
218
+ end # describe append_menu
152
219
 
153
- describe "#create_menu" do
154
- after(:each){ destroy_menu(@new_menu) }
220
+ describe "#insert_menu" do
221
+ before(:each) do
222
+ append_menu(@new_menu, MF_STRING, ID_FILE_SAVE_AS, FFI::MemoryPointer.from_string("Appended Item Text"))
223
+ end
155
224
 
156
- spec{ use{ @new_menu = CreateMenu() }}
157
- spec{ use{ @new_menu = create_menu() }}
225
+ spec { use { success = InsertMenu(menu_handle=0, position=0, flags=0, id_new_item=0, lp_new_item=nil) } }
226
+ spec { use { success = insert_menu(menu_handle=0, position=0, flags=0, id_new_item=0, lp_new_item=nil) } }
158
227
 
159
- it "original api creates a menu. The menu is initially empty, but it can be filled with menu items" do
160
- @new_menu = CreateMenu()
161
- menu?(@new_menu).should == true
228
+ it "inserts a new menu item into a menu, moving other items down the menu, returns 0/true" do
229
+ InsertMenu(@new_menu, 0, MF_STRING | MF_BYPOSITION, 1, @text).should == 1
230
+ insert_menu(@new_menu, 0, MF_STRING | MF_BYPOSITION, 0, @text).should == true
231
+ menu_item_count(@new_menu).should == 3
232
+ menu_item_id(@new_menu, pos=0).should == 0
233
+ menu_item_id(@new_menu, pos=1).should == 1
162
234
  end
163
235
 
164
- it "snake_case api creates a menu. The menu is initially empty." do
165
- @new_menu = create_menu()
166
- menu?(@new_menu).should == true
236
+ it "returns 0/false if unable to appends a new item to the end of the specified menu" do
237
+ InsertMenu(0, 0, flags=MF_STRING, 333, @text).should == 0
238
+ insert_menu(0, 0, flags=MF_STRING, 333, @text).should == false
167
239
  end
168
- end # describe create_menu
240
+ end # describe insert_menu
169
241
 
170
- context 'functions related to menu item manipulation' do
171
- before(:each)do
172
- @new_menu = create_menu()
173
- @sub_menu = create_menu()
174
- @text = FFI::MemoryPointer.from_string("Appended Item Text")
242
+ describe "#delete_menu" do
243
+ before(:each) do
244
+ append_menu(@new_menu, MF_STRING, 0, FFI::MemoryPointer.from_string("Item 0"))
245
+ append_menu(@new_menu, MF_STRING, 1, FFI::MemoryPointer.from_string("Item 1"))
246
+ append_menu(@new_menu, MF_POPUP | MF_STRING, @sub_menu, FFI::MemoryPointer.from_string("Sub 1"))
175
247
  end
176
- after(:each){ destroy_menu(@new_menu) }
177
-
178
- describe "#append_menu" do
179
- spec{ use{ success = AppendMenu(menu_handle=0, flags=0, id_new_item=0, lp_new_item=nil) }}
180
- spec{ use{ success = append_menu(menu_handle=0, flags=0, id_new_item=0, lp_new_item=nil) }}
181
-
182
- it "appends a new item to the end of the specified menu bar, drop-down or context menu, returns 1/true " do
183
- AppendMenu(@new_menu, flags=MF_STRING, 333, @text).should == 1
184
- append_menu(@new_menu, flags=MF_STRING, 333, @text).should == true
185
- menu_item_count(@new_menu).should == 2
186
- menu_item_id(@new_menu, pos=0).should == 333
187
- end
188
-
189
- it "appends a submenu to the end of the specified menu bar, drop-down or context menu, returns 1/true " do
190
- AppendMenu(@new_menu, MF_STRING | MF_POPUP, @sub_menu, @text).should == 1
191
- append_menu(@new_menu, MF_STRING | MF_POPUP, @sub_menu, @text).should == true
192
- menu_item_count(@new_menu).should == 2
193
- get_sub_menu(@new_menu, pos=0).should == @sub_menu
194
- get_sub_menu(@new_menu, pos=1).should == @sub_menu
195
- end
196
-
197
- it "returns 0/false if unable to appends a new item to the end of the specified menu" do
198
- AppendMenu(0, flags=MF_STRING, 333, @text).should == 0
199
- append_menu(0, flags=MF_STRING, 333, @text).should == false
200
- end
201
- end # describe append_menu
202
-
203
- describe "#insert_menu" do
204
- before(:each)do
205
- append_menu(@new_menu, MF_STRING, ID_FILE_SAVE_AS, FFI::MemoryPointer.from_string("Appended Item Text"))
206
- end
207
-
208
- spec{ use{ success = InsertMenu(menu_handle=0, position=0, flags=0, id_new_item=0, lp_new_item=nil) }}
209
- spec{ use{ success = insert_menu(menu_handle=0, position=0, flags=0, id_new_item=0, lp_new_item=nil) }}
210
-
211
- it "inserts a new menu item into a menu, moving other items down the menu, returns 0/true" do
212
- InsertMenu(@new_menu, 0, MF_STRING | MF_BYPOSITION, 1, @text).should == 1
213
- insert_menu(@new_menu, 0, MF_STRING | MF_BYPOSITION, 0, @text).should == true
214
- menu_item_count(@new_menu).should == 3
215
- menu_item_id(@new_menu, pos=0).should == 0
216
- menu_item_id(@new_menu, pos=1).should == 1
217
- end
218
-
219
- it "returns 0/false if unable to appends a new item to the end of the specified menu" do
220
- InsertMenu(0, 0, flags=MF_STRING, 333, @text).should == 0
221
- insert_menu(0, 0, flags=MF_STRING, 333, @text).should == false
222
- end
223
- end # describe insert_menu
224
-
225
- describe "#delete_menu" do
226
- before(:each)do
227
- append_menu(@new_menu, MF_STRING, 0, FFI::MemoryPointer.from_string("Item 0"))
228
- append_menu(@new_menu, MF_STRING, 1, FFI::MemoryPointer.from_string("Item 1"))
229
- append_menu(@new_menu, MF_POPUP | MF_STRING, @sub_menu, FFI::MemoryPointer.from_string("Sub 1"))
230
- end
231
-
232
- spec{ use{ success = DeleteMenu(menu_handle=0, position=0, flags=0) }}
233
- spec{ use{ success = delete_menu(menu_handle=0, position=0, flags=0) }}
234
-
235
- it "deletes an item from the specified menu, returns 1/true" do
236
- DeleteMenu(@new_menu, position=0, flags=MF_BYPOSITION).should == 1
237
- menu_item_count(@new_menu).should == 2
238
- delete_menu(@new_menu, position=0, flags=MF_BYPOSITION).should == true
239
- menu_item_count(@new_menu).should == 1
240
- end
241
-
242
- it "returns 0/false if unable to delete an item from the specified menu" do
243
- DeleteMenu(@new_menu, position=5, flags=MF_BYPOSITION).should == 0
244
- menu_item_count(@new_menu).should == 3
245
- delete_menu(0, position=0, flags=MF_BYPOSITION).should == false
246
- end
247
-
248
- it "destroys the handle to submenu and frees the memory if given menu item opens a submenu" do
249
- delete_menu(@new_menu, position=2, flags=MF_BYPOSITION).should == true
250
- menu_item_count(@new_menu).should == 2
251
- menu?(@sub_menu).should == false
252
- end
253
- end # describe delete_menu
254
- end # functions related to menu item manipulation
255
- end # context 'non-destructive methods'
256
-
257
- context 'destructive methods' do
258
- before(:each)do
259
- @app = launch_test_app
260
- @menu = get_menu(@app.handle)
261
- @file_menu = get_sub_menu(@menu, 0)
262
- end
263
- after(:each){ close_test_app if @launched_test_app }
264
248
 
265
- describe "#destroy_menu" do
266
- spec{ use{ success = DestroyMenu(menu_handle=0) }}
267
- spec{ use{ success = destroy_menu(menu_handle=0) }}
249
+ spec { use { success = DeleteMenu(menu_handle=0, position=0, flags=0) } }
250
+ spec { use { success = delete_menu(menu_handle=0, position=0, flags=0) } }
268
251
 
269
- it "original api destroys the specified menu and frees any memory that the menu occupies, returns 1" do
270
- DestroyMenu(@menu).should == 1
271
- menu?(@menu).should == false
252
+ it "deletes an item from the specified menu, returns 1/true" do
253
+ DeleteMenu(@new_menu, position=0, flags=MF_BYPOSITION).should == 1
254
+ menu_item_count(@new_menu).should == 2
255
+ delete_menu(@new_menu, position=0, flags=MF_BYPOSITION).should == true
256
+ menu_item_count(@new_menu).should == 1
272
257
  end
273
258
 
274
- it "snake_case api destroys the specified menu and frees any memory that the menu occupies, returns true" do
275
- destroy_menu(@menu).should == true
276
- menu?(@menu).should == false
259
+ it "returns 0/false if unable to delete an item from the specified menu" do
260
+ DeleteMenu(@new_menu, position=5, flags=MF_BYPOSITION).should == 0
261
+ menu_item_count(@new_menu).should == 3
262
+ delete_menu(0, position=0, flags=MF_BYPOSITION).should == false
277
263
  end
278
264
 
279
- it "returns 0/false if function was not successful " do
280
- destroy_menu(h_menu=0).should == false
281
- DestroyMenu(0).should == 0
265
+ it "destroys the handle to submenu and frees the memory if given menu item opens a submenu" do
266
+ delete_menu(@new_menu, position=2, flags=MF_BYPOSITION).should == true
267
+ menu_item_count(@new_menu).should == 2
268
+ menu?(@sub_menu).should == false
282
269
  end
283
- end # describe destroy_menu
270
+ end # describe delete_menu
271
+ end # functions related to menu item manipulation
272
+ end # context 'non-destructive methods'
273
+
274
+ context 'destructive methods' do
275
+ before(:each) do
276
+ @app = launch_test_app
277
+ @menu = get_menu(@app.handle)
278
+ @file_menu = get_sub_menu(@menu, 0)
279
+ end
280
+ after(:each) { close_test_app if @launched_test_app }
281
+
282
+ describe "#destroy_menu" do
283
+ spec { use { success = DestroyMenu(menu_handle=0) } }
284
+ spec { use { success = destroy_menu(menu_handle=0) } }
285
+
286
+ it "original api destroys the specified menu and frees any memory that the menu occupies, returns 1" do
287
+ DestroyMenu(@menu).should == 1
288
+ menu?(@menu).should == false
289
+ end
284
290
 
285
- end # context 'destructive methods' do
291
+ it "snake_case api destroys the specified menu and frees any memory that the menu occupies, returns true" do
292
+ destroy_menu(@menu).should == true
293
+ menu?(@menu).should == false
294
+ end
295
+
296
+ it "returns 0/false if function was not successful " do
297
+ destroy_menu(h_menu=0).should == false
298
+ DestroyMenu(0).should == 0
299
+ end
300
+ end # describe destroy_menu
286
301
 
287
- end # describe Win::Gui::Menu, ' defines a set of API functions related to menus'
302
+ end # context 'destructive methods' do
288
303
 
289
- # describe Win::Gui::Menu, ' defines convenience/service methods on top of Windows API' do
290
- # end # Win::Gui::Menu, ' defines convenience/service methods on top of Windows API'
291
- end
304
+ end # describe Win::Gui::Menu, ' defines a set of API functions related to menus'