1from Foundation import *
2from PyObjCTools.TestSupport import *
3
4
5class TestNSThread (TestCase):
6    def testMethods(self):
7        self.assertResultIsBOOL(NSThread.isMultiThreaded)
8        self.assertArgIsSEL(NSThread.detachNewThreadSelector_toTarget_withObject_, 0, b'v@:@')
9        self.assertResultIsBOOL(NSThread.setThreadPriority_)
10
11        self.assertArgIsSEL(NSThread.performSelectorOnMainThread_withObject_waitUntilDone_modes_, 0, b'v@:@')
12        self.assertArgIsBOOL(NSThread.performSelectorOnMainThread_withObject_waitUntilDone_modes_, 2)
13        self.assertArgIsSEL(NSThread.performSelectorOnMainThread_withObject_waitUntilDone_, 0, b'v@:@')
14        self.assertArgIsBOOL(NSThread.performSelectorOnMainThread_withObject_waitUntilDone_, 2)
15
16    @min_os_level('10.5')
17    def testMethods10_5(self):
18        self.assertArgIsSEL(NSThread.initWithTarget_selector_object_, 1, b'v@:@')
19        self.assertResultIsBOOL(NSThread.isExecuting)
20        self.assertResultIsBOOL(NSThread.isFinished)
21        self.assertResultIsBOOL(NSThread.isCancelled)
22        self.assertResultIsBOOL(NSThread.isMainThread)
23        self.assertResultIsBOOL(NSThread.mainThread().isMainThread)
24        self.assertArgIsSEL(NSThread.performSelector_onThread_withObject_waitUntilDone_modes_, 0, b'v@:@')
25        self.assertArgIsBOOL(NSThread.performSelector_onThread_withObject_waitUntilDone_modes_, 3)
26        self.assertArgIsSEL(NSThread.performSelector_onThread_withObject_waitUntilDone_, 0, b'v@:@')
27        self.assertArgIsBOOL(NSThread.performSelector_onThread_withObject_waitUntilDone_, 3)
28        self.assertArgIsSEL(NSThread.performSelectorInBackground_withObject_, 0, b'v@:@')
29
30
31    def testConstants(self):
32        self.assertIsInstance(NSWillBecomeMultiThreadedNotification, unicode)
33        self.assertIsInstance(NSDidBecomeSingleThreadedNotification, unicode)
34        self.assertIsInstance(NSThreadWillExitNotification, unicode)
35
36
37if __name__ == "__main__":
38    main()
39