windows-pr 0.8.7 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/CHANGES +15 -0
  2. data/MANIFEST +9 -1
  3. data/lib/windows/clipboard.rb +1 -2
  4. data/lib/windows/com/automation.rb +58 -0
  5. data/lib/windows/com.rb +0 -1
  6. data/lib/windows/console.rb +0 -1
  7. data/lib/windows/debug.rb +0 -1
  8. data/lib/windows/device_io.rb +0 -1
  9. data/lib/windows/error.rb +37 -32
  10. data/lib/windows/eventlog.rb +5 -6
  11. data/lib/windows/file.rb +10 -36
  12. data/lib/windows/file_mapping.rb +0 -1
  13. data/lib/windows/filesystem.rb +0 -1
  14. data/lib/windows/gdi/bitmap.rb +0 -1
  15. data/lib/windows/gdi/device_context.rb +0 -1
  16. data/lib/windows/gdi/painting_drawing.rb +0 -1
  17. data/lib/windows/handle.rb +0 -1
  18. data/lib/windows/library.rb +0 -1
  19. data/lib/windows/memory.rb +0 -1
  20. data/lib/windows/msvcrt/buffer.rb +0 -1
  21. data/lib/windows/msvcrt/directory.rb +8 -9
  22. data/lib/windows/msvcrt/file.rb +0 -1
  23. data/lib/windows/msvcrt/io.rb +0 -1
  24. data/lib/windows/msvcrt/string.rb +0 -1
  25. data/lib/windows/msvcrt/time.rb +0 -1
  26. data/lib/windows/national.rb +0 -1
  27. data/lib/windows/network/management.rb +523 -0
  28. data/lib/windows/network/snmp.rb +90 -0
  29. data/lib/windows/network/winsock.rb +126 -0
  30. data/lib/windows/nio.rb +0 -1
  31. data/lib/windows/ntfs/file.rb +58 -0
  32. data/lib/windows/path.rb +105 -38
  33. data/lib/windows/pipe.rb +0 -1
  34. data/lib/windows/security.rb +292 -6
  35. data/lib/windows/service.rb +0 -1
  36. data/lib/windows/shell.rb +4 -1
  37. data/lib/windows/sound.rb +0 -1
  38. data/lib/windows/synchronize.rb +0 -1
  39. data/lib/windows/system_info.rb +0 -1
  40. data/lib/windows/thread.rb +0 -1
  41. data/lib/windows/time.rb +0 -1
  42. data/lib/windows/unicode.rb +0 -1
  43. data/lib/windows/volume.rb +0 -1
  44. data/lib/windows/window/dialog.rb +89 -0
  45. data/lib/windows/window/message.rb +289 -0
  46. data/lib/windows/window/properties.rb +18 -0
  47. data/lib/windows/window/timer.rb +17 -0
  48. data/lib/windows/window.rb +0 -1
  49. data/test/tc_com.rb +17 -19
  50. data/test/tc_msvcrt_directory.rb +57 -27
  51. data/test/tc_msvcrt_string.rb +74 -18
  52. data/windows-pr.gemspec +4 -5
  53. metadata +33 -15
@@ -0,0 +1,289 @@
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Window
5
+ module Message
6
+ API.auto_namespace = 'Windows::Window::Message'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = false
10
+
11
+ # These constants are in winuser.h
12
+
13
+ BSF_QUERY = 0x00000001
14
+ BSF_IGNORECURRENTTASK = 0x00000002
15
+ BSF_FLUSHDISK = 0x00000004
16
+ BSF_NOHANG = 0x00000008
17
+ BSF_POSTMESSAGE = 0x00000010
18
+ BSF_FORCEIFHUNG = 0x00000020
19
+ BSF_NOTIMEOUTIFNOTHUNG = 0x00000040
20
+ BSF_ALLOWSFW = 0x00000080
21
+ BSF_SENDNOTIFYMESSAGE = 0x00000100
22
+ BSF_RETURNHDESK = 0x00000200
23
+ BSF_LUID = 0x00000400
24
+
25
+ SMTO_NORMAL = 0x0000
26
+ SMTO_BLOCK = 0x0001
27
+ SMTO_ABORTIFHUNG = 0x0002
28
+ SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
29
+
30
+ WM_NULL = 0x0000
31
+ WM_CREATE = 0x0001
32
+ WM_DESTROY = 0x0002
33
+ WM_MOVE = 0x0003
34
+ WM_SIZE = 0x0005
35
+ WM_ACTIVATE = 0x0006
36
+ WM_SETFOCUS = 0x0007
37
+ WM_KILLFOCUS = 0x0008
38
+ WM_ENABLE = 0x000A
39
+ WM_SETREDRAW = 0x000B
40
+ WM_SETTEXT = 0x000C
41
+ WM_GETTEXT = 0x000D
42
+ WM_GETTEXTLENGTH = 0x000E
43
+ WM_PAINT = 0x000F
44
+ WM_CLOSE = 0x0010
45
+ WM_QUERYENDSESSION = 0x0011
46
+ WM_QUERYOPEN = 0x0013
47
+ WM_ENDSESSION = 0x0016
48
+ WM_QUIT = 0x0012
49
+ WM_ERASEBKGND = 0x0014
50
+ WM_SYSCOLORCHANGE = 0x0015
51
+ WM_SHOWWINDOW = 0x0018
52
+ WM_WININICHANGE = 0x001A
53
+ WM_SETTINGCHANGE = WM_WININICHANGE
54
+ WM_DEVMODECHANGE = 0x001B
55
+ WM_ACTIVATEAPP = 0x001C
56
+ WM_FONTCHANGE = 0x001D
57
+ WM_TIMECHANGE = 0x001E
58
+ WM_CANCELMODE = 0x001F
59
+ WM_SETCURSOR = 0x0020
60
+ WM_MOUSEACTIVATE = 0x0021
61
+ WM_CHILDACTIVATE = 0x0022
62
+ WM_QUEUESYNC = 0x0023
63
+ WM_GETMINMAXINFO = 0x0024
64
+ WM_PAINTICON = 0x0026
65
+ WM_ICONERASEBKGND = 0x0027
66
+ WM_NEXTDLGCTL = 0x0028
67
+ WM_SPOOLERSTATUS = 0x002A
68
+ WM_DRAWITEM = 0x002B
69
+ WM_MEASUREITEM = 0x002C
70
+ WM_DELETEITEM = 0x002D
71
+ WM_VKEYTOITEM = 0x002E
72
+ WM_CHARTOITEM = 0x002F
73
+ WM_SETFONT = 0x0030
74
+ WM_GETFONT = 0x0031
75
+ WM_SETHOTKEY = 0x0032
76
+ WM_GETHOTKEY = 0x0033
77
+ WM_QUERYDRAGICON = 0x0037
78
+ WM_COMPAREITEM = 0x0039
79
+ WM_GETOBJECT = 0x003D
80
+ WM_COMPACTING = 0x0041
81
+ WM_COMMNOTIFY = 0x0044
82
+ WM_WINDOWPOSCHANGING = 0x0046
83
+ WM_WINDOWPOSCHANGED = 0x0047
84
+ WM_POWER = 0x0048
85
+ WM_COPYDATA = 0x004A
86
+ WM_CANCELJOURNAL = 0x004B
87
+ WM_NOTIFY = 0x004E
88
+ WM_INPUTLANGCHANGEREQUEST = 0x0050
89
+ WM_INPUTLANGCHANGE = 0x0051
90
+ WM_TCARD = 0x0052
91
+ WM_HELP = 0x0053
92
+ WM_USERCHANGED = 0x0054
93
+ WM_NOTIFYFORMAT = 0x0055
94
+ WM_CONTEXTMENU = 0x007B
95
+ WM_STYLECHANGING = 0x007C
96
+ WM_STYLECHANGED = 0x007D
97
+ WM_DISPLAYCHANGE = 0x007E
98
+ WM_GETICON = 0x007F
99
+ WM_SETICON = 0x0080
100
+ WM_NCCREATE = 0x0081
101
+ WM_NCDESTROY = 0x0082
102
+ WM_NCCALCSIZE = 0x0083
103
+ WM_NCHITTEST = 0x0084
104
+ WM_NCPAINT = 0x0085
105
+ WM_NCACTIVATE = 0x0086
106
+ WM_GETDLGCODE = 0x0087
107
+ WM_SYNCPAINT = 0x0088
108
+ WM_NCMOUSEMOVE = 0x00A0
109
+ WM_NCLBUTTONDOWN = 0x00A1
110
+ WM_NCLBUTTONUP = 0x00A2
111
+ WM_NCLBUTTONDBLCLK = 0x00A3
112
+ WM_NCRBUTTONDOWN = 0x00A4
113
+ WM_NCRBUTTONUP = 0x00A5
114
+ WM_NCRBUTTONDBLCLK = 0x00A6
115
+ WM_NCMBUTTONDOWN = 0x00A7
116
+ WM_NCMBUTTONUP = 0x00A8
117
+ WM_NCMBUTTONDBLCLK = 0x00A9
118
+ WM_NCXBUTTONDOWN = 0x00AB
119
+ WM_NCXBUTTONUP = 0x00AC
120
+ WM_NCXBUTTONDBLCLK = 0x00AD
121
+ WM_INPUT = 0x00FF
122
+ WM_KEYFIRST = 0x0100
123
+ WM_KEYDOWN = 0x0100
124
+ WM_KEYUP = 0x0101
125
+ WM_CHAR = 0x0102
126
+ WM_DEADCHAR = 0x0103
127
+ WM_SYSKEYDOWN = 0x0104
128
+ WM_SYSKEYUP = 0x0105
129
+ WM_SYSCHAR = 0x0106
130
+ WM_SYSDEADCHAR = 0x0107
131
+ WM_UNICHAR = 0x0109
132
+ WM_IME_STARTCOMPOSITION = 0x010D
133
+ WM_IME_ENDCOMPOSITION = 0x010E
134
+ WM_IME_COMPOSITION = 0x010F
135
+ WM_IME_KEYLAST = 0x010F
136
+ WM_INITDIALOG = 0x0110
137
+ WM_COMMAND = 0x0111
138
+ WM_SYSCOMMAND = 0x0112
139
+ WM_TIMER = 0x0113
140
+ WM_HSCROLL = 0x0114
141
+ WM_VSCROLL = 0x0115
142
+ WM_INITMENU = 0x0116
143
+ WM_INITMENUPOPUP = 0x0117
144
+ WM_MENUSELECT = 0x011F
145
+ WM_MENUCHAR = 0x0120
146
+ WM_ENTERIDLE = 0x0121
147
+ WM_MENURBUTTONUP = 0x0122
148
+ WM_MENUDRAG = 0x0123
149
+ WM_MENUGETOBJECT = 0x0124
150
+ WM_UNINITMENUPOPUP = 0x0125
151
+ WM_MENUCOMMAND = 0x0126
152
+ WM_CHANGEUISTATE = 0x0127
153
+ WM_UPDATEUISTATE = 0x0128
154
+ WM_QUERYUISTATE = 0x0129
155
+ WM_CTLCOLORMSGBOX = 0x0132
156
+ WM_CTLCOLOREDIT = 0x0133
157
+ WM_CTLCOLORLISTBOX = 0x0134
158
+ WM_CTLCOLORBTN = 0x0135
159
+ WM_CTLCOLORDLG = 0x0136
160
+ WM_CTLCOLORSCROLLBAR = 0x0137
161
+ WM_CTLCOLORSTATIC = 0x0138
162
+ WM_MOUSEFIRST = 0x0200
163
+ WM_MOUSEMOVE = 0x0200
164
+ WM_LBUTTONDOWN = 0x0201
165
+ WM_LBUTTONUP = 0x0202
166
+ WM_LBUTTONDBLCLK = 0x0203
167
+ WM_RBUTTONDOWN = 0x0204
168
+ WM_RBUTTONUP = 0x0205
169
+ WM_RBUTTONDBLCLK = 0x0206
170
+ WM_MBUTTONDOWN = 0x0207
171
+ WM_MBUTTONUP = 0x0208
172
+ WM_MBUTTONDBLCLK = 0x0209
173
+ WM_MOUSEWHEEL = 0x020A
174
+ WM_XBUTTONDOWN = 0x020B
175
+ WM_XBUTTONUP = 0x020C
176
+ WM_XBUTTONDBLCLK = 0x020D
177
+ WM_MOUSELAST = 0x020D # Assume Win2k or later
178
+ WM_PARENTNOTIFY = 0x0210
179
+ WM_ENTERMENULOOP = 0x0211
180
+ WM_EXITMENULOOP = 0x0212
181
+ WM_NEXTMENU = 0x0213
182
+ WM_SIZING = 0x0214
183
+ WM_CAPTURECHANGED = 0x0215
184
+ WM_MOVING = 0x0216
185
+ WM_POWERBROADCAST = 0x0218
186
+ WM_DEVICECHANGE = 0x0219
187
+ WM_MDICREATE = 0x0220
188
+ WM_MDIDESTROY = 0x0221
189
+ WM_MDIACTIVATE = 0x0222
190
+ WM_MDIRESTORE = 0x0223
191
+ WM_MDINEXT = 0x0224
192
+ WM_MDIMAXIMIZE = 0x0225
193
+ WM_MDITILE = 0x0226
194
+ WM_MDICASCADE = 0x0227
195
+ WM_MDIICONARRANGE = 0x0228
196
+ WM_MDIGETACTIVE = 0x0229
197
+ WM_MDISETMENU = 0x0230
198
+ WM_ENTERSIZEMOVE = 0x0231
199
+ WM_EXITSIZEMOVE = 0x0232
200
+ WM_DROPFILES = 0x0233
201
+ WM_MDIREFRESHMENU = 0x0234
202
+ WM_IME_SETCONTEXT = 0x0281
203
+ WM_IME_NOTIFY = 0x0282
204
+ WM_IME_CONTROL = 0x0283
205
+ WM_IME_COMPOSITIONFULL = 0x0284
206
+ WM_IME_SELECT = 0x0285
207
+ WM_IME_CHAR = 0x0286
208
+ WM_IME_REQUEST = 0x0288
209
+ WM_IME_KEYDOWN = 0x0290
210
+ WM_IME_KEYUP = 0x0291
211
+ WM_MOUSEHOVER = 0x02A1
212
+ WM_MOUSELEAVE = 0x02A3
213
+ WM_NCMOUSEHOVER = 0x02A0
214
+ WM_NCMOUSELEAVE = 0x02A2
215
+ WM_WTSSESSION_CHANGE = 0x02B1
216
+ WM_TABLET_FIRST = 0x02c0
217
+ WM_TABLET_LAST = 0x02df
218
+ WM_CUT = 0x0300
219
+ WM_COPY = 0x0301
220
+ WM_PASTE = 0x0302
221
+ WM_CLEAR = 0x0303
222
+ WM_UNDO = 0x0304
223
+ WM_RENDERFORMAT = 0x0305
224
+ WM_RENDERALLFORMATS = 0x0306
225
+ WM_DESTROYCLIPBOARD = 0x0307
226
+ WM_DRAWCLIPBOARD = 0x0308
227
+ WM_PAINTCLIPBOARD = 0x0309
228
+ WM_VSCROLLCLIPBOARD = 0x030A
229
+ WM_SIZECLIPBOARD = 0x030B
230
+ WM_ASKCBFORMATNAME = 0x030C
231
+ WM_CHANGECBCHAIN = 0x030D
232
+ WM_HSCROLLCLIPBOARD = 0x030E
233
+ WM_QUERYNEWPALETTE = 0x030F
234
+ WM_PALETTEISCHANGING = 0x0310
235
+ WM_PALETTECHANGED = 0x0311
236
+ WM_HOTKEY = 0x0312
237
+ WM_PRINT = 0x0317
238
+ WM_PRINTCLIENT = 0x0318
239
+ WM_APPCOMMAND = 0x0319
240
+ WM_THEMECHANGED = 0x031A
241
+ WM_HANDHELDFIRST = 0x0358
242
+ WM_HANDHELDLAST = 0x035F
243
+ WM_AFXFIRST = 0x0360
244
+ WM_AFXLAST = 0x037F
245
+ WM_PENWINFIRST = 0x0380
246
+ WM_PENWINLAST = 0x038F
247
+ WM_APP = 0x8000
248
+ WM_USER = 0x0400
249
+
250
+ # I'd rather not mixin Windows::SystemInfo
251
+ getVersionEx = Win32::API.new('GetVersionEx', 'P', 'B')
252
+ vbuf = "\0" * 128
253
+ vinfo = [148, 0 ,0, 0, 0, vbuf].pack("LLLLLa128")
254
+ getVersionEx.call(vinfo)
255
+ info = vinfo.unpack("LLLLLa128")
256
+
257
+ if info[2] >= 1
258
+ WM_KEYLAST = 0x0109 # Windows XP or later
259
+ else
260
+ WM_KEYLAST = 0x0108 # Windows 2000
261
+ end
262
+
263
+ API.new('BroadcastSystemMessage', 'LPILL', 'L', 'user32')
264
+ API.new('BroadcastSystemMessageEx', 'LPILLP', 'L', 'user32')
265
+ API.new('DispatchMessage', 'P', 'L', 'user32')
266
+ API.new('GetInputState', 'V', 'B', 'user32')
267
+ API.new('GetMessage', 'PLII', 'B', 'user32')
268
+ API.new('GetMessageExtraInfo', 'V', 'L', 'user32')
269
+ API.new('GetMessagePos', 'V', 'L', 'user32')
270
+ API.new('GetMessageTime', 'V', 'L', 'user32')
271
+ API.new('GetQueueStatus', 'I', 'L', 'user32')
272
+ API.new('InSendMessage', 'V', 'B', 'user32')
273
+ API.new('InSendMessageEx', 'L', 'L', 'user32')
274
+ API.new('PeekMessage', 'PLIII', 'B', 'user32')
275
+ API.new('PostMessage', 'PLLL', 'B', 'user32')
276
+ API.new('PostQuitMessage', 'I', 'V', 'user32')
277
+ API.new('PostThreadMessage', 'LILL', 'B', 'user32')
278
+ API.new('RegisterWindowMessage', 'P', 'I', 'user32')
279
+ API.new('ReplyMessage', 'L', 'B', 'user32')
280
+ API.new('SendMessage', 'LILL', 'L', 'user32')
281
+ API.new('SendMessageCallback', 'LILLKP', 'B', 'user32')
282
+ API.new('SendMessageTimeout', 'LILLIIP', 'L', 'user32')
283
+ API.new('SendNotifyMessage', 'LILLIIP', 'L', 'user32')
284
+ API.new('SetMessageExtraInfo', 'L', 'L', 'user32')
285
+ API.new('TranslateMessage', 'P', 'B', 'user32')
286
+ API.new('WaitMessage', 'V', 'B', 'user32')
287
+ end
288
+ end
289
+ end
@@ -0,0 +1,18 @@
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Window
5
+ module Properties
6
+ API.auto_namespace = 'Windows::Window::Properties'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = true
10
+
11
+ API.new('EnumProps', 'LK', 'I', 'user32')
12
+ API.new('EnumPropsEx', 'LKL', 'I', 'user32')
13
+ API.new('GetProp', 'LP', 'L', 'user32')
14
+ API.new('RemoveProp', 'LP', 'L', 'user32')
15
+ API.new('SetProp', 'LPL', 'B', 'user32')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Window
5
+ module Timer
6
+ API.auto_namespace = 'Windows::Window::Timer'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = false
10
+
11
+ API.new('KillTimer', 'LP', 'B', 'user32')
12
+ API.new('QueryPerformanceCounter', 'P', 'B', 'user32')
13
+ API.new('QueryPerformanceFrequency', 'P', 'B', 'user32')
14
+ API.new('SetTimer', 'LIIK', 'P', 'user32')
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,4 @@
1
1
  require 'windows/api'
2
- include Windows
3
2
 
4
3
  # See WinUser.h
5
4
 
data/test/tc_com.rb CHANGED
@@ -6,29 +6,27 @@
6
6
  require "windows/com"
7
7
  require "test/unit"
8
8
 
9
- class COMFoo
9
+ class TC_Windows_COM < Test::Unit::TestCase
10
10
  include Windows::COM
11
- end
12
11
 
13
- class TC_Windows_COM < Test::Unit::TestCase
14
- def setup
15
- @foo = COMFoo.new
16
- end
17
-
18
12
  def test_method_constants
19
- assert_not_nil(COMFoo::BindMoniker)
20
- assert_not_nil(COMFoo::CLSIDFromProgID)
21
- assert_not_nil(COMFoo::CLSIDFromProgIDEx)
22
- assert_not_nil(COMFoo::CoAddRefServerProcess)
23
- assert_not_nil(COMFoo::CoAllowSetForegroundWindow)
24
- assert_not_nil(COMFoo::CoCancelCall)
25
- assert_not_nil(COMFoo::CoCopyProxy)
26
- assert_not_nil(COMFoo::CoCreateFreeThreadedMarshaler)
27
- assert_not_nil(COMFoo::CoCreateGuid)
28
- assert_not_nil(COMFoo::CoCreateInstance)
13
+ assert_respond_to(self, :BindMoniker)
14
+ assert_respond_to(self, :CLSIDFromProgID)
15
+ assert_respond_to(self, :CLSIDFromProgIDEx)
16
+ assert_respond_to(self, :CoAddRefServerProcess)
17
+ assert_respond_to(self, :CoAllowSetForegroundWindow)
18
+ assert_respond_to(self, :CoCancelCall)
19
+ assert_respond_to(self, :CoCopyProxy)
20
+ assert_respond_to(self, :CoCreateFreeThreadedMarshaler)
21
+ assert_respond_to(self, :CoCreateGuid)
22
+ assert_respond_to(self, :CoCreateInstance)
29
23
  end
30
24
 
31
- def teardown
32
- @foo = nil
25
+ def test_numeric_constants
26
+ assert_equal(0, VT_EMPTY)
27
+ assert_equal(1, VT_NULL)
28
+ assert_equal(2, VT_I2)
29
+ assert_equal(3, VT_I4)
30
+ assert_equal(4, VT_R4)
33
31
  end
34
32
  end
@@ -4,64 +4,94 @@
4
4
  # Test case for the Windows::MSVCRT::File module.
5
5
  #####################################################################
6
6
  require 'windows/msvcrt/directory'
7
+ require 'fileutils'
7
8
  require 'test/unit'
8
9
 
9
- class MDirectoryFoo
10
+ class TC_Windows_MSVCRT_Directory < Test::Unit::TestCase
10
11
  include Windows::MSVCRT::Directory
11
- end
12
12
 
13
- class TC_Windows_MSVCRT_Directory < Test::Unit::TestCase
14
13
  def setup
15
- @foo = MDirectoryFoo.new
14
+ @pwd = Dir.pwd
15
+ @dir = 'delete_me'
16
+ @buf = 0.chr * 260
16
17
  end
17
18
 
18
19
  def test_method_constants
19
- assert_not_nil(MDirectoryFoo::Chdir)
20
- assert_not_nil(MDirectoryFoo::Wchdir)
21
- assert_not_nil(MDirectoryFoo::Chdrive)
22
- assert_not_nil(MDirectoryFoo::Getcwd)
23
- assert_not_nil(MDirectoryFoo::Wgetcwd)
24
- assert_not_nil(MDirectoryFoo::Getdcwd)
25
- assert_not_nil(MDirectoryFoo::Getdiskfree)
26
- assert_not_nil(MDirectoryFoo::Getdrive)
27
- assert_not_nil(MDirectoryFoo::Getdrives)
28
- assert_not_nil(MDirectoryFoo::Mkdir)
29
- assert_not_nil(MDirectoryFoo::Wmkdir)
30
- assert_not_nil(MDirectoryFoo::Rmdir)
31
- assert_not_nil(MDirectoryFoo::Wrmdir)
32
- assert_not_nil(MDirectoryFoo::Searchenv)
33
- assert_not_nil(MDirectoryFoo::Wsearchenv)
20
+ assert_not_nil(Chdir)
21
+ assert_not_nil(Wchdir)
22
+ assert_not_nil(Chdrive)
23
+ assert_not_nil(Getcwd)
24
+ assert_not_nil(Wgetcwd)
25
+ assert_not_nil(Getdcwd)
26
+ assert_not_nil(Getdiskfree)
27
+ assert_not_nil(Getdrive)
28
+ assert_not_nil(Getdrives)
29
+ assert_not_nil(Mkdir)
30
+ assert_not_nil(Wmkdir)
31
+ assert_not_nil(Rmdir)
32
+ assert_not_nil(Wrmdir)
33
+ assert_not_nil(Searchenv)
34
+ assert_not_nil(Wsearchenv)
34
35
  end
35
36
 
36
37
  def test_chdir
37
- assert_respond_to(@foo, :chdir)
38
+ assert_respond_to(self, :chdir)
39
+ assert_nothing_raised{ chdir('..') }
40
+ assert_equal(File.dirname(@pwd), Dir.pwd)
38
41
  end
39
42
 
40
43
  def test_wchdir
41
- assert_respond_to(@foo, :wchdir)
44
+ assert_respond_to(self, :wchdir)
45
+ assert_nothing_raised{ wchdir("C:\\") }
42
46
  end
43
47
 
44
48
  def test_chdrive
45
- assert_respond_to(@foo, :chdrive)
49
+ assert_respond_to(self, :chdrive)
46
50
  end
47
51
 
48
52
  def test_getcwd
49
- assert_respond_to(@foo, :getcwd)
53
+ assert_respond_to(self, :getcwd)
50
54
  end
51
55
 
52
56
  def test_wgetcwd
53
- assert_respond_to(@foo, :wgetcwd)
57
+ assert_respond_to(self, :wgetcwd)
54
58
  end
55
59
 
56
60
  def test_getdcwd
57
- assert_respond_to(@foo, :getdcwd)
61
+ assert_respond_to(self, :getdcwd)
58
62
  end
59
63
 
60
64
  def test_wgetdcwd
61
- assert_respond_to(@foo, :wgetdcwd)
65
+ assert_respond_to(self, :wgetdcwd)
66
+ end
67
+
68
+ def test_mkdir
69
+ assert_respond_to(self, :mkdir)
70
+ assert_nothing_raised{ mkdir(@dir) }
71
+ assert_equal(true, File.exists?(@dir))
72
+ end
73
+
74
+ def test_rmdir
75
+ Dir.mkdir(@dir) unless File.exists?(@dir)
76
+ assert_respond_to(self, :rmdir)
77
+ assert_nothing_raised{ rmdir(@dir) }
78
+ assert_equal(false, File.exists?(@dir))
79
+ end
80
+
81
+ def test_searchenv
82
+ possible = [
83
+ "c:\\winnt\\system32\\notepad.exe",
84
+ "c:\\windows\\system32\\notepad.exe"
85
+ ]
86
+ assert_respond_to(self, :searchenv)
87
+ assert_nothing_raised{ searchenv("notepad.exe", "PATH", @buf) }
88
+ assert_equal(true, possible.include?(@buf.strip.downcase))
62
89
  end
63
90
 
64
91
  def teardown
65
- @foo = nil
92
+ FileUtils.rm_f(@dir) if File.exists?(@dir)
93
+ @pwd = nil
94
+ @dir = nil
95
+ @buf = 0
66
96
  end
67
97
  end
@@ -6,31 +6,87 @@
6
6
  require 'windows/msvcrt/string'
7
7
  require 'test/unit'
8
8
 
9
- class MStringFoo
9
+ class TC_Windows_MSVCRT_String < Test::Unit::TestCase
10
10
  include Windows::MSVCRT::String
11
- end
12
11
 
13
- class TC_Windows_MSVCRT_String < Test::Unit::TestCase
14
12
  def setup
15
- @foo = MStringFoo.new
13
+ @buf = 0.chr * 260
16
14
  end
17
-
15
+
18
16
  def test_method_constants
19
- assert_not_nil(MStringFoo::Strcmp)
20
- assert_not_nil(MStringFoo::Strcpy)
21
- assert_not_nil(MStringFoo::Strcspn)
22
- assert_not_nil(MStringFoo::Strlen)
23
- assert_not_nil(MStringFoo::Strncpy)
24
- assert_not_nil(MStringFoo::Strrchr)
25
- assert_not_nil(MStringFoo::Strrev)
26
- assert_not_nil(MStringFoo::Strtok)
27
- end
28
-
17
+ assert_not_nil(Strcmp)
18
+ assert_not_nil(Strcpy)
19
+ assert_not_nil(Strcspn)
20
+ assert_not_nil(Strlen)
21
+ assert_not_nil(Strncpy)
22
+ assert_not_nil(Strrchr)
23
+ assert_not_nil(Strrev)
24
+ assert_not_nil(Strtok)
25
+ end
26
+
27
+ def test_strchr
28
+ assert_respond_to(self, :strchr)
29
+ assert_equal('llo', strchr('hello', 'l'[0]))
30
+ assert_equal(nil, strchr('hello', 'x'[0]))
31
+ end
32
+
33
+ def test_strchr_with_zero
34
+ assert_nil(strchr(0, 'l'[0]))
35
+ assert_nil(strchr('hello', 0))
36
+ end
37
+
38
+ def test_strchr_expected_errors
39
+ assert_raise(ArgumentError){ strchr }
40
+ assert_raise(ArgumentError){ strchr('hello') }
41
+ end
42
+
29
43
  def test_strcmp
30
- assert_respond_to(@foo, :strcmp)
44
+ assert_respond_to(self, :strcmp)
45
+ assert_equal(-1, strcmp('alpha', 'beta'))
46
+ assert_equal(1, strcmp('beta', 'alpha'))
47
+ assert_equal(0, strcmp('alpha', 'alpha'))
48
+ end
49
+
50
+ def test_strcmp_expected_errors
51
+ assert_raise(ArgumentError){ strcmp }
52
+ assert_raise(ArgumentError){ strcmp('alpha') }
31
53
  end
32
-
54
+
55
+ def test_strcpy
56
+ assert_respond_to(self, :strcpy)
57
+ assert_kind_of(Fixnum, strcpy(@buf, ['hello'].pack('p*').unpack('L')[0]))
58
+ assert_equal('hello', @buf.strip)
59
+ end
60
+
61
+ def test_strcspn
62
+ assert_respond_to(self, :strcspn)
63
+ assert_equal(3, strcspn('abcxyz123', '&^(x'))
64
+ assert_equal(9, strcspn('abcxyz123', '&^(('))
65
+ end
66
+
67
+ def test_strcspn_expected_errors
68
+ assert_raise(ArgumentError){ strcspn }
69
+ assert_raise(ArgumentError){ strcspn('alpha') }
70
+ end
71
+
72
+ def test_strlen
73
+ assert_respond_to(self, :strlen)
74
+ assert_equal(5, strlen('hello'))
75
+ assert_equal(0, strlen(''))
76
+ end
77
+
78
+ def test_strlen_expected_errors
79
+ assert_raise(ArgumentError){ strlen }
80
+ assert_raise(ArgumentError){ strlen('a', 'b') }
81
+ end
82
+
83
+ def test_strncpy
84
+ assert_respond_to(self, :strncpy)
85
+ assert_equal('alp', strncpy(@buf, 'alpha', 3))
86
+ assert_equal('alp', @buf.strip)
87
+ end
88
+
33
89
  def teardown
34
- @foo = nil
90
+ @buf = nil
35
91
  end
36
92
  end
data/windows-pr.gemspec CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "windows-pr"
5
- gem.version = "0.8.7"
5
+ gem.version = "0.9.0"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
@@ -12,14 +12,13 @@ spec = Gem::Specification.new do |gem|
12
12
  gem.description = "Windows functions and constants bundled via Win32::API"
13
13
  gem.test_files = Dir["test/tc*"]
14
14
  gem.has_rdoc = true
15
- gem.files = Dir["doc/*.txt"] + Dir["lib/windows/*.rb"]
16
- gem.files += Dir["lib/windows/msvcrt/*.rb"]
17
- gem.files += Dir["lib/windows/gdi/*.rb"]
15
+ gem.files = Dir["doc/*.txt"] + Dir["lib/windows/**/*.rb"]
18
16
  gem.files += Dir["test/*"] + Dir["[A-Z]*"]
19
17
  gem.files.reject! { |fn| fn.include? "CVS" }
20
18
  gem.require_path = "lib"
21
19
  gem.extra_rdoc_files = ["MANIFEST", "README", "CHANGES"]
22
- gem.add_dependency("windows-api", ">= 0.2.3")
20
+ gem.add_dependency("windows-api", ">= 0.2.4")
21
+ gem.add_dependency("win32-api", ">= 1.2.0")
23
22
  end
24
23
 
25
24
  if $0 == __FILE__