[pywin32-checkins] pywin32/win32/test test_clipboard.py,1.1,1.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-11-29 05:51:02
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1:/tmp/cvs-serv17365 Modified Files: test_clipboard.py Log Message: Test set and get of a bitmap handle on the clipboard. Index: test_clipboard.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_clipboard.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_clipboard.py 2 Sep 2003 00:16:23 -0000 1.1 --- test_clipboard.py 29 Nov 2003 05:50:57 -0000 1.2 *************** *** 1,7 **** # General test module for win32api - please add some :) ! import unittest ! import win32clipboard class CrashingTestCase(unittest.TestCase): --- 1,8 ---- # General test module for win32api - please add some :) ! import sys, os import unittest ! from win32clipboard import * ! import win32gui, win32con class CrashingTestCase(unittest.TestCase): *************** *** 11,18 **** obj = crasher() ! win32clipboard.OpenClipboard() ! win32clipboard.EmptyClipboard() ! # This used to crash - now correctly raises type error. ! self.assertRaises(TypeError, win32clipboard.SetClipboardData, 0, obj ) if __name__ == '__main__': --- 12,53 ---- obj = crasher() ! OpenClipboard() ! try: ! EmptyClipboard() ! # This used to crash - now correctly raises type error. ! self.assertRaises(TypeError, ! SetClipboardData, 0, obj ) ! finally: ! CloseClipboard() ! ! class TestBitmap(unittest.TestCase): ! def setUp(self): ! self.bmp_handle = None ! try: ! this_file = __file__ ! except NameError: ! this_file = sys.argv[0] ! this_dir = os.path.dirname(__file__) ! self.bmp_name = os.path.join(os.path.abspath(this_dir), ! "..", "Demos", "images", "smiley.bmp") ! self.failUnless(os.path.isfile(self.bmp_name)) ! flags = win32con.LR_DEFAULTSIZE | win32con.LR_LOADFROMFILE ! self.bmp_handle = win32gui.LoadImage(0, self.bmp_name, ! win32con.IMAGE_BITMAP, ! 0, 0, flags) ! self.failUnless(self.bmp_handle, "Failed to get a bitmap handle") ! ! def tearDown(self): ! if self.bmp_handle: ! win32gui.DeleteObject(self.bmp_handle) ! ! def test_bitmap_roundtrip(self): ! OpenClipboard() ! try: ! SetClipboardData(win32con.CF_BITMAP, self.bmp_handle) ! got_handle = GetClipboardDataHandle(win32con.CF_BITMAP) ! self.failUnlessEqual(got_handle, self.bmp_handle) ! finally: ! CloseClipboard() if __name__ == '__main__': |