Commit afc1fc5
authored
* test: Prepare for `stdole.IPicture` interface testing.
Imports `comtypes.gen.stdole` in `test_stream.py` and adds a new
test class `Test_Picture` with a placeholder test `test_ole_load_picture`.
This is a preliminary step to implement comprehensive testing for the
`stdole.IPicture` interface.
* test: Declare `OleLoadPicture` function in `test_stream.py`.
This includes setting its argument types and return type using `ctypes` to
allow for loading `stdole.IPicture` objects from a `IStream`.
* test: Add `create_pixel_data` function for BMP image generation.
Introduces a new function `create_pixel_data` in `test_stream.py` to
generate 32-bit BGRA BMP binary data. This utility function allows for
creating synthetic image data with specified dimensions, color, and DPI.
* test: Add `OleLoadPicture` test for `stdole.IPicture` creation.
This test validates the loading of a `stdole.IPicture` object from a
stream containing bitmap data using `_OleLoadPicture`. It involves
Windows API calls for device context, global memory management,
and stream operations, ensuring the correct instantiation of the
`IPicture` interface.
* refactor: Enhance `_create_stream` for flexible `stdole.IPicture` testing.
The `_create_stream` helper function in `test_stream.py` is refactored
to accept `handle` and `delete_on_release` parameters. This allows for
more controlled stream creation, particularly for testing scenarios
involving `stdole.IPicture` where the underlying global memory management
needs to be externalized.
* test: Introduce `get_dc` context manager for `stdole.IPicture` testing.
A new `get_dc` context manager is added to `test_stream.py` to encapsulate
the acquisition and release of device contexts (DC) via `_GetDC` and
`_ReleaseDC`. This improves the test for `stdole.IPicture` by:
- Reducing the number of variables within the main test logic, enhancing
readability.
- Separating setup (DC acquisition) and teardown (DC release) processes
from the core test assertions, making the test cleaner and more
maintainable.
* test: Add `global_alloc` and `global_lock` context managers for `stdole.IPicture` testing.
Two new context managers, `global_alloc` and `global_lock`, are introduced
in `test_stream.py`. These encapsulate `_GlobalAlloc`/`_GlobalFree` and
`_GlobalLock`/`_GlobalUnlock` Windows API calls respectively.
* test: Extract DPI retrieval into `get_screen_dpi` for `stdole.IPicture` testing.
The logic for retrieving screen DPI is extracted into a new helper function,
`get_screen_dpi`, in `test_stream.py`. This function utilizes the
`get_dc` context manager to safely obtain and release the device context.
* test: Verify `stdole.IPicture.Type` property after loading.
This is a direct validation of the `stdole.IPicture` interface's behavior.
1 parent 86d39f5 commit afc1fc5
1 file changed
+216
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | | - | |
3 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
4 | 29 | | |
5 | 30 | | |
| 31 | + | |
6 | 32 | | |
7 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
8 | 37 | | |
9 | 38 | | |
| 39 | + | |
| 40 | + | |
10 | 41 | | |
11 | 42 | | |
12 | 43 | | |
| |||
27 | 58 | | |
28 | 59 | | |
29 | 60 | | |
30 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
31 | 64 | | |
32 | 65 | | |
33 | | - | |
| 66 | + | |
34 | 67 | | |
35 | 68 | | |
36 | 69 | | |
| |||
158 | 191 | | |
159 | 192 | | |
160 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
161 | 373 | | |
162 | 374 | | |
0 commit comments