objc2_xc_test/generated/
mod.rs

1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::invalid_html_tags)]
19
20#[link(name = "XCTest", kind = "framework")]
21extern "C" {}
22
23use core::ffi::*;
24use core::ptr::NonNull;
25use objc2::__framework_prelude::*;
26#[cfg(feature = "objc2-app-kit")]
27#[cfg(target_os = "macos")]
28use objc2_app_kit::*;
29use objc2_foundation::*;
30#[cfg(feature = "objc2-xc-ui-automation")]
31use objc2_xc_ui_automation::*;
32
33use crate::*;
34
35extern "C" {
36    /// Domain for errors provided by the XCTest framework.
37    ///
38    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctesterrordomain?language=objc)
39    pub static XCTestErrorDomain: &'static NSErrorDomain;
40}
41
42/// Error codes used with errors in the XCTestErrorDomain.
43///
44/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctesterrorcode?language=objc)
45// NS_ENUM
46#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct XCTestErrorCode(pub NSInteger);
49impl XCTestErrorCode {
50    #[doc(alias = "XCTestErrorCodeTimeoutWhileWaiting")]
51    pub const TimeoutWhileWaiting: Self = Self(0);
52    #[doc(alias = "XCTestErrorCodeFailureWhileWaiting")]
53    pub const FailureWhileWaiting: Self = Self(1);
54}
55
56unsafe impl Encode for XCTestErrorCode {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for XCTestErrorCode {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern_class!(
65    /// An abstract base class for testing. XCTestCase and XCTestSuite extend XCTest to provide
66    /// for creating, managing, and executing tests. Most developers will not need to subclass
67    /// XCTest directly.
68    ///
69    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctest?language=objc)
70    #[unsafe(super(NSObject))]
71    #[derive(Debug, PartialEq, Eq, Hash)]
72    pub struct XCTest;
73);
74
75extern_conformance!(
76    unsafe impl NSObjectProtocol for XCTest {}
77);
78
79impl XCTest {
80    extern_methods!(
81        /// Number of test cases. Must be overridden by subclasses.
82        #[unsafe(method(testCaseCount))]
83        #[unsafe(method_family = none)]
84        pub fn testCaseCount(&self) -> NSUInteger;
85
86        /// Test's name. Must be overridden by subclasses.
87        #[unsafe(method(name))]
88        #[unsafe(method_family = none)]
89        pub fn name(&self) -> Retained<NSString>;
90
91        /// The XCTestRun subclass that will be instantiated when the test is run to hold
92        /// the test's results. Must be overridden by subclasses.
93        #[unsafe(method(testRunClass))]
94        #[unsafe(method_family = none)]
95        pub fn testRunClass(&self) -> Option<&'static AnyClass>;
96
97        /// The test run object that executed the test, an instance of testRunClass. If the test has not yet been run, this will be nil.
98        #[unsafe(method(testRun))]
99        #[unsafe(method_family = none)]
100        pub fn testRun(&self) -> Option<Retained<XCTestRun>>;
101
102        /// The method through which tests are executed. Must be overridden by subclasses.
103        #[unsafe(method(performTest:))]
104        #[unsafe(method_family = none)]
105        pub fn performTest(&self, run: &XCTestRun);
106
107        /// Creates an instance of the testRunClass and passes it as a parameter to -performTest:.
108        #[unsafe(method(runTest))]
109        #[unsafe(method_family = none)]
110        pub fn runTest(&self);
111
112        #[cfg(feature = "block2")]
113        /// Asynchronous set up method called before the invocation of each test method in the class.
114        /// This method is called before invoking `setUpWithError`, `setUp`, and the test method.
115        ///
116        ///
117        /// Parameter `completion`: A block which must be called to signal completion of set up.
118        /// May be called asynchronously. If the block's `error` argument is non-nil, the specified error
119        /// is recorded as a thrown error issue.
120        #[unsafe(method(setUpWithCompletionHandler:))]
121        #[unsafe(method_family = none)]
122        pub fn setUpWithCompletionHandler(
123            &self,
124            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
125        );
126
127        /// This method is called before invoking `setUp` and the test method.
128        #[unsafe(method(setUpWithError:_))]
129        #[unsafe(method_family = none)]
130        pub fn setUpWithError(&self) -> Result<(), Retained<NSError>>;
131
132        /// Setup method called before the invocation of each test method in the class.
133        #[unsafe(method(setUp))]
134        #[unsafe(method_family = none)]
135        pub fn setUp(&self);
136
137        /// Teardown method called after the invocation of each test method in the class.
138        #[unsafe(method(tearDown))]
139        #[unsafe(method_family = none)]
140        pub fn tearDown(&self);
141
142        /// This method is called after invoking the test method (if applicable) and
143        /// `tearDown`.
144        #[unsafe(method(tearDownWithError:_))]
145        #[unsafe(method_family = none)]
146        pub fn tearDownWithError(&self) -> Result<(), Retained<NSError>>;
147
148        #[cfg(feature = "block2")]
149        /// Asynchronous tear down method called after invoking the test method.
150        /// This method is called after invoking the test method (if applicable), `tearDown`, and
151        /// `tearDownWithError`.
152        ///
153        ///
154        /// Parameter `completion`: A block which must be called to signal completion of tear down.
155        /// May be called asynchronously. If the block's `error` argument is non-nil, the specified error
156        /// is recorded as a thrown error issue.
157        #[unsafe(method(tearDownWithCompletionHandler:))]
158        #[unsafe(method_family = none)]
159        pub fn tearDownWithCompletionHandler(
160            &self,
161            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
162        );
163    );
164}
165
166/// Methods declared on superclass `NSObject`.
167impl XCTest {
168    extern_methods!(
169        #[unsafe(method(init))]
170        #[unsafe(method_family = init)]
171        pub fn init(this: Allocated<Self>) -> Retained<Self>;
172
173        #[unsafe(method(new))]
174        #[unsafe(method_family = new)]
175        pub fn new() -> Retained<Self>;
176    );
177}
178
179impl DefaultRetained for XCTest {
180    #[inline]
181    fn default_retained() -> Retained<Self> {
182        Self::new()
183    }
184}
185
186extern_class!(
187    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/_xctestcaseinterruptionexception?language=objc)
188    #[unsafe(super(NSException, NSObject))]
189    #[derive(Debug, PartialEq, Eq, Hash)]
190    pub struct _XCTestCaseInterruptionException;
191);
192
193extern_conformance!(
194    unsafe impl NSCoding for _XCTestCaseInterruptionException {}
195);
196
197extern_conformance!(
198    unsafe impl NSCopying for _XCTestCaseInterruptionException {}
199);
200
201unsafe impl CopyingHelper for _XCTestCaseInterruptionException {
202    type Result = Self;
203}
204
205extern_conformance!(
206    unsafe impl NSObjectProtocol for _XCTestCaseInterruptionException {}
207);
208
209extern_conformance!(
210    unsafe impl NSSecureCoding for _XCTestCaseInterruptionException {}
211);
212
213impl _XCTestCaseInterruptionException {
214    extern_methods!();
215}
216
217/// Methods declared on superclass `NSException`.
218impl _XCTestCaseInterruptionException {
219    extern_methods!(
220        /// # Safety
221        ///
222        /// `a_user_info` generic should be of the correct type.
223        #[unsafe(method(initWithName:reason:userInfo:))]
224        #[unsafe(method_family = init)]
225        pub unsafe fn initWithName_reason_userInfo(
226            this: Allocated<Self>,
227            a_name: &NSExceptionName,
228            a_reason: Option<&NSString>,
229            a_user_info: Option<&NSDictionary>,
230        ) -> Retained<Self>;
231    );
232}
233
234/// Methods declared on superclass `NSObject`.
235impl _XCTestCaseInterruptionException {
236    extern_methods!(
237        #[unsafe(method(init))]
238        #[unsafe(method_family = init)]
239        pub fn init(this: Allocated<Self>) -> Retained<Self>;
240
241        #[unsafe(method(new))]
242        #[unsafe(method_family = new)]
243        pub fn new() -> Retained<Self>;
244    );
245}
246
247impl DefaultRetained for _XCTestCaseInterruptionException {
248    #[inline]
249    fn default_retained() -> Retained<Self> {
250        Self::new()
251    }
252}
253
254#[inline]
255pub(crate) extern "C-unwind" fn _XCTPreformattedFailureHandler(
256    test: Option<&XCTestCase>,
257    expected: bool,
258    file_path: &NSString,
259    line_number: NSUInteger,
260    condition: &NSString,
261    message: &NSString,
262) {
263    extern "C-unwind" {
264        fn _XCTPreformattedFailureHandler(
265            test: Option<&XCTestCase>,
266            expected: Bool,
267            file_path: &NSString,
268            line_number: NSUInteger,
269            condition: &NSString,
270            message: &NSString,
271        );
272    }
273    unsafe {
274        _XCTPreformattedFailureHandler(
275            test,
276            Bool::new(expected),
277            file_path,
278            line_number,
279            condition,
280            message,
281        )
282    }
283}
284
285/// [Apple's documentation](https://developer.apple.com/documentation/xctest/_xctassertiontype?language=objc)
286// NS_ENUM
287#[repr(transparent)]
288#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
289pub struct _XCTAssertionType(pub NSUInteger);
290impl _XCTAssertionType {
291    #[doc(alias = "_XCTAssertion_Fail")]
292    pub const Fail: Self = Self(0);
293    #[doc(alias = "_XCTAssertion_Nil")]
294    pub const Nil: Self = Self(1);
295    #[doc(alias = "_XCTAssertion_NotNil")]
296    pub const NotNil: Self = Self(2);
297    #[doc(alias = "_XCTAssertion_EqualObjects")]
298    pub const EqualObjects: Self = Self(3);
299    #[doc(alias = "_XCTAssertion_NotEqualObjects")]
300    pub const NotEqualObjects: Self = Self(4);
301    #[doc(alias = "_XCTAssertion_Equal")]
302    pub const Equal: Self = Self(5);
303    #[doc(alias = "_XCTAssertion_NotEqual")]
304    pub const NotEqual: Self = Self(6);
305    #[doc(alias = "_XCTAssertion_EqualWithAccuracy")]
306    pub const EqualWithAccuracy: Self = Self(7);
307    #[doc(alias = "_XCTAssertion_NotEqualWithAccuracy")]
308    pub const NotEqualWithAccuracy: Self = Self(8);
309    #[doc(alias = "_XCTAssertion_GreaterThan")]
310    pub const GreaterThan: Self = Self(9);
311    #[doc(alias = "_XCTAssertion_GreaterThanOrEqual")]
312    pub const GreaterThanOrEqual: Self = Self(10);
313    #[doc(alias = "_XCTAssertion_LessThan")]
314    pub const LessThan: Self = Self(11);
315    #[doc(alias = "_XCTAssertion_LessThanOrEqual")]
316    pub const LessThanOrEqual: Self = Self(12);
317    #[doc(alias = "_XCTAssertion_True")]
318    pub const True: Self = Self(13);
319    #[doc(alias = "_XCTAssertion_False")]
320    pub const False: Self = Self(14);
321    #[doc(alias = "_XCTAssertion_Throws")]
322    pub const Throws: Self = Self(15);
323    #[doc(alias = "_XCTAssertion_ThrowsSpecific")]
324    pub const ThrowsSpecific: Self = Self(16);
325    #[doc(alias = "_XCTAssertion_ThrowsSpecificNamed")]
326    pub const ThrowsSpecificNamed: Self = Self(17);
327    #[doc(alias = "_XCTAssertion_NoThrow")]
328    pub const NoThrow: Self = Self(18);
329    #[doc(alias = "_XCTAssertion_NoThrowSpecific")]
330    pub const NoThrowSpecific: Self = Self(19);
331    #[doc(alias = "_XCTAssertion_NoThrowSpecificNamed")]
332    pub const NoThrowSpecificNamed: Self = Self(20);
333    #[doc(alias = "_XCTAssertion_Unwrap")]
334    pub const Unwrap: Self = Self(21);
335    #[doc(alias = "_XCTAssertion_Identical")]
336    pub const Identical: Self = Self(22);
337    #[doc(alias = "_XCTAssertion_NotIdentical")]
338    pub const NotIdentical: Self = Self(23);
339}
340
341unsafe impl Encode for _XCTAssertionType {
342    const ENCODING: Encoding = NSUInteger::ENCODING;
343}
344
345unsafe impl RefEncode for _XCTAssertionType {
346    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
347}
348
349#[inline]
350pub(crate) extern "C-unwind" fn _XCTFailureFormat(
351    assertion_type: _XCTAssertionType,
352    format_index: NSUInteger,
353) -> Retained<NSString> {
354    extern "C-unwind" {
355        fn _XCTFailureFormat(
356            assertion_type: _XCTAssertionType,
357            format_index: NSUInteger,
358        ) -> *mut NSString;
359    }
360    let ret = unsafe { _XCTFailureFormat(assertion_type, format_index) };
361    unsafe { Retained::retain_autoreleased(ret) }
362        .expect("function was marked as returning non-null, but actually returned NULL")
363}
364
365#[inline]
366pub(crate) extern "C-unwind" fn _XCTDescriptionForValue(value: &NSValue) -> Retained<NSString> {
367    extern "C-unwind" {
368        fn _XCTDescriptionForValue(value: &NSValue) -> *mut NSString;
369    }
370    let ret = unsafe { _XCTDescriptionForValue(value) };
371    unsafe { Retained::retain_autoreleased(ret) }
372        .expect("function was marked as returning non-null, but actually returned NULL")
373}
374
375#[inline]
376pub(crate) extern "C-unwind" fn _XCTGetCurrentExceptionReasonWithFallback(
377    fallback: Option<&NSString>,
378) -> Retained<NSString> {
379    extern "C-unwind" {
380        fn _XCTGetCurrentExceptionReasonWithFallback(fallback: Option<&NSString>) -> *mut NSString;
381    }
382    let ret = unsafe { _XCTGetCurrentExceptionReasonWithFallback(fallback) };
383    unsafe { Retained::retain_autoreleased(ret) }
384        .expect("function was marked as returning non-null, but actually returned NULL")
385}
386
387extern_protocol!(
388    /// Represents a test activity.
389    ///
390    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctactivity?language=objc)
391    pub unsafe trait XCTActivity: NSObjectProtocol {
392        /// Human-readable name of the activity, given at creation time.
393        #[unsafe(method(name))]
394        #[unsafe(method_family = none)]
395        fn name(&self) -> Retained<NSString>;
396
397        /// Adds an attachment which is always kept by Xcode, regardless of the test result.
398        /// Thread-safe, attachments can be added from any thread, are reported in the order they are added.
399        #[unsafe(method(addAttachment:))]
400        #[unsafe(method_family = none)]
401        fn addAttachment(&self, attachment: &XCTAttachment);
402    }
403);
404
405extern_class!(
406    /// XCTestCase is a concrete subclass of XCTest that should be the override point for
407    /// most developers creating tests for their projects. A test case subclass can have
408    /// multiple test methods and supports setup and tear down that executes for every test
409    /// method as well as class level setup and tear down.
410    ///
411    /// To define a test case:
412    ///
413    /// • Create a subclass of XCTestCase.
414    /// • Implement -test methods.
415    /// • Optionally define instance variables or properties that store the state of the test.
416    /// • Optionally initialize state by overriding -setUp
417    /// • Optionally clean-up after a test by overriding -tearDown.
418    ///
419    /// Test methods are instance methods meeting these requirements:
420    /// • accepting no parameters
421    /// • returning no value
422    /// • prefixed with 'test'
423    ///
424    /// For example:
425    ///
426    /// - (void)testSomething;
427    ///
428    /// Test methods are automatically recognized as test cases by the XCTest framework.
429    /// Each XCTestCase subclass's defaultTestSuite is a XCTestSuite which includes these
430    /// tests. Test method implementations usually contain assertions that must be verified
431    /// for the test to pass, for example:
432    ///
433    /// ```text
434    ///
435    ///     @interface MathTest : XCTestCase
436    ///
437    ///     @property float f1;
438    ///     @property float f2;
439    ///
440    ///     @end
441    ///
442    ///     @implementation MathTest
443    ///
444    ///     - (void)setUp
445    ///     {
446    ///         self.f1 = 2.0;
447    ///         self.f2 = 3.0;
448    ///     }
449    ///
450    ///     - (void)testAddition
451    ///     {
452    ///         XCTAssertTrue(f1 + f2 == 5.0);
453    ///     }
454    ///
455    ///     @end
456    ///
457    /// ```
458    ///
459    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestcase?language=objc)
460    #[unsafe(super(XCTest, NSObject))]
461    #[derive(Debug, PartialEq, Eq, Hash)]
462    pub struct XCTestCase;
463);
464
465extern_conformance!(
466    unsafe impl NSObjectProtocol for XCTestCase {}
467);
468
469impl XCTestCase {
470    extern_methods!(
471        #[unsafe(method(testCaseWithInvocation:))]
472        #[unsafe(method_family = none)]
473        pub unsafe fn testCaseWithInvocation(invocation: Option<&NSInvocation>) -> Retained<Self>;
474
475        #[unsafe(method(initWithInvocation:))]
476        #[unsafe(method_family = init)]
477        pub unsafe fn initWithInvocation(
478            this: Allocated<Self>,
479            invocation: Option<&NSInvocation>,
480        ) -> Retained<Self>;
481
482        /// # Safety
483        ///
484        /// `selector` must be a valid selector.
485        #[unsafe(method(testCaseWithSelector:))]
486        #[unsafe(method_family = none)]
487        pub unsafe fn testCaseWithSelector(selector: Sel) -> Option<Retained<Self>>;
488
489        /// # Safety
490        ///
491        /// `selector` must be a valid selector.
492        #[unsafe(method(initWithSelector:))]
493        #[unsafe(method_family = init)]
494        pub unsafe fn initWithSelector(this: Allocated<Self>, selector: Sel) -> Retained<Self>;
495
496        /// The invocation used when this test is run.
497        #[unsafe(method(invocation))]
498        #[unsafe(method_family = none)]
499        pub unsafe fn invocation(&self) -> Option<Retained<NSInvocation>>;
500
501        /// Setter for [`invocation`][Self::invocation].
502        #[unsafe(method(setInvocation:))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn setInvocation(&self, invocation: Option<&NSInvocation>);
505
506        /// Invoking a test performs its setUp, invocation, and tearDown. In general this
507        /// should not be called directly.
508        #[unsafe(method(invokeTest))]
509        #[unsafe(method_family = none)]
510        pub fn invokeTest(&self);
511
512        /// Determines whether the test method continues execution after an XCTAssert fails.
513        ///
514        /// By default, this property is YES, meaning the test method will complete regardless of how many
515        /// XCTAssert failures occur. Setting this to NO causes the test method to end execution immediately
516        /// after the first failure occurs, but does not affect remaining test methods in the suite.
517        ///
518        /// If XCTAssert failures in the test method indicate problems with state or determinism, additional
519        /// failures may be not be helpful information. Setting `continueAfterFailure` to NO can reduce the
520        /// noise in the test report for these kinds of tests.
521        #[unsafe(method(continueAfterFailure))]
522        #[unsafe(method_family = none)]
523        pub fn continueAfterFailure(&self) -> bool;
524
525        /// Setter for [`continueAfterFailure`][Self::continueAfterFailure].
526        #[unsafe(method(setContinueAfterFailure:))]
527        #[unsafe(method_family = none)]
528        pub fn setContinueAfterFailure(&self, continue_after_failure: bool);
529
530        /// Records a failure or other issue in the execution of the test and is used by all test assertions.
531        /// Overrides of this method should call super unless they wish to suppress the issue.
532        /// Super can be invoked with a different issue object.
533        ///
534        ///
535        /// Parameter `issue`: Object with all details related to the issue.
536        #[unsafe(method(recordIssue:))]
537        #[unsafe(method_family = none)]
538        pub fn recordIssue(&self, issue: &XCTIssue);
539
540        /// Invocations for each test method in the test case.
541        #[unsafe(method(testInvocations))]
542        #[unsafe(method_family = none)]
543        pub fn testInvocations() -> Retained<NSArray<NSInvocation>>;
544
545        #[cfg(feature = "block2")]
546        /// Registers a block to be run at the end of a test.
547        ///
548        /// Teardown blocks are executed after the current test method has returned but before
549        /// -tearDown is invoked.
550        ///
551        /// Registered blocks are run on the main thread but can be registered from any thread.
552        /// They are guaranteed to run only once, in LIFO order, and are executed serially. You
553        /// may register blocks during -setUp, but you may *not* register blocks during -tearDown
554        /// or from other teardown blocks.
555        ///
556        ///
557        /// Parameter `block`: A block to enqueue for future execution.
558        #[unsafe(method(addTeardownBlock:))]
559        #[unsafe(method_family = none)]
560        pub fn addTeardownBlock(&self, block: &block2::DynBlock<dyn Fn()>);
561
562        #[cfg(feature = "block2")]
563        /// Registers an async block to be run at the end of a test.
564        ///
565        /// Teardown blocks are executed after the current test method has returned but before
566        /// -tearDown is invoked.
567        ///
568        /// Registered blocks are run on the main thread but can be registered from any thread.
569        /// They are guaranteed to run only once, in LIFO order, and are executed serially. You
570        /// may register blocks during -setUp, but you may *not* register blocks during -tearDown
571        /// or from other teardown blocks.
572        ///
573        ///
574        /// Parameter `block`: An async block to enqueue for future execution. The completion handler
575        /// passed to this block must be invoked for test execution to continue. Invoking the completion
576        /// handler with a non-nil NSError will cause an XCTIssue to be recorded representing the error.
577        ///
578        /// # Safety
579        ///
580        /// `block` block's argument block's argument must be a valid pointer or null.
581        #[unsafe(method(addAsyncTeardownBlock:))]
582        #[unsafe(method_family = none)]
583        pub unsafe fn addAsyncTeardownBlock(
584            &self,
585            block: &block2::DynBlock<dyn Fn(NonNull<block2::DynBlock<dyn Fn(*mut NSError)>>)>,
586        );
587
588        /// If test timeouts are enabled, this property represents the amount of time the test would like to be given to run.
589        /// If the test exceeds its allowance, Xcode will capture a spindump of the process and then restart it
590        /// so that test execution can continue on with the next test. The test that timed out will be marked
591        /// as a failure, and the spindump will be attached to the test in Xcode's test report.
592        ///
593        /// Note that the value you supply will be rounded up to the nearest minute value. Also note that a test
594        /// may be given less time than the value you specify if the -maximum-test-execution-time-allowance
595        /// option is passed to xcodebuild.
596        ///
597        /// The default value is 10 minutes.
598        #[unsafe(method(executionTimeAllowance))]
599        #[unsafe(method_family = none)]
600        pub fn executionTimeAllowance(&self) -> NSTimeInterval;
601
602        /// Setter for [`executionTimeAllowance`][Self::executionTimeAllowance].
603        #[unsafe(method(setExecutionTimeAllowance:))]
604        #[unsafe(method_family = none)]
605        pub fn setExecutionTimeAllowance(&self, execution_time_allowance: NSTimeInterval);
606    );
607}
608
609/// Methods declared on superclass `NSObject`.
610impl XCTestCase {
611    extern_methods!(
612        #[unsafe(method(init))]
613        #[unsafe(method_family = init)]
614        pub fn init(this: Allocated<Self>) -> Retained<Self>;
615
616        #[unsafe(method(new))]
617        #[unsafe(method_family = new)]
618        pub fn new() -> Retained<Self>;
619    );
620}
621
622impl DefaultRetained for XCTestCase {
623    #[inline]
624    fn default_retained() -> Retained<Self> {
625        Self::new()
626    }
627}
628
629/// XCTestSuiteExtensions.
630impl XCTestCase {
631    extern_methods!(
632        /// Returns a test suite containing test cases for all of the tests in the class.
633        #[unsafe(method(defaultTestSuite))]
634        #[unsafe(method_family = none)]
635        pub fn defaultTestSuite() -> Retained<XCTestSuite>;
636
637        /// Suite-level setup method called before the class begins to run any of its test methods or their associated
638        /// per-instance setUp methods.
639        #[unsafe(method(setUp))]
640        #[unsafe(method_family = none)]
641        pub fn setUp();
642
643        /// Suite-level teardown method called after the class has finished running all of its test methods and their
644        /// associated per-instance tearDown methods and teardown blocks.
645        #[unsafe(method(tearDown))]
646        #[unsafe(method_family = none)]
647        pub fn tearDown();
648    );
649}
650
651/// XCTActivity.
652///
653/// XCTestCase conforms to XCTActivity, allowing test attachments to be added directly from test methods.
654///
655/// See XCTAttachment.h for details on how to create attachments. Once created, they can be added directly to XCTestCase:
656///
657///
658/// ```text
659///  
660///      - (void)testFoo
661///      {
662///          XCTAttachment *attachment = ...
663///          [self addAttachment:attachment];
664///      }
665///  
666/// ```
667impl XCTestCase {
668    extern_methods!();
669}
670
671extern_conformance!(
672    unsafe impl XCTActivity for XCTestCase {}
673);
674
675/// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctperformancemetric?language=objc)
676// NS_TYPED_EXTENSIBLE_ENUM
677pub type XCTPerformanceMetric = NSString;
678
679extern "C" {
680    /// Records wall clock time in seconds between startMeasuring/stopMeasuring.
681    ///
682    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctperformancemetric_wallclocktime?language=objc)
683    pub static XCTPerformanceMetric_WallClockTime: &'static XCTPerformanceMetric;
684}
685
686/// XCTPerformanceAnalysis.
687///
688/// Interface extension for measure related API.
689impl XCTestCase {
690    extern_methods!(
691        /// The names of the performance metrics to measure when invoking -measureBlock:. Returns XCTPerformanceMetric_WallClockTime by default. Subclasses can override this to change the behavior of -measureBlock:
692        #[unsafe(method(defaultPerformanceMetrics))]
693        #[unsafe(method_family = none)]
694        pub fn defaultPerformanceMetrics() -> Retained<NSArray<XCTPerformanceMetric>>;
695
696        #[cfg(feature = "block2")]
697        /// Call from a test method to measure resources (+defaultPerformanceMetrics) used by the
698        /// block in the current process.
699        ///
700        /// - (void)testPerformanceOfMyFunction {
701        ///
702        /// [self measureBlock:^{
703        /// // Do that thing you want to measure.
704        /// MyFunction();
705        /// }];
706        /// }
707        ///
708        ///
709        /// Parameter `block`: A block whose performance to measure.
710        #[unsafe(method(measureBlock:))]
711        #[unsafe(method_family = none)]
712        pub fn measureBlock(&self, block: &block2::DynBlock<dyn Fn() + '_>);
713
714        #[cfg(feature = "block2")]
715        /// Call from a test method to measure resources (XCTPerformanceMetrics) used by the
716        /// block in the current process. Each metric will be measured across calls to the block.
717        /// The number of times the block will be called is undefined and may change in the
718        /// future. For one example of why, as long as the requested performance metrics do
719        /// not interfere with each other the API will measure all metrics across the same
720        /// calls to the block. If the performance metrics may interfere the API will measure
721        /// them separately.
722        ///
723        /// - (void)testMyFunction2_WallClockTime {
724        /// [self measureMetrics:[self class].defaultPerformanceMetrics automaticallyStartMeasuring:NO forBlock:^{
725        ///
726        /// // Do setup work that needs to be done for every iteration but you don't want to measure before the call to -startMeasuring
727        /// SetupSomething();
728        /// [self startMeasuring];
729        ///
730        /// // Do that thing you want to measure.
731        /// MyFunction();
732        /// [self stopMeasuring];
733        ///
734        /// // Do teardown work that needs to be done for every iteration but you don't want to measure after the call to -stopMeasuring
735        /// TeardownSomething();
736        /// }];
737        /// }
738        ///
739        /// Caveats:
740        /// • If YES was passed for automaticallyStartMeasuring and -startMeasuring is called
741        /// anyway, the test will fail.
742        /// • If NO was passed for automaticallyStartMeasuring then -startMeasuring must be
743        /// called once and only once before the end of the block or the test will fail.
744        /// • If -stopMeasuring is called multiple times during the block the test will fail.
745        ///
746        ///
747        /// Parameter `metrics`: An array of NSStrings (XCTPerformanceMetrics) to measure. Providing an unrecognized string is a test failure.
748        ///
749        ///
750        /// Parameter `automaticallyStartMeasuring`: If NO, XCTestCase will not take any measurements until -startMeasuring is called.
751        ///
752        ///
753        /// Parameter `block`: A block whose performance to measure.
754        #[unsafe(method(measureMetrics:automaticallyStartMeasuring:forBlock:))]
755        #[unsafe(method_family = none)]
756        pub fn measureMetrics_automaticallyStartMeasuring_forBlock(
757            &self,
758            metrics: &NSArray<XCTPerformanceMetric>,
759            automatically_start_measuring: bool,
760            block: &block2::DynBlock<dyn Fn() + '_>,
761        );
762
763        /// Call this from within a measure block to set the beginning of the critical section.
764        /// Measurement of metrics will start at this point.
765        #[unsafe(method(startMeasuring))]
766        #[unsafe(method_family = none)]
767        pub fn startMeasuring(&self);
768
769        /// Call this from within a measure block to set the ending of the critical section.
770        /// Measurement of metrics will stop at this point.
771        #[unsafe(method(stopMeasuring))]
772        #[unsafe(method_family = none)]
773        pub fn stopMeasuring(&self);
774
775        /// A collection of metrics to be taken by default when -measureBlock or -measureWithOptions:block: is called.
776        #[unsafe(method(defaultMetrics))]
777        #[unsafe(method_family = none)]
778        pub fn defaultMetrics() -> Retained<NSArray<ProtocolObject<dyn XCTMetric>>>;
779
780        /// Collection of configurable settings to change how measurements are taken.
781        #[unsafe(method(defaultMeasureOptions))]
782        #[unsafe(method_family = none)]
783        pub fn defaultMeasureOptions() -> Retained<XCTMeasureOptions>;
784
785        #[cfg(feature = "block2")]
786        /// Measures the block using the provided metrics and the default options from your XCTestCase class.
787        ///
788        ///
789        /// Parameter `metrics`: A non-empty array of objects which adopt the XCTMetric protocol, describing the set of metrics to measure.
790        ///
791        /// Parameter `block`: The block to be measured.
792        #[unsafe(method(measureWithMetrics:block:))]
793        #[unsafe(method_family = none)]
794        pub fn measureWithMetrics_block(
795            &self,
796            metrics: &NSArray<ProtocolObject<dyn XCTMetric>>,
797            block: &block2::DynBlock<dyn Fn() + '_>,
798        );
799
800        #[cfg(feature = "block2")]
801        /// Measures the block using the default metrics from your XCTestCase class and the provided options.
802        ///
803        ///
804        /// Parameter `options`: An object describing the options to use when measuring the block, such as the number of times the block should be executed.
805        ///
806        /// Parameter `block`: The block to be measured.
807        ///
808        ///
809        /// See also: XCTMeasureOptions
810        #[unsafe(method(measureWithOptions:block:))]
811        #[unsafe(method_family = none)]
812        pub fn measureWithOptions_block(
813            &self,
814            options: &XCTMeasureOptions,
815            block: &block2::DynBlock<dyn Fn() + '_>,
816        );
817
818        #[cfg(feature = "block2")]
819        /// Measures the block using the provided metrics and options.
820        ///
821        ///
822        /// Parameter `metrics`: A non-empty array of objects which adopt the XCTMetric protocol, describing the set of metrics to measure.
823        ///
824        /// Parameter `options`: An object describing the options to use when measuring the block, such as the number of times the block should be executed.
825        ///
826        /// Parameter `block`: The block to be measured.
827        #[unsafe(method(measureWithMetrics:options:block:))]
828        #[unsafe(method_family = none)]
829        pub fn measureWithMetrics_options_block(
830            &self,
831            metrics: &NSArray<ProtocolObject<dyn XCTMetric>>,
832            options: &XCTMeasureOptions,
833            block: &block2::DynBlock<dyn Fn() + '_>,
834        );
835    );
836}
837
838/// XCTDeprecated.
839impl XCTestCase {
840    extern_methods!(
841        /// Records a failure in the execution of the test.
842        ///
843        /// This method is deprecated and has been replaced by the `-recordIssue:` method and XCTIssue class, which
844        /// provide greater flexibility for recording issues that arise during testing. Overriding this method in an XCTestCase subclass and
845        /// modifying its arguments before calling `super` may cause information about the failure to be lost and is not recommended.
846        /// Instead, override `-recordIssue:` and pass `super` a modified XCTIssue.
847        ///
848        ///
849        /// Parameter `description`: The description of the failure being recorded. When replacing usage of this deprecated API,
850        /// this can be represented using the `compactDescription` property on XCTIssue.
851        ///
852        ///
853        /// Parameter `filePath`: The file path to the source file where the failure being recorded was encountered.
854        /// When replacing usage of this deprecated API, this can be specified using an XCTSourceCodeLocation instance
855        /// associated with an XCTIssue via its `sourceCodeContext` property.
856        ///
857        ///
858        /// Parameter `lineNumber`: The line number in the source file at filePath where the failure being recorded
859        /// was encountered. When replacing usage of this deprecated API, this can be specified using an XCTSourceCodeLocation
860        /// instance associated with an XCTIssue via its `sourceCodeContext` property.
861        ///
862        ///
863        /// Parameter `expected`: NO if the failure being recorded was the result of an uncaught exception, YES if it was the result
864        /// of a failed assertion or any other reason. When replacing usage of this deprecated API, the representation using XCTIssue may vary.
865        /// A NO value may be specified using the issue type `XCTIssueTypeUncaughtException`, and a YES value may be represented
866        /// using a different issue type such as `XCTIssueTypeAssertionFailure` combined with other properties on XCTIssue.
867        #[deprecated]
868        #[unsafe(method(recordFailureWithDescription:inFile:atLine:expected:))]
869        #[unsafe(method_family = none)]
870        pub fn recordFailureWithDescription_inFile_atLine_expected(
871            &self,
872            description: &NSString,
873            file_path: &NSString,
874            line_number: NSUInteger,
875            expected: bool,
876        );
877    );
878}
879
880extern_class!(
881    /// A test run collects information about the execution of a test. Failures in explicit
882    /// test assertions are classified as "expected", while failures from unrelated or
883    /// uncaught exceptions are classified as "unexpected".
884    ///
885    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestrun?language=objc)
886    #[unsafe(super(NSObject))]
887    #[derive(Debug, PartialEq, Eq, Hash)]
888    pub struct XCTestRun;
889);
890
891extern_conformance!(
892    unsafe impl NSObjectProtocol for XCTestRun {}
893);
894
895impl XCTestRun {
896    extern_methods!(
897        #[unsafe(method(new))]
898        #[unsafe(method_family = new)]
899        pub unsafe fn new() -> Retained<Self>;
900
901        #[unsafe(method(init))]
902        #[unsafe(method_family = init)]
903        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
904
905        /// Class factory method for the XCTestRun class.
906        ///
907        ///
908        /// Parameter `test`: An XCTest instance.
909        ///
910        ///
911        /// Returns: A test run for the provided test.
912        #[unsafe(method(testRunWithTest:))]
913        #[unsafe(method_family = none)]
914        pub fn testRunWithTest(test: &XCTest) -> Retained<Self>;
915
916        /// Designated initializer for the XCTestRun class.
917        ///
918        ///
919        /// Parameter `test`: An XCTest instance.
920        ///
921        ///
922        /// Returns: A test run for the provided test.
923        #[unsafe(method(initWithTest:))]
924        #[unsafe(method_family = init)]
925        pub fn initWithTest(this: Allocated<Self>, test: &XCTest) -> Retained<Self>;
926
927        /// The test instance provided when the test run was initialized.
928        #[unsafe(method(test))]
929        #[unsafe(method_family = none)]
930        pub fn test(&self) -> Retained<XCTest>;
931
932        /// Start a test run. Must not be called more than once.
933        #[unsafe(method(start))]
934        #[unsafe(method_family = none)]
935        pub fn start(&self);
936
937        /// Stop a test run. Must not be called unless the run has been started. Must not be called more than once.
938        #[unsafe(method(stop))]
939        #[unsafe(method_family = none)]
940        pub fn stop(&self);
941
942        /// The time at which the test run was started, or nil.
943        #[unsafe(method(startDate))]
944        #[unsafe(method_family = none)]
945        pub fn startDate(&self) -> Option<Retained<NSDate>>;
946
947        /// The time at which the test run was stopped, or nil.
948        #[unsafe(method(stopDate))]
949        #[unsafe(method_family = none)]
950        pub fn stopDate(&self) -> Option<Retained<NSDate>>;
951
952        /// The number of seconds that elapsed between when the run was started and when it was stopped.
953        #[unsafe(method(totalDuration))]
954        #[unsafe(method_family = none)]
955        pub fn totalDuration(&self) -> NSTimeInterval;
956
957        /// The number of seconds that elapsed between when the run was started and when it was stopped.
958        #[unsafe(method(testDuration))]
959        #[unsafe(method_family = none)]
960        pub fn testDuration(&self) -> NSTimeInterval;
961
962        /// The number of tests in the run.
963        #[unsafe(method(testCaseCount))]
964        #[unsafe(method_family = none)]
965        pub fn testCaseCount(&self) -> NSUInteger;
966
967        /// The number of test executions recorded during the run.
968        #[unsafe(method(executionCount))]
969        #[unsafe(method_family = none)]
970        pub fn executionCount(&self) -> NSUInteger;
971
972        /// The number of test skips recorded during the run.
973        #[unsafe(method(skipCount))]
974        #[unsafe(method_family = none)]
975        pub fn skipCount(&self) -> NSUInteger;
976
977        /// The number of test failures recorded during the run.
978        #[unsafe(method(failureCount))]
979        #[unsafe(method_family = none)]
980        pub fn failureCount(&self) -> NSUInteger;
981
982        /// The number of uncaught exceptions recorded during the run.
983        #[unsafe(method(unexpectedExceptionCount))]
984        #[unsafe(method_family = none)]
985        pub fn unexpectedExceptionCount(&self) -> NSUInteger;
986
987        /// The total number of test failures and uncaught exceptions recorded during the run.
988        #[unsafe(method(totalFailureCount))]
989        #[unsafe(method_family = none)]
990        pub fn totalFailureCount(&self) -> NSUInteger;
991
992        /// YES if all tests in the run completed their execution without recording any failures, otherwise NO.
993        #[unsafe(method(hasSucceeded))]
994        #[unsafe(method_family = none)]
995        pub fn hasSucceeded(&self) -> bool;
996
997        /// YES if the test was skipped, otherwise NO.
998        #[unsafe(method(hasBeenSkipped))]
999        #[unsafe(method_family = none)]
1000        pub fn hasBeenSkipped(&self) -> bool;
1001
1002        /// Records a failure or other  issue in the execution of the test and is used by all test assertions.
1003        /// Overrides of this method should call super unless they wish to suppress the issue.
1004        /// Super can be invoked with a different issue object.
1005        ///
1006        ///
1007        /// Parameter `issue`: Object with all details related to the issue.
1008        #[unsafe(method(recordIssue:))]
1009        #[unsafe(method_family = none)]
1010        pub fn recordIssue(&self, issue: &XCTIssue);
1011    );
1012}
1013
1014/// XCTDeprecated.
1015impl XCTestRun {
1016    extern_methods!(
1017        /// Records a failure in the execution of the test for this test run. Must not be called
1018        /// unless the run has been started. Must not be called if the test run has been stopped.
1019        ///
1020        /// This method is deprecated and has been replaced by the `-recordIssue:` method and XCTIssue class, which
1021        /// provide greater flexibility for recording issues that arise during testing. Overriding this method in an XCTestRun subclass and
1022        /// modifying its arguments before calling `super` may cause information about the failure to be lost and is not recommended.
1023        /// Instead, override `-recordIssue:` and pass `super` a modified XCTIssue.
1024        ///
1025        ///
1026        /// Parameter `description`: The description of the failure being recorded. When replacing usage of this deprecated API,
1027        /// this can be represented using the `compactDescription` property on XCTIssue.
1028        ///
1029        ///
1030        /// Parameter `filePath`: The file path to the source file where the failure being recorded was encountered
1031        /// or nil if unknown. When replacing usage of this deprecated API, this can be specified using an XCTSourceCodeLocation instance
1032        /// associated with an XCTIssue via its `sourceCodeContext` property.
1033        ///
1034        ///
1035        /// Parameter `lineNumber`: The line number in the source file at filePath where the failure being recorded
1036        /// was encountered or 0 if unknown. When replacing usage of this deprecated API, this can be specified using an
1037        /// XCTSourceCodeLocation instance associated with an XCTIssue via its `sourceCodeContext` property.
1038        ///
1039        ///
1040        /// Parameter `expected`: NO if the failure being recorded was the result of an uncaught exception, YES if it was the result
1041        /// of a failed assertion or any other reason. When replacing usage of this deprecated API, the representation using XCTIssue may vary.
1042        /// A NO value may be specified using the issue type `XCTIssueTypeUncaughtException`, and a YES value may be represented
1043        /// using a different issue type such as `XCTIssueTypeAssertionFailure` combined with other properties on XCTIssue.
1044        #[deprecated]
1045        #[unsafe(method(recordFailureWithDescription:inFile:atLine:expected:))]
1046        #[unsafe(method_family = none)]
1047        pub fn recordFailureWithDescription_inFile_atLine_expected(
1048            &self,
1049            description: &NSString,
1050            file_path: Option<&NSString>,
1051            line_number: NSUInteger,
1052            expected: bool,
1053        );
1054    );
1055}
1056
1057extern_class!(
1058    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestcaserun?language=objc)
1059    #[unsafe(super(XCTestRun, NSObject))]
1060    #[derive(Debug, PartialEq, Eq, Hash)]
1061    pub struct XCTestCaseRun;
1062);
1063
1064extern_conformance!(
1065    unsafe impl NSObjectProtocol for XCTestCaseRun {}
1066);
1067
1068impl XCTestCaseRun {
1069    extern_methods!(
1070        #[deprecated]
1071        #[unsafe(method(recordFailureInTest:withDescription:inFile:atLine:expected:))]
1072        #[unsafe(method_family = none)]
1073        pub fn recordFailureInTest_withDescription_inFile_atLine_expected(
1074            &self,
1075            test_case: &XCTestCase,
1076            description: &NSString,
1077            file_path: &NSString,
1078            line_number: NSUInteger,
1079            expected: bool,
1080        );
1081    );
1082}
1083
1084/// Methods declared on superclass `XCTestRun`.
1085impl XCTestCaseRun {
1086    extern_methods!(
1087        #[unsafe(method(new))]
1088        #[unsafe(method_family = new)]
1089        pub unsafe fn new() -> Retained<Self>;
1090
1091        #[unsafe(method(init))]
1092        #[unsafe(method_family = init)]
1093        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1094
1095        /// Class factory method for the XCTestRun class.
1096        ///
1097        ///
1098        /// Parameter `test`: An XCTest instance.
1099        ///
1100        ///
1101        /// Returns: A test run for the provided test.
1102        #[unsafe(method(testRunWithTest:))]
1103        #[unsafe(method_family = none)]
1104        pub fn testRunWithTest(test: &XCTest) -> Retained<Self>;
1105
1106        /// Designated initializer for the XCTestRun class.
1107        ///
1108        ///
1109        /// Parameter `test`: An XCTest instance.
1110        ///
1111        ///
1112        /// Returns: A test run for the provided test.
1113        #[unsafe(method(initWithTest:))]
1114        #[unsafe(method_family = init)]
1115        pub fn initWithTest(this: Allocated<Self>, test: &XCTest) -> Retained<Self>;
1116    );
1117}
1118
1119extern_class!(
1120    /// XCTestObserver is deprecated.
1121    ///
1122    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestobserver?language=objc)
1123    #[unsafe(super(NSObject))]
1124    #[derive(Debug, PartialEq, Eq, Hash)]
1125    #[deprecated]
1126    pub struct XCTestObserver;
1127);
1128
1129extern_conformance!(
1130    unsafe impl NSObjectProtocol for XCTestObserver {}
1131);
1132
1133impl XCTestObserver {
1134    extern_methods!(
1135        #[unsafe(method(startObserving))]
1136        #[unsafe(method_family = none)]
1137        pub fn startObserving(&self);
1138
1139        #[unsafe(method(stopObserving))]
1140        #[unsafe(method_family = none)]
1141        pub fn stopObserving(&self);
1142
1143        /// # Safety
1144        ///
1145        /// `test_run` might not allow `None`.
1146        #[unsafe(method(testSuiteDidStart:))]
1147        #[unsafe(method_family = none)]
1148        pub unsafe fn testSuiteDidStart(&self, test_run: Option<&XCTestRun>);
1149
1150        /// # Safety
1151        ///
1152        /// `test_run` might not allow `None`.
1153        #[unsafe(method(testSuiteDidStop:))]
1154        #[unsafe(method_family = none)]
1155        pub unsafe fn testSuiteDidStop(&self, test_run: Option<&XCTestRun>);
1156
1157        /// # Safety
1158        ///
1159        /// `test_run` might not allow `None`.
1160        #[unsafe(method(testCaseDidStart:))]
1161        #[unsafe(method_family = none)]
1162        pub unsafe fn testCaseDidStart(&self, test_run: Option<&XCTestRun>);
1163
1164        /// # Safety
1165        ///
1166        /// `test_run` might not allow `None`.
1167        #[unsafe(method(testCaseDidStop:))]
1168        #[unsafe(method_family = none)]
1169        pub unsafe fn testCaseDidStop(&self, test_run: Option<&XCTestRun>);
1170
1171        /// # Safety
1172        ///
1173        /// - `test_run` might not allow `None`.
1174        /// - `description` might not allow `None`.
1175        /// - `file_path` might not allow `None`.
1176        #[unsafe(method(testCaseDidFail:withDescription:inFile:atLine:))]
1177        #[unsafe(method_family = none)]
1178        pub unsafe fn testCaseDidFail_withDescription_inFile_atLine(
1179            &self,
1180            test_run: Option<&XCTestRun>,
1181            description: Option<&NSString>,
1182            file_path: Option<&NSString>,
1183            line_number: NSUInteger,
1184        );
1185    );
1186}
1187
1188/// Methods declared on superclass `NSObject`.
1189impl XCTestObserver {
1190    extern_methods!(
1191        #[unsafe(method(init))]
1192        #[unsafe(method_family = init)]
1193        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1194
1195        #[unsafe(method(new))]
1196        #[unsafe(method_family = new)]
1197        pub fn new() -> Retained<Self>;
1198    );
1199}
1200
1201impl DefaultRetained for XCTestObserver {
1202    #[inline]
1203    fn default_retained() -> Retained<Self> {
1204        Self::new()
1205    }
1206}
1207
1208extern "C" {
1209    /// XCTestObserverClassKey is deprecated and ignored.
1210    ///
1211    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestobserverclasskey?language=objc)
1212    #[deprecated]
1213    pub static XCTestObserverClassKey: Option<&'static NSString>;
1214}
1215
1216extern_class!(
1217    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestlog?language=objc)
1218    #[unsafe(super(XCTestObserver, NSObject))]
1219    #[derive(Debug, PartialEq, Eq, Hash)]
1220    #[deprecated]
1221    pub struct XCTestLog;
1222);
1223
1224extern_conformance!(
1225    unsafe impl NSObjectProtocol for XCTestLog {}
1226);
1227
1228impl XCTestLog {
1229    extern_methods!(
1230        #[unsafe(method(logFileHandle))]
1231        #[unsafe(method_family = none)]
1232        pub fn logFileHandle(&self) -> Option<Retained<NSFileHandle>>;
1233    );
1234}
1235
1236/// Methods declared on superclass `NSObject`.
1237impl XCTestLog {
1238    extern_methods!(
1239        #[unsafe(method(init))]
1240        #[unsafe(method_family = init)]
1241        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1242
1243        #[unsafe(method(new))]
1244        #[unsafe(method_family = new)]
1245        pub fn new() -> Retained<Self>;
1246    );
1247}
1248
1249impl DefaultRetained for XCTestLog {
1250    #[inline]
1251    fn default_retained() -> Retained<Self> {
1252        Self::new()
1253    }
1254}
1255
1256extern_protocol!(
1257    /// Objects conforming to XCTestObservation can register to be notified of the progress of test runs. See XCTestObservationCenter
1258    /// for details on registration.
1259    ///
1260    /// Progress events are delivered in the following sequence:
1261    ///
1262    /// -testBundleWillStart:                            // exactly once per test bundle
1263    /// -testSuiteWillStart:                        // exactly once per test suite
1264    /// -testCaseWillStart:                     // exactly once per test case
1265    /// -testCase:didRecordIssue:               // zero or more times per test case, any time between test case start and finish
1266    /// -testCaseDidFinish:                     // exactly once per test case
1267    /// -testSuite:didRecordIssue:                  // zero or more times per test suite, any time between test suite start and finish
1268    /// -testSuiteDidFinish:                        // exactly once per test suite
1269    /// -testBundleDidFinish:                            // exactly once per test bundle
1270    ///
1271    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestobservation?language=objc)
1272    pub unsafe trait XCTestObservation: NSObjectProtocol {
1273        /// Sent immediately before tests begin as a hook for any pre-testing setup.
1274        ///
1275        ///
1276        /// Parameter `testBundle`: The bundle containing the tests that were executed.
1277        #[optional]
1278        #[unsafe(method(testBundleWillStart:))]
1279        #[unsafe(method_family = none)]
1280        fn testBundleWillStart(&self, test_bundle: &NSBundle);
1281
1282        /// Sent immediately after all tests have finished as a hook for any post-testing activity. The test process will generally
1283        /// exit after this method returns, so if there is long running and/or asynchronous work to be done after testing, be sure
1284        /// to implement this method in a way that it blocks until all such activity is complete.
1285        ///
1286        ///
1287        /// Parameter `testBundle`: The bundle containing the tests that were executed.
1288        #[optional]
1289        #[unsafe(method(testBundleDidFinish:))]
1290        #[unsafe(method_family = none)]
1291        fn testBundleDidFinish(&self, test_bundle: &NSBundle);
1292
1293        /// Sent when a test suite starts executing.
1294        ///
1295        ///
1296        /// Parameter `testSuite`: The test suite that started. Additional information can be retrieved from the associated XCTestRun.
1297        #[optional]
1298        #[unsafe(method(testSuiteWillStart:))]
1299        #[unsafe(method_family = none)]
1300        fn testSuiteWillStart(&self, test_suite: &XCTestSuite);
1301
1302        /// Sent when a test suite reports an issue. Suite issues are most commonly reported during suite-level setup and teardown
1303        /// whereas issues during tests are reported for the test case alone and are not reported as suite issues.
1304        ///
1305        ///
1306        /// Parameter `testSuite`: The test suite that recorded the issue.
1307        ///
1308        /// Parameter `issue`: Object with all details related to the issue.
1309        #[optional]
1310        #[unsafe(method(testSuite:didRecordIssue:))]
1311        #[unsafe(method_family = none)]
1312        fn testSuite_didRecordIssue(&self, test_suite: &XCTestSuite, issue: &XCTIssue);
1313
1314        /// Sent when a test suite records an expected failure.
1315        ///
1316        ///
1317        /// Parameter `testSuite`: The test suite that recorded the expected failure.
1318        ///
1319        /// Parameter `expectedFailure`: Object with all details related to the expected failure, including the suppressed issue.
1320        #[optional]
1321        #[unsafe(method(testSuite:didRecordExpectedFailure:))]
1322        #[unsafe(method_family = none)]
1323        fn testSuite_didRecordExpectedFailure(
1324            &self,
1325            test_suite: &XCTestSuite,
1326            expected_failure: &XCTExpectedFailure,
1327        );
1328
1329        /// Sent when a test suite finishes executing.
1330        ///
1331        ///
1332        /// Parameter `testSuite`: The test suite that finished. Additional information can be retrieved from the associated XCTestRun.
1333        #[optional]
1334        #[unsafe(method(testSuiteDidFinish:))]
1335        #[unsafe(method_family = none)]
1336        fn testSuiteDidFinish(&self, test_suite: &XCTestSuite);
1337
1338        /// Sent when a test case starts executing.
1339        ///
1340        ///
1341        /// Parameter `testCase`: The test case that started. Additional information can be retrieved from the associated XCTestRun.
1342        #[optional]
1343        #[unsafe(method(testCaseWillStart:))]
1344        #[unsafe(method_family = none)]
1345        fn testCaseWillStart(&self, test_case: &XCTestCase);
1346
1347        /// Sent when a test case reports an issue.
1348        ///
1349        ///
1350        /// Parameter `testCase`: The test case that recorded the issue.
1351        ///
1352        /// Parameter `issue`: Object with all details related to the issue.
1353        #[optional]
1354        #[unsafe(method(testCase:didRecordIssue:))]
1355        #[unsafe(method_family = none)]
1356        fn testCase_didRecordIssue(&self, test_case: &XCTestCase, issue: &XCTIssue);
1357
1358        /// Sent when a test case records an expected failure.
1359        ///
1360        ///
1361        /// Parameter `testCase`: The test case that recorded the expected failure.
1362        ///
1363        /// Parameter `expectedFailure`: Object with all details related to the expected failure, including the suppressed issue.
1364        #[optional]
1365        #[unsafe(method(testCase:didRecordExpectedFailure:))]
1366        #[unsafe(method_family = none)]
1367        fn testCase_didRecordExpectedFailure(
1368            &self,
1369            test_case: &XCTestCase,
1370            expected_failure: &XCTExpectedFailure,
1371        );
1372
1373        /// Sent when a test case finishes executing.
1374        ///
1375        ///
1376        /// Parameter `testCase`: The test case that finished. Additional information can be retrieved from the associated XCTestRun.
1377        #[optional]
1378        #[unsafe(method(testCaseDidFinish:))]
1379        #[unsafe(method_family = none)]
1380        fn testCaseDidFinish(&self, test_case: &XCTestCase);
1381
1382        /// Sent when a test suite reports a failure. Suite failures are most commonly reported during suite-level setup and teardown
1383        /// whereas failures during tests are reported for the test case alone and are not reported as suite failures.
1384        ///
1385        /// This method is deprecated and replaced by the `-testSuite:didRecordIssue:` method whose XCTIssue parameter provides greater flexibility
1386        /// for describing issues that arise during testing. If the receiver of this method also responds to `-testSuite:didRecordIssue:`, that method
1387        /// is called instead and this will not be called.
1388        ///
1389        ///
1390        /// Parameter `testSuite`: The test suite that failed. Additional information can be retrieved from the associated XCTestRun.
1391        ///
1392        ///
1393        /// Parameter `description`: A textual description of the failure. When replacing usage of this deprecated API, this can
1394        /// be obtained using the `compactDescription` property on XCTIssue.
1395        ///
1396        ///
1397        /// Parameter `filePath`: The path of file where the failure occurred or nil if unknown. When replacing usage of this deprecated API, this
1398        /// can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its `sourceCodeContext` property
1399        ///
1400        ///
1401        /// Parameter `lineNumber`: The line where the failure was reported or 0 if unknown. When replacing usage of this deprecated API, this
1402        /// can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its `sourceCodeContext` property
1403        #[deprecated]
1404        #[optional]
1405        #[unsafe(method(testSuite:didFailWithDescription:inFile:atLine:))]
1406        #[unsafe(method_family = none)]
1407        fn testSuite_didFailWithDescription_inFile_atLine(
1408            &self,
1409            test_suite: &XCTestSuite,
1410            description: &NSString,
1411            file_path: Option<&NSString>,
1412            line_number: NSUInteger,
1413        );
1414
1415        /// Sent when a test case reports a failure.
1416        ///
1417        /// This method is deprecated and replaced by the `-testCase:didRecordIssue:` method whose XCTIssue parameter provides greater flexibility
1418        /// for describing issues that arise during testing. If the receiver of this method also responds to `-testCase:didRecordIssue:`, that method
1419        /// is called instead and this will not be called.
1420        ///
1421        ///
1422        /// Parameter `testCase`: The test case that failed. Additional information can be retrieved from the associated XCTestRun.
1423        ///
1424        ///
1425        /// Parameter `description`: A textual description of the failure. When replacing usage of this deprecated API, this can
1426        /// be obtained using the `compactDescription` property on XCTIssue.
1427        ///
1428        ///
1429        /// Parameter `filePath`: The path of file where the failure occurred or nil if unknown. When replacing usage of this deprecated API, this
1430        /// can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its `sourceCodeContext` property
1431        ///
1432        ///
1433        /// Parameter `lineNumber`: The line where the failure was reported or 0 if unknown. When replacing usage of this deprecated API, this
1434        /// can be obtained using the XCTSourceCodeLocation instance associated with an XCTIssue via its `sourceCodeContext` property
1435        #[deprecated]
1436        #[optional]
1437        #[unsafe(method(testCase:didFailWithDescription:inFile:atLine:))]
1438        #[unsafe(method_family = none)]
1439        fn testCase_didFailWithDescription_inFile_atLine(
1440            &self,
1441            test_case: &XCTestCase,
1442            description: &NSString,
1443            file_path: Option<&NSString>,
1444            line_number: NSUInteger,
1445        );
1446    }
1447);
1448
1449extern_class!(
1450    /// The XCTestObservationCenter distributes information about the progress of test runs to registered
1451    /// observers. Observers can be any object conforming to the XCTestObservation protocol.
1452    ///
1453    /// If an NSPrincipalClass is declared in the test bundle's Info.plist, XCTest automatically creates a
1454    /// single instance of that class when the test bundle is loaded. This instance provides a means to register
1455    /// observers or do other pretesting global set up.
1456    ///
1457    /// Observers must be registered manually. The NSPrincipalClass instance is not automatically
1458    /// registered as an observer even if the class conforms to
1459    /// <XCTestObservation
1460    /// >.
1461    ///
1462    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestobservationcenter?language=objc)
1463    #[unsafe(super(NSObject))]
1464    #[derive(Debug, PartialEq, Eq, Hash)]
1465    pub struct XCTestObservationCenter;
1466);
1467
1468extern_conformance!(
1469    unsafe impl NSObjectProtocol for XCTestObservationCenter {}
1470);
1471
1472impl XCTestObservationCenter {
1473    extern_methods!(
1474        /// Returns: The shared XCTestObservationCenter singleton instance.
1475        #[unsafe(method(sharedTestObservationCenter))]
1476        #[unsafe(method_family = none)]
1477        pub fn sharedTestObservationCenter() -> Retained<XCTestObservationCenter>;
1478
1479        /// Register an object conforming to XCTestObservation as an observer for the current test session. Observers may be added
1480        /// at any time, but will not receive events that occurred before they were registered. The observation center maintains a strong
1481        /// reference to observers.
1482        ///
1483        /// Events may be delivered to observers in any order - given observers A and B, A may be notified of a test failure before
1484        /// or after B. Any ordering dependencies or serialization requirements must be managed by clients.
1485        #[unsafe(method(addTestObserver:))]
1486        #[unsafe(method_family = none)]
1487        pub fn addTestObserver(&self, test_observer: &ProtocolObject<dyn XCTestObservation>);
1488
1489        /// Unregister an object conforming to XCTestObservation as an observer for the current test session.
1490        #[unsafe(method(removeTestObserver:))]
1491        #[unsafe(method_family = none)]
1492        pub fn removeTestObserver(&self, test_observer: &ProtocolObject<dyn XCTestObservation>);
1493    );
1494}
1495
1496/// Methods declared on superclass `NSObject`.
1497impl XCTestObservationCenter {
1498    extern_methods!(
1499        #[unsafe(method(init))]
1500        #[unsafe(method_family = init)]
1501        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1502
1503        #[unsafe(method(new))]
1504        #[unsafe(method_family = new)]
1505        pub fn new() -> Retained<Self>;
1506    );
1507}
1508
1509impl DefaultRetained for XCTestObservationCenter {
1510    #[inline]
1511    fn default_retained() -> Retained<Self> {
1512        Self::new()
1513    }
1514}
1515
1516#[deprecated]
1517#[inline]
1518pub extern "C-unwind" fn XCTSelfTestMain() -> c_int {
1519    extern "C-unwind" {
1520        fn XCTSelfTestMain() -> c_int;
1521    }
1522    unsafe { XCTSelfTestMain() }
1523}
1524
1525extern_class!(
1526    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestprobe?language=objc)
1527    #[unsafe(super(NSObject))]
1528    #[derive(Debug, PartialEq, Eq, Hash)]
1529    #[deprecated]
1530    pub struct XCTestProbe;
1531);
1532
1533extern_conformance!(
1534    unsafe impl NSObjectProtocol for XCTestProbe {}
1535);
1536
1537impl XCTestProbe {
1538    extern_methods!(
1539        #[unsafe(method(isTesting))]
1540        #[unsafe(method_family = none)]
1541        pub fn isTesting() -> bool;
1542    );
1543}
1544
1545/// Methods declared on superclass `NSObject`.
1546impl XCTestProbe {
1547    extern_methods!(
1548        #[unsafe(method(init))]
1549        #[unsafe(method_family = init)]
1550        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1551
1552        #[unsafe(method(new))]
1553        #[unsafe(method_family = new)]
1554        pub fn new() -> Retained<Self>;
1555    );
1556}
1557
1558impl DefaultRetained for XCTestProbe {
1559    #[inline]
1560    fn default_retained() -> Retained<Self> {
1561        Self::new()
1562    }
1563}
1564
1565extern "C" {
1566    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestedunitpath?language=objc)
1567    #[deprecated]
1568    pub static XCTestedUnitPath: Option<&'static NSString>;
1569}
1570
1571extern "C" {
1572    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestscopekey?language=objc)
1573    #[deprecated]
1574    pub static XCTestScopeKey: Option<&'static NSString>;
1575}
1576
1577extern "C" {
1578    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestscopeall?language=objc)
1579    #[deprecated]
1580    pub static XCTestScopeAll: Option<&'static NSString>;
1581}
1582
1583extern "C" {
1584    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestscopenone?language=objc)
1585    #[deprecated]
1586    pub static XCTestScopeNone: Option<&'static NSString>;
1587}
1588
1589extern "C" {
1590    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestscopeself?language=objc)
1591    #[deprecated]
1592    pub static XCTestScopeSelf: Option<&'static NSString>;
1593}
1594
1595extern "C" {
1596    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctesttoolkey?language=objc)
1597    #[deprecated]
1598    pub static XCTestToolKey: Option<&'static NSString>;
1599}
1600
1601extern_class!(
1602    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/_xctskipfailureexception?language=objc)
1603    #[unsafe(super(NSException, NSObject))]
1604    #[derive(Debug, PartialEq, Eq, Hash)]
1605    pub struct _XCTSkipFailureException;
1606);
1607
1608extern_conformance!(
1609    unsafe impl NSCoding for _XCTSkipFailureException {}
1610);
1611
1612extern_conformance!(
1613    unsafe impl NSCopying for _XCTSkipFailureException {}
1614);
1615
1616unsafe impl CopyingHelper for _XCTSkipFailureException {
1617    type Result = Self;
1618}
1619
1620extern_conformance!(
1621    unsafe impl NSObjectProtocol for _XCTSkipFailureException {}
1622);
1623
1624extern_conformance!(
1625    unsafe impl NSSecureCoding for _XCTSkipFailureException {}
1626);
1627
1628impl _XCTSkipFailureException {
1629    extern_methods!();
1630}
1631
1632/// Methods declared on superclass `NSException`.
1633impl _XCTSkipFailureException {
1634    extern_methods!(
1635        /// # Safety
1636        ///
1637        /// `a_user_info` generic should be of the correct type.
1638        #[unsafe(method(initWithName:reason:userInfo:))]
1639        #[unsafe(method_family = init)]
1640        pub unsafe fn initWithName_reason_userInfo(
1641            this: Allocated<Self>,
1642            a_name: &NSExceptionName,
1643            a_reason: Option<&NSString>,
1644            a_user_info: Option<&NSDictionary>,
1645        ) -> Retained<Self>;
1646    );
1647}
1648
1649/// Methods declared on superclass `NSObject`.
1650impl _XCTSkipFailureException {
1651    extern_methods!(
1652        #[unsafe(method(init))]
1653        #[unsafe(method_family = init)]
1654        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1655
1656        #[unsafe(method(new))]
1657        #[unsafe(method_family = new)]
1658        pub fn new() -> Retained<Self>;
1659    );
1660}
1661
1662impl DefaultRetained for _XCTSkipFailureException {
1663    #[inline]
1664    fn default_retained() -> Retained<Self> {
1665        Self::new()
1666    }
1667}
1668
1669extern_class!(
1670    /// A concrete subclass of XCTest, XCTestSuite is a collection of test cases. Suites
1671    /// are usually managed by the IDE, but XCTestSuite also provides API for dynamic test
1672    /// and suite management:
1673    ///
1674    /// ```text
1675    ///
1676    ///     XCTestSuite *suite = [XCTestSuite testSuiteWithName:@"My tests"];
1677    ///     [suite addTest:[MathTest testCaseWithSelector:@selector(testAdd)]];
1678    ///     [suite addTest:[MathTest testCaseWithSelector:@selector(testDivideByZero)]];
1679    ///
1680    /// ```
1681    ///
1682    /// Alternatively, a test suite can extract the tests to be run automatically. To do so,
1683    /// pass the class of your test case class to the suite's constructor:
1684    ///
1685    /// ```text
1686    ///
1687    ///     XCTestSuite *suite = [XCTestSuite testSuiteForTestCaseClass:[MathTest class]];
1688    ///
1689    /// ```
1690    ///
1691    /// This creates a suite with all the methods starting with "test" that take no arguments.
1692    /// Also, a test suite of all the test cases found in the runtime can be created automatically:
1693    ///
1694    /// ```text
1695    ///
1696    ///     XCTestSuite *suite = XCTestSuite.defaultTestSuite;
1697    ///
1698    /// ```
1699    ///
1700    /// This creates a suite of suites with all the XCTestCase subclasses methods that start
1701    /// with "test" and take no arguments.
1702    ///
1703    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestsuite?language=objc)
1704    #[unsafe(super(XCTest, NSObject))]
1705    #[derive(Debug, PartialEq, Eq, Hash)]
1706    pub struct XCTestSuite;
1707);
1708
1709extern_conformance!(
1710    unsafe impl NSObjectProtocol for XCTestSuite {}
1711);
1712
1713impl XCTestSuite {
1714    extern_methods!(
1715        #[unsafe(method(defaultTestSuite))]
1716        #[unsafe(method_family = none)]
1717        pub fn defaultTestSuite() -> Retained<XCTestSuite>;
1718
1719        #[unsafe(method(testSuiteForBundlePath:))]
1720        #[unsafe(method_family = none)]
1721        pub fn testSuiteForBundlePath(bundle_path: &NSString) -> Retained<Self>;
1722
1723        #[unsafe(method(testSuiteForTestCaseWithName:))]
1724        #[unsafe(method_family = none)]
1725        pub fn testSuiteForTestCaseWithName(name: &NSString) -> Retained<Self>;
1726
1727        /// # Safety
1728        ///
1729        /// `test_case_class` probably has further requirements.
1730        #[unsafe(method(testSuiteForTestCaseClass:))]
1731        #[unsafe(method_family = none)]
1732        pub unsafe fn testSuiteForTestCaseClass(test_case_class: &AnyClass) -> Retained<Self>;
1733
1734        #[unsafe(method(testSuiteWithName:))]
1735        #[unsafe(method_family = none)]
1736        pub fn testSuiteWithName(name: &NSString) -> Retained<Self>;
1737
1738        #[unsafe(method(initWithName:))]
1739        #[unsafe(method_family = init)]
1740        pub fn initWithName(this: Allocated<Self>, name: &NSString) -> Retained<Self>;
1741
1742        #[unsafe(method(new))]
1743        #[unsafe(method_family = new)]
1744        pub unsafe fn new() -> Retained<Self>;
1745
1746        #[unsafe(method(init))]
1747        #[unsafe(method_family = init)]
1748        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1749
1750        #[unsafe(method(addTest:))]
1751        #[unsafe(method_family = none)]
1752        pub fn addTest(&self, test: &XCTest);
1753
1754        #[unsafe(method(tests))]
1755        #[unsafe(method_family = none)]
1756        pub fn tests(&self) -> Retained<NSArray<XCTest>>;
1757    );
1758}
1759
1760extern_class!(
1761    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestsuiterun?language=objc)
1762    #[unsafe(super(XCTestRun, NSObject))]
1763    #[derive(Debug, PartialEq, Eq, Hash)]
1764    pub struct XCTestSuiteRun;
1765);
1766
1767extern_conformance!(
1768    unsafe impl NSObjectProtocol for XCTestSuiteRun {}
1769);
1770
1771impl XCTestSuiteRun {
1772    extern_methods!(
1773        #[unsafe(method(testRuns))]
1774        #[unsafe(method_family = none)]
1775        pub fn testRuns(&self) -> Retained<NSArray<XCTestRun>>;
1776
1777        #[unsafe(method(addTestRun:))]
1778        #[unsafe(method_family = none)]
1779        pub fn addTestRun(&self, test_run: &XCTestRun);
1780    );
1781}
1782
1783/// Methods declared on superclass `XCTestRun`.
1784impl XCTestSuiteRun {
1785    extern_methods!(
1786        #[unsafe(method(new))]
1787        #[unsafe(method_family = new)]
1788        pub unsafe fn new() -> Retained<Self>;
1789
1790        #[unsafe(method(init))]
1791        #[unsafe(method_family = init)]
1792        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1793
1794        /// Class factory method for the XCTestRun class.
1795        ///
1796        ///
1797        /// Parameter `test`: An XCTest instance.
1798        ///
1799        ///
1800        /// Returns: A test run for the provided test.
1801        #[unsafe(method(testRunWithTest:))]
1802        #[unsafe(method_family = none)]
1803        pub fn testRunWithTest(test: &XCTest) -> Retained<Self>;
1804
1805        /// Designated initializer for the XCTestRun class.
1806        ///
1807        ///
1808        /// Parameter `test`: An XCTest instance.
1809        ///
1810        ///
1811        /// Returns: A test run for the provided test.
1812        #[unsafe(method(initWithTest:))]
1813        #[unsafe(method_family = init)]
1814        pub fn initWithTest(this: Allocated<Self>, test: &XCTest) -> Retained<Self>;
1815    );
1816}
1817
1818/// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctattachmentlifetime?language=objc)
1819// NS_ENUM
1820#[repr(transparent)]
1821#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1822pub struct XCTAttachmentLifetime(pub NSInteger);
1823impl XCTAttachmentLifetime {
1824    #[doc(alias = "XCTAttachmentLifetimeKeepAlways")]
1825    pub const KeepAlways: Self = Self(0);
1826    #[doc(alias = "XCTAttachmentLifetimeDeleteOnSuccess")]
1827    pub const DeleteOnSuccess: Self = Self(1);
1828}
1829
1830unsafe impl Encode for XCTAttachmentLifetime {
1831    const ENCODING: Encoding = NSInteger::ENCODING;
1832}
1833
1834unsafe impl RefEncode for XCTAttachmentLifetime {
1835    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1836}
1837
1838extern_class!(
1839    /// Represents the concept of data attached to an XCTActivity. Allows reporting more context about the test run
1840    /// for debugging, such as screenshots, log files, and configuration dictionaries.
1841    ///
1842    /// Each attachment must be added to an activity to be handed off to XCTest. There are two ways to get an activity:
1843    /// 1. XCTestCase conforms to the XCTActivity protocol, attachments can be added to it directly.
1844    /// 2. Create a nested activity with +[XCTContext runActivityNamed:block:], the parameter inside the block is a new activity to which attachments can be added.
1845    ///
1846    /// Once you have an XCTActivity-conforming object:
1847    /// • Create a new XCTAttachment with one of the initializers provided.
1848    /// • Optionally customize the attachment's `lifetime`, `name` and `userInfo` properties.
1849    /// • Add the attachment to the activity with -[XCTActivity addAttachment:].
1850    ///
1851    ///
1852    /// ```text
1853    ///  
1854    ///     - (void)testFoo
1855    ///     {
1856    ///         // ...
1857    ///         NSString *logs = ...
1858    ///         XCTAttachment *attachment = [XCTAttachment attachmentWithString:logs];
1859    ///         attachment.name = @"Build logs";
1860    ///         [self addAttachment:attachment];
1861    ///     }
1862    ///
1863    ///     - (void)testNestedFoo
1864    ///     {
1865    ///         // ...
1866    ///         [XCTContext runActivityNamed:@"Collect logs" block:^(id<XCTActivity> activity){
1867    ///             NSString *logs = ...
1868    ///             XCTAttachment *attachment = [XCTAttachment attachmentWithString:logs];
1869    ///             attachment.name = @"Build logs";
1870    ///             [activity addAttachment:attachment];
1871    ///         }];
1872    ///     }
1873    ///  
1874    /// ```
1875    ///
1876    /// Attachments have the default lifetime of .deleteOnSuccess, which means they are deleted when
1877    /// their test passes. This ensures attachments are only kept when test fails. To override this
1878    /// behavior, change the value of the `lifetime` property to .keepAlways before adding it to an activity.
1879    ///
1880    ///
1881    /// ```text
1882    ///  
1883    ///      - (void)testImportantAttachment
1884    ///      {
1885    ///          XCTAttachment *attachment = ...
1886    ///          attachment.lifetime = XCTAttachmentLifetimeKeepAlways;
1887    ///          [self addAttachment:attachment];
1888    ///      }
1889    ///  
1890    /// ```
1891    ///
1892    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctattachment?language=objc)
1893    #[unsafe(super(NSObject))]
1894    #[derive(Debug, PartialEq, Eq, Hash)]
1895    pub struct XCTAttachment;
1896);
1897
1898extern_conformance!(
1899    unsafe impl NSCoding for XCTAttachment {}
1900);
1901
1902extern_conformance!(
1903    unsafe impl NSObjectProtocol for XCTAttachment {}
1904);
1905
1906extern_conformance!(
1907    unsafe impl NSSecureCoding for XCTAttachment {}
1908);
1909
1910impl XCTAttachment {
1911    extern_methods!(
1912        #[unsafe(method(new))]
1913        #[unsafe(method_family = new)]
1914        pub unsafe fn new() -> Retained<Self>;
1915
1916        #[unsafe(method(init))]
1917        #[unsafe(method_family = init)]
1918        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1919
1920        /// # Safety
1921        ///
1922        /// `user_info` generic should be of the correct type.
1923        #[unsafe(method(initWithUniformTypeIdentifier:name:payload:userInfo:))]
1924        #[unsafe(method_family = init)]
1925        pub unsafe fn initWithUniformTypeIdentifier_name_payload_userInfo(
1926            this: Allocated<Self>,
1927            identifier: Option<&NSString>,
1928            name: Option<&NSString>,
1929            payload: Option<&NSData>,
1930            user_info: Option<&NSDictionary>,
1931        ) -> Retained<Self>;
1932
1933        /// # Safety
1934        ///
1935        /// `user_info` generic should be of the correct type.
1936        #[unsafe(method(attachmentWithUniformTypeIdentifier:name:payload:userInfo:))]
1937        #[unsafe(method_family = none)]
1938        pub unsafe fn attachmentWithUniformTypeIdentifier_name_payload_userInfo(
1939            identifier: Option<&NSString>,
1940            name: Option<&NSString>,
1941            payload: Option<&NSData>,
1942            user_info: Option<&NSDictionary>,
1943        ) -> Retained<Self>;
1944
1945        /// Uniform Type Identifier of the payload data.
1946        /// Examples: "public.png", "public.jpeg", "public.plain-text", "public.data", "com.apple.xml-property-list".
1947        #[unsafe(method(uniformTypeIdentifier))]
1948        #[unsafe(method_family = none)]
1949        pub fn uniformTypeIdentifier(&self) -> Retained<NSString>;
1950
1951        /// Attachment name.
1952        #[unsafe(method(name))]
1953        #[unsafe(method_family = none)]
1954        pub fn name(&self) -> Option<Retained<NSString>>;
1955
1956        /// Setter for [`name`][Self::name].
1957        ///
1958        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1959        #[unsafe(method(setName:))]
1960        #[unsafe(method_family = none)]
1961        pub fn setName(&self, name: Option<&NSString>);
1962
1963        /// Container for additional metadata, such as pixel density with images.
1964        #[unsafe(method(userInfo))]
1965        #[unsafe(method_family = none)]
1966        pub fn userInfo(&self) -> Option<Retained<NSDictionary>>;
1967
1968        /// Setter for [`userInfo`][Self::userInfo].
1969        ///
1970        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1971        ///
1972        /// # Safety
1973        ///
1974        /// `user_info` generic should be of the correct type.
1975        #[unsafe(method(setUserInfo:))]
1976        #[unsafe(method_family = none)]
1977        pub unsafe fn setUserInfo(&self, user_info: Option<&NSDictionary>);
1978
1979        #[unsafe(method(lifetime))]
1980        #[unsafe(method_family = none)]
1981        pub fn lifetime(&self) -> XCTAttachmentLifetime;
1982
1983        /// Setter for [`lifetime`][Self::lifetime].
1984        #[unsafe(method(setLifetime:))]
1985        #[unsafe(method_family = none)]
1986        pub fn setLifetime(&self, lifetime: XCTAttachmentLifetime);
1987    );
1988}
1989
1990/// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctimagequality?language=objc)
1991// NS_ENUM
1992#[repr(transparent)]
1993#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1994pub struct XCTImageQuality(pub NSInteger);
1995impl XCTImageQuality {
1996    #[doc(alias = "XCTImageQualityOriginal")]
1997    pub const Original: Self = Self(0);
1998    #[doc(alias = "XCTImageQualityMedium")]
1999    pub const Medium: Self = Self(1);
2000    #[doc(alias = "XCTImageQualityLow")]
2001    pub const Low: Self = Self(2);
2002}
2003
2004unsafe impl Encode for XCTImageQuality {
2005    const ENCODING: Encoding = NSInteger::ENCODING;
2006}
2007
2008unsafe impl RefEncode for XCTImageQuality {
2009    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2010}
2011
2012/// ConvenienceInitializers.
2013impl XCTAttachment {
2014    extern_methods!(
2015        /// Creates a new data attachment (type "public.data") with the specified payload.
2016        #[unsafe(method(attachmentWithData:))]
2017        #[unsafe(method_family = none)]
2018        pub fn attachmentWithData(payload: &NSData) -> Retained<Self>;
2019
2020        /// Creates a new attachment with the specified payload and type.
2021        #[unsafe(method(attachmentWithData:uniformTypeIdentifier:))]
2022        #[unsafe(method_family = none)]
2023        pub fn attachmentWithData_uniformTypeIdentifier(
2024            payload: &NSData,
2025            identifier: &NSString,
2026        ) -> Retained<Self>;
2027
2028        /// Creates a new plain UTF-8 encoded text attachment (type "public.plain-text") with the specified string.
2029        #[unsafe(method(attachmentWithString:))]
2030        #[unsafe(method_family = none)]
2031        pub fn attachmentWithString(string: &NSString) -> Retained<Self>;
2032
2033        /// Creates an attachment with an object that can be encoded with NSSecureCoding.
2034        /// Defaults to type "public.data".
2035        ///
2036        /// # Safety
2037        ///
2038        /// `object` should be of the correct type.
2039        #[unsafe(method(attachmentWithArchivableObject:))]
2040        #[unsafe(method_family = none)]
2041        pub unsafe fn attachmentWithArchivableObject(
2042            object: &ProtocolObject<dyn NSSecureCoding>,
2043        ) -> Retained<Self>;
2044
2045        /// Creates an attachment with an object that can be encoded with NSSecureCoding and type.
2046        ///
2047        /// # Safety
2048        ///
2049        /// `object` should be of the correct type.
2050        #[unsafe(method(attachmentWithArchivableObject:uniformTypeIdentifier:))]
2051        #[unsafe(method_family = none)]
2052        pub unsafe fn attachmentWithArchivableObject_uniformTypeIdentifier(
2053            object: &ProtocolObject<dyn NSSecureCoding>,
2054            identifier: &NSString,
2055        ) -> Retained<Self>;
2056
2057        /// Creates an attachment with an object that can be encoded into an XML property list.
2058        ///
2059        /// # Safety
2060        ///
2061        /// `object` should be of the correct type.
2062        #[unsafe(method(attachmentWithPlistObject:))]
2063        #[unsafe(method_family = none)]
2064        pub unsafe fn attachmentWithPlistObject(object: &AnyObject) -> Retained<Self>;
2065
2066        /// Creates an attachment with an existing file on disk. Attachment's uniform type identifier is inferred from the file extension.
2067        /// If no type can be inferred from the extension, fallback is "public.data".
2068        ///
2069        /// Note: Only works for files, not directories.
2070        #[unsafe(method(attachmentWithContentsOfFileAtURL:))]
2071        #[unsafe(method_family = none)]
2072        pub fn attachmentWithContentsOfFileAtURL(url: &NSURL) -> Retained<Self>;
2073
2074        /// Creates an attachment with an existing file on disk and type.
2075        ///
2076        /// Note: Only works for files, not directories.
2077        #[unsafe(method(attachmentWithContentsOfFileAtURL:uniformTypeIdentifier:))]
2078        #[unsafe(method_family = none)]
2079        pub fn attachmentWithContentsOfFileAtURL_uniformTypeIdentifier(
2080            url: &NSURL,
2081            identifier: &NSString,
2082        ) -> Retained<Self>;
2083
2084        /// Creates an attachment with an existing directory on disk. Automatically zips the directory, the content type is "public.zip-archive".
2085        #[unsafe(method(attachmentWithCompressedContentsOfDirectoryAtURL:))]
2086        #[unsafe(method_family = none)]
2087        pub fn attachmentWithCompressedContentsOfDirectoryAtURL(url: &NSURL) -> Retained<Self>;
2088
2089        #[cfg(feature = "objc2-app-kit")]
2090        #[cfg(target_os = "macos")]
2091        #[unsafe(method(attachmentWithImage:))]
2092        #[unsafe(method_family = none)]
2093        pub fn attachmentWithImage(image: &NSImage) -> Retained<Self>;
2094
2095        #[cfg(feature = "objc2-app-kit")]
2096        #[cfg(target_os = "macos")]
2097        #[unsafe(method(attachmentWithImage:quality:))]
2098        #[unsafe(method_family = none)]
2099        pub fn attachmentWithImage_quality(
2100            image: &NSImage,
2101            quality: XCTImageQuality,
2102        ) -> Retained<Self>;
2103    );
2104}
2105
2106extern_class!(
2107    /// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctcontext?language=objc)
2108    #[unsafe(super(NSObject))]
2109    #[derive(Debug, PartialEq, Eq, Hash)]
2110    pub struct XCTContext;
2111);
2112
2113extern_conformance!(
2114    unsafe impl NSObjectProtocol for XCTContext {}
2115);
2116
2117impl XCTContext {
2118    extern_methods!(
2119        #[unsafe(method(init))]
2120        #[unsafe(method_family = init)]
2121        pub fn init(this: Allocated<Self>) -> Retained<Self>;
2122
2123        #[unsafe(method(new))]
2124        #[unsafe(method_family = new)]
2125        pub fn new() -> Retained<Self>;
2126
2127        #[cfg(feature = "block2")]
2128        /// Call to create a named activity around the block.
2129        /// Can be used to group low level actions, such as typing and tapping, into high level
2130        /// tasks, such as filling of a form in a UI test.
2131        ///
2132        /// ```text
2133        ///  
2134        ///  - (void)testSignUpFlow {
2135        ///      XCUIElement *form = ...
2136        ///      [XCTContext runActivityNamed:@"Fill in account information" block:^{
2137        ///          [form.textFields[@"Email"] typeText:@"john.appleseed@icloud.com"];
2138        ///          [form.secureTextFields[@"New Password"] typeText:@"myPassword"];
2139        ///      }];
2140        ///      [XCTContext runActivityNamed:@"Create account" block:^{
2141        ///          XCUIElement *submit = form.buttons[@"Create"];
2142        ///          XCTAssert(submit.isEnabled);
2143        ///          [submit tap];
2144        ///      }];
2145        ///  }
2146        ///  
2147        /// ```
2148        ///
2149        /// Such test would result in an activity hierarchy of:
2150        ///
2151        /// ```text
2152        ///  
2153        ///  - Fill in account information
2154        ///      - Type "john.appleseed@icloud.com" into "Email"
2155        ///      - Type "myPassword" into "New Password"
2156        ///  - Create account
2157        ///      - Tap "Create"
2158        ///  
2159        /// ```
2160        ///
2161        /// Must be called from the main thread.
2162        ///
2163        ///
2164        /// Parameter `name`: A string that will help identify the activity.
2165        ///
2166        ///
2167        /// Parameter `block`: A block whose contents are wrapped in the new activity.
2168        #[unsafe(method(runActivityNamed:block:))]
2169        #[unsafe(method_family = none)]
2170        pub fn runActivityNamed_block(
2171            name: &NSString,
2172            block: &block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn XCTActivity>>) + '_>,
2173        );
2174    );
2175}
2176
2177impl DefaultRetained for XCTContext {
2178    #[inline]
2179    fn default_retained() -> Retained<Self> {
2180        Self::new()
2181    }
2182}
2183
2184/// Declares that the test is expected to fail at some point beyond the call. This can be used to both document and
2185/// suppress a known issue when immediate resolution is not possible. Issues caught by XCTExpectFailure do not
2186/// impact the aggregate results of the test suites which own them.
2187///
2188/// This function may be invoked repeatedly and has stack semantics. Failures are associated with the closest
2189/// matching expected failure and the stack is cleaned up by the test after it runs. If a failure is expected
2190/// but none is recorded, a distinct failure for the unmatched expected failure will be recorded instead.
2191///
2192/// Threading considerations: when XCTExpectFailure is called on the test's primary thread it will match against
2193/// any issue recorded on any thread. When XCTExpectFailure is called on any other thread, it will only match
2194/// against issues recorded on the same thread.
2195///
2196///
2197/// Parameter `failureReason`: Explanation of the issue being suppressed. If it contains
2198/// a URL, that URL can be extracted and presented as a link in reporting UI (Xcode and CI).
2199#[inline]
2200pub extern "C-unwind" fn XCTExpectFailure(failure_reason: Option<&NSString>) {
2201    extern "C-unwind" {
2202        fn XCTExpectFailure(failure_reason: Option<&NSString>);
2203    }
2204    unsafe { XCTExpectFailure(failure_reason) }
2205}
2206
2207/// Like XCTExpectFailure, but takes an options object that can be used to customize the behavior.
2208///
2209///
2210/// Parameter `options`: The options can include a custom issue matching block as well as the ability to
2211/// disable "strict" behavior, which relaxes the requirement that a call to XCTExpectFailure must be matched
2212/// against at least one recorded issue.
2213#[inline]
2214pub extern "C-unwind" fn XCTExpectFailureWithOptions(
2215    failure_reason: Option<&NSString>,
2216    options: &XCTExpectedFailureOptions,
2217) {
2218    extern "C-unwind" {
2219        fn XCTExpectFailureWithOptions(
2220            failure_reason: Option<&NSString>,
2221            options: &XCTExpectedFailureOptions,
2222        );
2223    }
2224    unsafe { XCTExpectFailureWithOptions(failure_reason, options) }
2225}
2226
2227/// Like XCTExpectFailure, but limits the scope in which issues are matched.
2228///
2229///
2230/// Parameter `failingBlock`: The scope of code in which the failure is expected. Note that this will only
2231/// match against failures in that scope on the same thread; failures in dispatch callouts or other code
2232/// running on a different thread will not be matched.
2233#[cfg(feature = "block2")]
2234#[inline]
2235pub extern "C-unwind" fn XCTExpectFailureInBlock(
2236    failure_reason: Option<&NSString>,
2237    failing_block: &block2::DynBlock<dyn Fn()>,
2238) {
2239    extern "C-unwind" {
2240        fn XCTExpectFailureInBlock(
2241            failure_reason: Option<&NSString>,
2242            failing_block: &block2::DynBlock<dyn Fn()>,
2243        );
2244    }
2245    unsafe { XCTExpectFailureInBlock(failure_reason, failing_block) }
2246}
2247
2248/// Like XCTExpectFailure, but takes an options object that can be used to customize the behavior and
2249/// limits the scope in which issues are matched.
2250#[cfg(feature = "block2")]
2251#[inline]
2252pub extern "C-unwind" fn XCTExpectFailureWithOptionsInBlock(
2253    failure_reason: Option<&NSString>,
2254    options: &XCTExpectedFailureOptions,
2255    failing_block: &block2::DynBlock<dyn Fn()>,
2256) {
2257    extern "C-unwind" {
2258        fn XCTExpectFailureWithOptionsInBlock(
2259            failure_reason: Option<&NSString>,
2260            options: &XCTExpectedFailureOptions,
2261            failing_block: &block2::DynBlock<dyn Fn()>,
2262        );
2263    }
2264    unsafe { XCTExpectFailureWithOptionsInBlock(failure_reason, options, failing_block) }
2265}
2266
2267extern_class!(
2268    /// Describes the rules for matching issues to expected failures and other behaviors related to
2269    /// expected failure handling.
2270    ///
2271    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctexpectedfailureoptions?language=objc)
2272    #[unsafe(super(NSObject))]
2273    #[derive(Debug, PartialEq, Eq, Hash)]
2274    pub struct XCTExpectedFailureOptions;
2275);
2276
2277extern_conformance!(
2278    unsafe impl NSCoding for XCTExpectedFailureOptions {}
2279);
2280
2281extern_conformance!(
2282    unsafe impl NSCopying for XCTExpectedFailureOptions {}
2283);
2284
2285unsafe impl CopyingHelper for XCTExpectedFailureOptions {
2286    type Result = Self;
2287}
2288
2289extern_conformance!(
2290    unsafe impl NSObjectProtocol for XCTExpectedFailureOptions {}
2291);
2292
2293extern_conformance!(
2294    unsafe impl NSSecureCoding for XCTExpectedFailureOptions {}
2295);
2296
2297impl XCTExpectedFailureOptions {
2298    extern_methods!(
2299        #[cfg(feature = "block2")]
2300        /// An optional filter can be used to determine whether or not an issue recorded inside an expected
2301        /// failure block should be matched to the expected failure. Issues that are not matched to an expected
2302        /// failure will be recorded as normal issues (real test failures). By default the filter is nil and
2303        /// all issues are matched.
2304        ///
2305        /// # Safety
2306        ///
2307        /// The returned block's argument must be a valid pointer.
2308        #[unsafe(method(issueMatcher))]
2309        #[unsafe(method_family = none)]
2310        pub unsafe fn issueMatcher(
2311            &self,
2312        ) -> NonNull<block2::DynBlock<dyn Fn(NonNull<XCTIssue>) -> Bool>>;
2313
2314        #[cfg(feature = "block2")]
2315        /// Setter for [`issueMatcher`][Self::issueMatcher].
2316        ///
2317        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2318        #[unsafe(method(setIssueMatcher:))]
2319        #[unsafe(method_family = none)]
2320        pub fn setIssueMatcher(
2321            &self,
2322            issue_matcher: &block2::DynBlock<dyn Fn(NonNull<XCTIssue>) -> Bool>,
2323        );
2324
2325        /// For expected failures that only occur under certain circumstances, this flag can be used to
2326        /// disable the expected failure. In the closure-based variants of XCTExpectFailure, the failing block
2327        /// will be executed normally. Defaults to YES/true.
2328        #[unsafe(method(isEnabled))]
2329        #[unsafe(method_family = none)]
2330        pub fn isEnabled(&self) -> bool;
2331
2332        /// Setter for [`isEnabled`][Self::isEnabled].
2333        #[unsafe(method(setEnabled:))]
2334        #[unsafe(method_family = none)]
2335        pub fn setEnabled(&self, enabled: bool);
2336
2337        /// If true (the default) and no issue is matched to the expected failure, then an issue will be
2338        /// recorded for the unmatched expected failure itself.
2339        #[unsafe(method(isStrict))]
2340        #[unsafe(method_family = none)]
2341        pub fn isStrict(&self) -> bool;
2342
2343        /// Setter for [`isStrict`][Self::isStrict].
2344        #[unsafe(method(setStrict:))]
2345        #[unsafe(method_family = none)]
2346        pub fn setStrict(&self, strict: bool);
2347
2348        /// Convenience factory method which returns a new instance of XCTExpectedFailureOptions that has `isStrict` set to NO, with every other value set to its default.
2349        #[unsafe(method(nonStrictOptions))]
2350        #[unsafe(method_family = none)]
2351        pub fn nonStrictOptions() -> Retained<XCTExpectedFailureOptions>;
2352    );
2353}
2354
2355/// Methods declared on superclass `NSObject`.
2356impl XCTExpectedFailureOptions {
2357    extern_methods!(
2358        #[unsafe(method(init))]
2359        #[unsafe(method_family = init)]
2360        pub fn init(this: Allocated<Self>) -> Retained<Self>;
2361
2362        #[unsafe(method(new))]
2363        #[unsafe(method_family = new)]
2364        pub fn new() -> Retained<Self>;
2365    );
2366}
2367
2368impl DefaultRetained for XCTExpectedFailureOptions {
2369    #[inline]
2370    fn default_retained() -> Retained<Self> {
2371        Self::new()
2372    }
2373}
2374
2375extern_class!(
2376    /// Contains the details about a single instance of an expected failure, including the failure
2377    /// reason and the underlying issue that was recorded.
2378    ///
2379    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctexpectedfailure?language=objc)
2380    #[unsafe(super(NSObject))]
2381    #[derive(Debug, PartialEq, Eq, Hash)]
2382    pub struct XCTExpectedFailure;
2383);
2384
2385extern_conformance!(
2386    unsafe impl NSCoding for XCTExpectedFailure {}
2387);
2388
2389extern_conformance!(
2390    unsafe impl NSObjectProtocol for XCTExpectedFailure {}
2391);
2392
2393extern_conformance!(
2394    unsafe impl NSSecureCoding for XCTExpectedFailure {}
2395);
2396
2397impl XCTExpectedFailure {
2398    extern_methods!(
2399        #[unsafe(method(init))]
2400        #[unsafe(method_family = init)]
2401        pub fn init(this: Allocated<Self>) -> Retained<Self>;
2402
2403        #[unsafe(method(new))]
2404        #[unsafe(method_family = new)]
2405        pub fn new() -> Retained<Self>;
2406
2407        /// Explanation of the problem requiring the issue to be suppressed.
2408        #[unsafe(method(failureReason))]
2409        #[unsafe(method_family = none)]
2410        pub fn failureReason(&self) -> Option<Retained<NSString>>;
2411
2412        /// The issue being suppressed.
2413        #[unsafe(method(issue))]
2414        #[unsafe(method_family = none)]
2415        pub fn issue(&self) -> Retained<XCTIssue>;
2416    );
2417}
2418
2419impl DefaultRetained for XCTExpectedFailure {
2420    #[inline]
2421    fn default_retained() -> Retained<Self> {
2422        Self::new()
2423    }
2424}
2425
2426/// Types of failures and other issues that can be reported for tests.
2427///
2428/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctissuetype?language=objc)
2429// NS_ENUM
2430#[repr(transparent)]
2431#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2432pub struct XCTIssueType(pub NSInteger);
2433impl XCTIssueType {
2434    /// Issue raised by a failed XCTAssert or related API.
2435    #[doc(alias = "XCTIssueTypeAssertionFailure")]
2436    pub const AssertionFailure: Self = Self(0);
2437    /// Issue raised by the test throwing an error in Swift. This could also occur if an Objective C test is implemented in the form `- (BOOL)testFoo:(NSError **)outError` and returns NO with a non-nil out error.
2438    #[doc(alias = "XCTIssueTypeThrownError")]
2439    pub const ThrownError: Self = Self(1);
2440    /// Code in the test throws and does not catch an exception, Objective C, C++, or other.
2441    #[doc(alias = "XCTIssueTypeUncaughtException")]
2442    pub const UncaughtException: Self = Self(2);
2443    /// One of the XCTestCase(measure:) family of APIs detected a performance regression.
2444    #[doc(alias = "XCTIssueTypePerformanceRegression")]
2445    pub const PerformanceRegression: Self = Self(3);
2446    /// One of the framework APIs failed internally. For example, XCUIApplication was unable to launch or terminate an app or XCUIElementQuery was unable to complete a query.
2447    #[doc(alias = "XCTIssueTypeSystem")]
2448    pub const System: Self = Self(4);
2449    /// Issue raised when XCTExpectFailure is used but no matching issue is recorded.
2450    #[doc(alias = "XCTIssueTypeUnmatchedExpectedFailure")]
2451    pub const UnmatchedExpectedFailure: Self = Self(5);
2452}
2453
2454unsafe impl Encode for XCTIssueType {
2455    const ENCODING: Encoding = NSInteger::ENCODING;
2456}
2457
2458unsafe impl RefEncode for XCTIssueType {
2459    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2460}
2461
2462/// An enum representing the severity of a test issue.
2463///
2464/// The numeric values of this enum's cases are comparable. A case which represents
2465/// higher severity has a larger numeric value than one which represents lower
2466/// severity. Specifying a numeric severity value other than one corresponding to
2467/// a case defined below when initializing an ``XCTIssue`` is unsupported.
2468///
2469/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctissueseverity?language=objc)
2470// NS_ENUM
2471#[repr(transparent)]
2472#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2473pub struct XCTIssueSeverity(pub NSInteger);
2474impl XCTIssueSeverity {
2475    /// The severity level for an issue which should be noted but is not
2476    /// necessarily an error.
2477    ///
2478    /// An issue with warning severity does not cause the test it's associated
2479    /// with to be marked as a failure, but is noted in the results.
2480    #[doc(alias = "XCTIssueSeverityWarning")]
2481    pub const Warning: Self = Self(4);
2482    /// The severity level for an issue which represents an error in a test.
2483    ///
2484    /// An issue with error severity causes the test it's associated with to be
2485    /// marked as a failure.
2486    #[doc(alias = "XCTIssueSeverityError")]
2487    pub const Error: Self = Self(8);
2488}
2489
2490unsafe impl Encode for XCTIssueSeverity {
2491    const ENCODING: Encoding = NSInteger::ENCODING;
2492}
2493
2494unsafe impl RefEncode for XCTIssueSeverity {
2495    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2496}
2497
2498extern_class!(
2499    /// Encapsulates all data concerning a test failure or other issue.
2500    ///
2501    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctissue?language=objc)
2502    #[unsafe(super(NSObject))]
2503    #[derive(Debug, PartialEq, Eq, Hash)]
2504    pub struct XCTIssue;
2505);
2506
2507extern_conformance!(
2508    unsafe impl NSCoding for XCTIssue {}
2509);
2510
2511extern_conformance!(
2512    unsafe impl NSCopying for XCTIssue {}
2513);
2514
2515unsafe impl CopyingHelper for XCTIssue {
2516    type Result = Self;
2517}
2518
2519extern_conformance!(
2520    unsafe impl NSMutableCopying for XCTIssue {}
2521);
2522
2523unsafe impl MutableCopyingHelper for XCTIssue {
2524    type Result = XCTMutableIssue;
2525}
2526
2527extern_conformance!(
2528    unsafe impl NSObjectProtocol for XCTIssue {}
2529);
2530
2531extern_conformance!(
2532    unsafe impl NSSecureCoding for XCTIssue {}
2533);
2534
2535impl XCTIssue {
2536    extern_methods!(
2537        #[unsafe(method(initWithType:compactDescription:detailedDescription:sourceCodeContext:associatedError:attachments:))]
2538        #[unsafe(method_family = init)]
2539        pub fn initWithType_compactDescription_detailedDescription_sourceCodeContext_associatedError_attachments(
2540            this: Allocated<Self>,
2541            r#type: XCTIssueType,
2542            compact_description: &NSString,
2543            detailed_description: Option<&NSString>,
2544            source_code_context: &XCTSourceCodeContext,
2545            associated_error: Option<&NSError>,
2546            attachments: &NSArray<XCTAttachment>,
2547        ) -> Retained<Self>;
2548
2549        #[unsafe(method(initWithType:compactDescription:detailedDescription:sourceCodeContext:associatedError:attachments:severity:))]
2550        #[unsafe(method_family = init)]
2551        pub fn initWithType_compactDescription_detailedDescription_sourceCodeContext_associatedError_attachments_severity(
2552            this: Allocated<Self>,
2553            r#type: XCTIssueType,
2554            compact_description: &NSString,
2555            detailed_description: Option<&NSString>,
2556            source_code_context: &XCTSourceCodeContext,
2557            associated_error: Option<&NSError>,
2558            attachments: &NSArray<XCTAttachment>,
2559            severity: XCTIssueSeverity,
2560        ) -> Retained<Self>;
2561
2562        #[unsafe(method(initWithType:compactDescription:severity:))]
2563        #[unsafe(method_family = init)]
2564        pub fn initWithType_compactDescription_severity(
2565            this: Allocated<Self>,
2566            r#type: XCTIssueType,
2567            compact_description: &NSString,
2568            severity: XCTIssueSeverity,
2569        ) -> Retained<Self>;
2570
2571        #[unsafe(method(initWithType:compactDescription:))]
2572        #[unsafe(method_family = init)]
2573        pub fn initWithType_compactDescription(
2574            this: Allocated<Self>,
2575            r#type: XCTIssueType,
2576            compact_description: &NSString,
2577        ) -> Retained<Self>;
2578
2579        #[unsafe(method(init))]
2580        #[unsafe(method_family = init)]
2581        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2582
2583        #[unsafe(method(new))]
2584        #[unsafe(method_family = new)]
2585        pub unsafe fn new() -> Retained<Self>;
2586
2587        /// The type of the issue.
2588        #[unsafe(method(type))]
2589        #[unsafe(method_family = none)]
2590        pub fn r#type(&self) -> XCTIssueType;
2591
2592        /// A concise description of the issue, expected to be free of transient data and suitable for use in test run
2593        /// summaries and for aggregation of results across multiple test runs.
2594        #[unsafe(method(compactDescription))]
2595        #[unsafe(method_family = none)]
2596        pub fn compactDescription(&self) -> Retained<NSString>;
2597
2598        /// A detailed description of the issue designed to help diagnose the issue. May include transient data such as
2599        /// numbers, object identifiers, timestamps, etc.
2600        #[unsafe(method(detailedDescription))]
2601        #[unsafe(method_family = none)]
2602        pub fn detailedDescription(&self) -> Option<Retained<NSString>>;
2603
2604        /// The source code location (file and line number) and the call stack associated with the issue.
2605        #[unsafe(method(sourceCodeContext))]
2606        #[unsafe(method_family = none)]
2607        pub fn sourceCodeContext(&self) -> Retained<XCTSourceCodeContext>;
2608
2609        /// Error associated with the issue.
2610        #[unsafe(method(associatedError))]
2611        #[unsafe(method_family = none)]
2612        pub fn associatedError(&self) -> Option<Retained<NSError>>;
2613
2614        /// All attachments associated with the issue.
2615        #[unsafe(method(attachments))]
2616        #[unsafe(method_family = none)]
2617        pub fn attachments(&self) -> Retained<NSArray<XCTAttachment>>;
2618
2619        /// The severity of the issue.
2620        #[unsafe(method(severity))]
2621        #[unsafe(method_family = none)]
2622        pub fn severity(&self) -> XCTIssueSeverity;
2623
2624        /// Whether or not this issue should cause the test it's associated with to be
2625        /// considered a failure.
2626        ///
2627        /// The value of this property is `YES` for issues which have a severity level of
2628        /// ``XCTIssueSeverityError`` or higher.
2629        /// Otherwise, the value of this property is `NO`.
2630        ///
2631        /// Use this property to determine if an issue should be considered a failure, instead of
2632        /// directly comparing the value of the ``severity`` property.
2633        #[unsafe(method(isFailure))]
2634        #[unsafe(method_family = none)]
2635        pub fn isFailure(&self) -> bool;
2636    );
2637}
2638
2639extern_class!(
2640    /// Mutable variant of XCTIssue, suitable for modifying by overrides in the reporting chain.
2641    ///
2642    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctmutableissue?language=objc)
2643    #[unsafe(super(XCTIssue, NSObject))]
2644    #[derive(Debug, PartialEq, Eq, Hash)]
2645    pub struct XCTMutableIssue;
2646);
2647
2648extern_conformance!(
2649    unsafe impl NSCoding for XCTMutableIssue {}
2650);
2651
2652extern_conformance!(
2653    unsafe impl NSCopying for XCTMutableIssue {}
2654);
2655
2656unsafe impl CopyingHelper for XCTMutableIssue {
2657    type Result = XCTIssue;
2658}
2659
2660extern_conformance!(
2661    unsafe impl NSMutableCopying for XCTMutableIssue {}
2662);
2663
2664unsafe impl MutableCopyingHelper for XCTMutableIssue {
2665    type Result = Self;
2666}
2667
2668extern_conformance!(
2669    unsafe impl NSObjectProtocol for XCTMutableIssue {}
2670);
2671
2672extern_conformance!(
2673    unsafe impl NSSecureCoding for XCTMutableIssue {}
2674);
2675
2676impl XCTMutableIssue {
2677    extern_methods!(
2678        #[unsafe(method(type))]
2679        #[unsafe(method_family = none)]
2680        pub fn r#type(&self) -> XCTIssueType;
2681
2682        /// Setter for [`type`][Self::type].
2683        #[unsafe(method(setType:))]
2684        #[unsafe(method_family = none)]
2685        pub fn setType(&self, r#type: XCTIssueType);
2686
2687        #[unsafe(method(compactDescription))]
2688        #[unsafe(method_family = none)]
2689        pub fn compactDescription(&self) -> Retained<NSString>;
2690
2691        /// Setter for [`compactDescription`][Self::compactDescription].
2692        ///
2693        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2694        #[unsafe(method(setCompactDescription:))]
2695        #[unsafe(method_family = none)]
2696        pub fn setCompactDescription(&self, compact_description: &NSString);
2697
2698        #[unsafe(method(detailedDescription))]
2699        #[unsafe(method_family = none)]
2700        pub fn detailedDescription(&self) -> Option<Retained<NSString>>;
2701
2702        /// Setter for [`detailedDescription`][Self::detailedDescription].
2703        ///
2704        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2705        #[unsafe(method(setDetailedDescription:))]
2706        #[unsafe(method_family = none)]
2707        pub fn setDetailedDescription(&self, detailed_description: Option<&NSString>);
2708
2709        #[unsafe(method(sourceCodeContext))]
2710        #[unsafe(method_family = none)]
2711        pub fn sourceCodeContext(&self) -> Retained<XCTSourceCodeContext>;
2712
2713        /// Setter for [`sourceCodeContext`][Self::sourceCodeContext].
2714        #[unsafe(method(setSourceCodeContext:))]
2715        #[unsafe(method_family = none)]
2716        pub fn setSourceCodeContext(&self, source_code_context: &XCTSourceCodeContext);
2717
2718        #[unsafe(method(associatedError))]
2719        #[unsafe(method_family = none)]
2720        pub fn associatedError(&self) -> Option<Retained<NSError>>;
2721
2722        /// Setter for [`associatedError`][Self::associatedError].
2723        #[unsafe(method(setAssociatedError:))]
2724        #[unsafe(method_family = none)]
2725        pub fn setAssociatedError(&self, associated_error: Option<&NSError>);
2726
2727        #[unsafe(method(attachments))]
2728        #[unsafe(method_family = none)]
2729        pub fn attachments(&self) -> Retained<NSArray<XCTAttachment>>;
2730
2731        /// Setter for [`attachments`][Self::attachments].
2732        ///
2733        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2734        #[unsafe(method(setAttachments:))]
2735        #[unsafe(method_family = none)]
2736        pub fn setAttachments(&self, attachments: &NSArray<XCTAttachment>);
2737
2738        #[unsafe(method(severity))]
2739        #[unsafe(method_family = none)]
2740        pub fn severity(&self) -> XCTIssueSeverity;
2741
2742        /// Setter for [`severity`][Self::severity].
2743        #[unsafe(method(setSeverity:))]
2744        #[unsafe(method_family = none)]
2745        pub fn setSeverity(&self, severity: XCTIssueSeverity);
2746
2747        /// Add an attachment to this issue.
2748        #[unsafe(method(addAttachment:))]
2749        #[unsafe(method_family = none)]
2750        pub fn addAttachment(&self, attachment: &XCTAttachment);
2751    );
2752}
2753
2754/// Methods declared on superclass `XCTIssue`.
2755impl XCTMutableIssue {
2756    extern_methods!(
2757        #[unsafe(method(initWithType:compactDescription:detailedDescription:sourceCodeContext:associatedError:attachments:))]
2758        #[unsafe(method_family = init)]
2759        pub fn initWithType_compactDescription_detailedDescription_sourceCodeContext_associatedError_attachments(
2760            this: Allocated<Self>,
2761            r#type: XCTIssueType,
2762            compact_description: &NSString,
2763            detailed_description: Option<&NSString>,
2764            source_code_context: &XCTSourceCodeContext,
2765            associated_error: Option<&NSError>,
2766            attachments: &NSArray<XCTAttachment>,
2767        ) -> Retained<Self>;
2768
2769        #[unsafe(method(initWithType:compactDescription:detailedDescription:sourceCodeContext:associatedError:attachments:severity:))]
2770        #[unsafe(method_family = init)]
2771        pub fn initWithType_compactDescription_detailedDescription_sourceCodeContext_associatedError_attachments_severity(
2772            this: Allocated<Self>,
2773            r#type: XCTIssueType,
2774            compact_description: &NSString,
2775            detailed_description: Option<&NSString>,
2776            source_code_context: &XCTSourceCodeContext,
2777            associated_error: Option<&NSError>,
2778            attachments: &NSArray<XCTAttachment>,
2779            severity: XCTIssueSeverity,
2780        ) -> Retained<Self>;
2781
2782        #[unsafe(method(initWithType:compactDescription:severity:))]
2783        #[unsafe(method_family = init)]
2784        pub fn initWithType_compactDescription_severity(
2785            this: Allocated<Self>,
2786            r#type: XCTIssueType,
2787            compact_description: &NSString,
2788            severity: XCTIssueSeverity,
2789        ) -> Retained<Self>;
2790
2791        #[unsafe(method(initWithType:compactDescription:))]
2792        #[unsafe(method_family = init)]
2793        pub fn initWithType_compactDescription(
2794            this: Allocated<Self>,
2795            r#type: XCTIssueType,
2796            compact_description: &NSString,
2797        ) -> Retained<Self>;
2798
2799        #[unsafe(method(init))]
2800        #[unsafe(method_family = init)]
2801        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2802
2803        #[unsafe(method(new))]
2804        #[unsafe(method_family = new)]
2805        pub unsafe fn new() -> Retained<Self>;
2806    );
2807}
2808
2809/// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctmeasurementinvocationoptions?language=objc)
2810// NS_OPTIONS
2811#[repr(transparent)]
2812#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2813pub struct XCTMeasurementInvocationOptions(pub NSUInteger);
2814bitflags::bitflags! {
2815    impl XCTMeasurementInvocationOptions: NSUInteger {
2816        #[doc(alias = "XCTMeasurementInvocationNone")]
2817        const None = 0;
2818        #[doc(alias = "XCTMeasurementInvocationManuallyStart")]
2819        const ManuallyStart = 1<<0;
2820        #[doc(alias = "XCTMeasurementInvocationManuallyStop")]
2821        const ManuallyStop = 1<<1;
2822    }
2823}
2824
2825unsafe impl Encode for XCTMeasurementInvocationOptions {
2826    const ENCODING: Encoding = NSUInteger::ENCODING;
2827}
2828
2829unsafe impl RefEncode for XCTMeasurementInvocationOptions {
2830    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2831}
2832
2833extern_class!(
2834    /// Collection of options which configures behavior when passed into the -[XCTMeasure measure*] APIs.
2835    ///
2836    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctmeasureoptions?language=objc)
2837    #[unsafe(super(NSObject))]
2838    #[derive(Debug, PartialEq, Eq, Hash)]
2839    pub struct XCTMeasureOptions;
2840);
2841
2842extern_conformance!(
2843    unsafe impl NSObjectProtocol for XCTMeasureOptions {}
2844);
2845
2846impl XCTMeasureOptions {
2847    extern_methods!(
2848        /// Builds a set of recommended default options for measuring.
2849        ///
2850        ///
2851        /// Returns: An object which represents a set of default configuration options for measuring.
2852        #[unsafe(method(defaultOptions))]
2853        #[unsafe(method_family = none)]
2854        pub fn defaultOptions() -> Retained<XCTMeasureOptions>;
2855
2856        /// Set of options which configure how measurements are taken. The default option is XCTMeasurementInvocationNone.
2857        #[unsafe(method(invocationOptions))]
2858        #[unsafe(method_family = none)]
2859        pub fn invocationOptions(&self) -> XCTMeasurementInvocationOptions;
2860
2861        /// Setter for [`invocationOptions`][Self::invocationOptions].
2862        #[unsafe(method(setInvocationOptions:))]
2863        #[unsafe(method_family = none)]
2864        pub fn setInvocationOptions(&self, invocation_options: XCTMeasurementInvocationOptions);
2865
2866        /// The number of times the block being measured should be invoked. The default value is 5.
2867        /// Note that the block is actually invoked `iterationCount` + 1 times, and the first iteration
2868        /// is discarded. This is done to reduce the chance that the first iteration will be an outlier.
2869        #[unsafe(method(iterationCount))]
2870        #[unsafe(method_family = none)]
2871        pub fn iterationCount(&self) -> NSUInteger;
2872
2873        /// Setter for [`iterationCount`][Self::iterationCount].
2874        #[unsafe(method(setIterationCount:))]
2875        #[unsafe(method_family = none)]
2876        pub fn setIterationCount(&self, iteration_count: NSUInteger);
2877    );
2878}
2879
2880/// Methods declared on superclass `NSObject`.
2881impl XCTMeasureOptions {
2882    extern_methods!(
2883        #[unsafe(method(init))]
2884        #[unsafe(method_family = init)]
2885        pub fn init(this: Allocated<Self>) -> Retained<Self>;
2886
2887        #[unsafe(method(new))]
2888        #[unsafe(method_family = new)]
2889        pub fn new() -> Retained<Self>;
2890    );
2891}
2892
2893impl DefaultRetained for XCTMeasureOptions {
2894    #[inline]
2895    fn default_retained() -> Retained<Self> {
2896        Self::new()
2897    }
2898}
2899
2900/// [Apple's documentation](https://developer.apple.com/documentation/xctest/xctperformancemeasurementpolarity?language=objc)
2901// NS_ENUM
2902#[repr(transparent)]
2903#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2904pub struct XCTPerformanceMeasurementPolarity(pub NSInteger);
2905impl XCTPerformanceMeasurementPolarity {
2906    /// Represents measurements where smaller values are considered "better".
2907    #[doc(alias = "XCTPerformanceMeasurementPolarityPrefersSmaller")]
2908    pub const PrefersSmaller: Self = Self(-1);
2909    /// Represents measurements which do not have a meaningful polarity. Suitable for situations where neither smaller nor larger values are considered "better".
2910    #[doc(alias = "XCTPerformanceMeasurementPolarityUnspecified")]
2911    pub const Unspecified: Self = Self(0);
2912    /// Represents measurements where larger values are considered "better".
2913    #[doc(alias = "XCTPerformanceMeasurementPolarityPrefersLarger")]
2914    pub const PrefersLarger: Self = Self(1);
2915}
2916
2917unsafe impl Encode for XCTPerformanceMeasurementPolarity {
2918    const ENCODING: Encoding = NSInteger::ENCODING;
2919}
2920
2921unsafe impl RefEncode for XCTPerformanceMeasurementPolarity {
2922    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2923}
2924
2925extern_class!(
2926    /// Encapsulates timestamps at various levels
2927    ///
2928    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctperformancemeasurementtimestamp?language=objc)
2929    #[unsafe(super(NSObject))]
2930    #[derive(Debug, PartialEq, Eq, Hash)]
2931    pub struct XCTPerformanceMeasurementTimestamp;
2932);
2933
2934extern_conformance!(
2935    unsafe impl NSObjectProtocol for XCTPerformanceMeasurementTimestamp {}
2936);
2937
2938impl XCTPerformanceMeasurementTimestamp {
2939    extern_methods!(
2940        /// The timestamp recorded using mach_absolute_time().
2941        #[unsafe(method(absoluteTime))]
2942        #[unsafe(method_family = none)]
2943        pub fn absoluteTime(&self) -> u64;
2944
2945        /// Nanoseconds since an arbitrary point, does not increment while the system is asleep.
2946        #[unsafe(method(absoluteTimeNanoSeconds))]
2947        #[unsafe(method_family = none)]
2948        pub fn absoluteTimeNanoSeconds(&self) -> u64;
2949
2950        /// The timestamp recorded using an NSDate.
2951        #[unsafe(method(date))]
2952        #[unsafe(method_family = none)]
2953        pub fn date(&self) -> Retained<NSDate>;
2954
2955        /// Initializes an object with the given mach absolute time and NSDate instance.
2956        #[unsafe(method(initWithAbsoluteTime:date:))]
2957        #[unsafe(method_family = init)]
2958        pub fn initWithAbsoluteTime_date(
2959            this: Allocated<Self>,
2960            absolute_time: u64,
2961            date: &NSDate,
2962        ) -> Retained<Self>;
2963
2964        /// Initializes an object which represents a timestamp at the current time.
2965        #[unsafe(method(init))]
2966        #[unsafe(method_family = init)]
2967        pub fn init(this: Allocated<Self>) -> Retained<Self>;
2968    );
2969}
2970
2971/// Methods declared on superclass `NSObject`.
2972impl XCTPerformanceMeasurementTimestamp {
2973    extern_methods!(
2974        #[unsafe(method(new))]
2975        #[unsafe(method_family = new)]
2976        pub fn new() -> Retained<Self>;
2977    );
2978}
2979
2980impl DefaultRetained for XCTPerformanceMeasurementTimestamp {
2981    #[inline]
2982    fn default_retained() -> Retained<Self> {
2983        Self::new()
2984    }
2985}
2986
2987extern_class!(
2988    /// Contains the data acquired from a single metric being measured for an individual iteration.
2989    ///
2990    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctperformancemeasurement?language=objc)
2991    #[unsafe(super(NSObject))]
2992    #[derive(Debug, PartialEq, Eq, Hash)]
2993    pub struct XCTPerformanceMeasurement;
2994);
2995
2996extern_conformance!(
2997    unsafe impl NSObjectProtocol for XCTPerformanceMeasurement {}
2998);
2999
3000impl XCTPerformanceMeasurement {
3001    extern_methods!(
3002        /// A unique identifier for this measurement such as "com.apple.XCTPerformanceMetric_WallClockTime".
3003        #[unsafe(method(identifier))]
3004        #[unsafe(method_family = none)]
3005        pub fn identifier(&self) -> Retained<NSString>;
3006
3007        /// The human-readable name for this measurement, such as "Wall Clock Time".
3008        #[unsafe(method(displayName))]
3009        #[unsafe(method_family = none)]
3010        pub fn displayName(&self) -> Retained<NSString>;
3011
3012        /// The value of the measurement.
3013        #[unsafe(method(value))]
3014        #[unsafe(method_family = none)]
3015        pub fn value(&self) -> Retained<NSMeasurement>;
3016
3017        /// The double value of the measurement.
3018        #[unsafe(method(doubleValue))]
3019        #[unsafe(method_family = none)]
3020        pub fn doubleValue(&self) -> c_double;
3021
3022        /// A string describing the unit the value is in.
3023        #[unsafe(method(unitSymbol))]
3024        #[unsafe(method_family = none)]
3025        pub fn unitSymbol(&self) -> Retained<NSString>;
3026
3027        /// An enum value representing in which direction measurements should be compared against their baselines.
3028        #[unsafe(method(polarity))]
3029        #[unsafe(method_family = none)]
3030        pub fn polarity(&self) -> XCTPerformanceMeasurementPolarity;
3031
3032        /// Initializes an object which encapsulates the measurement for a metric during a single iteration.
3033        ///
3034        ///
3035        /// Parameter `identifier`: A unique identifier for this measurement such as "com.apple.XCTPerformanceMetric_WallClockTime".
3036        ///
3037        /// Parameter `displayName`: A human-readable name for this measurement, such as "Wall Clock Time".
3038        ///
3039        /// Parameter `value`: The value of the measurement.
3040        ///
3041        /// # Safety
3042        ///
3043        /// `value` generic should be bound by `AsRef<NSUnit>`.
3044        #[unsafe(method(initWithIdentifier:displayName:value:))]
3045        #[unsafe(method_family = init)]
3046        pub unsafe fn initWithIdentifier_displayName_value(
3047            this: Allocated<Self>,
3048            identifier: &NSString,
3049            display_name: &NSString,
3050            value: &NSMeasurement,
3051        ) -> Retained<Self>;
3052
3053        /// Initializes an object which encapsulates the measurement for a metric during a single iteration.
3054        ///
3055        ///
3056        /// Parameter `identifier`: A unique identifier for this measurement such as "com.apple.XCTPerformanceMetric_WallClockTime".
3057        ///
3058        /// Parameter `displayName`: A human-readable name for this measurement, such as "Wall Clock Time".
3059        ///
3060        /// Parameter `doubleValue`: The double value of the measurement.
3061        ///
3062        /// Parameter `unitSymbol`: A string describing the unit the value is in.
3063        #[unsafe(method(initWithIdentifier:displayName:doubleValue:unitSymbol:))]
3064        #[unsafe(method_family = init)]
3065        pub fn initWithIdentifier_displayName_doubleValue_unitSymbol(
3066            this: Allocated<Self>,
3067            identifier: &NSString,
3068            display_name: &NSString,
3069            double_value: c_double,
3070            unit_symbol: &NSString,
3071        ) -> Retained<Self>;
3072
3073        /// Initializes an object which encapsulates the measurement for a metric during a single iteration.
3074        ///
3075        ///
3076        /// Parameter `identifier`: A unique identifier for this measurement such as "com.apple.XCTPerformanceMetric_WallClockTime".
3077        ///
3078        /// Parameter `displayName`: A human-readable name for this measurement, such as "Wall Clock Time".
3079        ///
3080        /// Parameter `value`: The value of the measurement.
3081        ///
3082        /// Parameter `polarity`: An enum value representing in which direction measurements should be compared against their baselines.
3083        ///
3084        /// # Safety
3085        ///
3086        /// `value` generic should be bound by `AsRef<NSUnit>`.
3087        #[unsafe(method(initWithIdentifier:displayName:value:polarity:))]
3088        #[unsafe(method_family = init)]
3089        pub unsafe fn initWithIdentifier_displayName_value_polarity(
3090            this: Allocated<Self>,
3091            identifier: &NSString,
3092            display_name: &NSString,
3093            value: &NSMeasurement,
3094            polarity: XCTPerformanceMeasurementPolarity,
3095        ) -> Retained<Self>;
3096
3097        /// Initializes an object which encapsulates the measurement for a metric during a single iteration.
3098        ///
3099        ///
3100        /// Parameter `identifier`: A unique identifier for this measurement such as "com.apple.XCTPerformanceMetric_WallClockTime".
3101        ///
3102        /// Parameter `displayName`: A human-readable name for this measurement, such as "Wall Clock Time".
3103        ///
3104        /// Parameter `doubleValue`: The double value of the measurement.
3105        ///
3106        /// Parameter `unitSymbol`: A string describing the unit the value is in.
3107        ///
3108        /// Parameter `polarity`: An enum value representing in which direction measurements should be compared against their baselines.
3109        #[unsafe(method(initWithIdentifier:displayName:doubleValue:unitSymbol:polarity:))]
3110        #[unsafe(method_family = init)]
3111        pub fn initWithIdentifier_displayName_doubleValue_unitSymbol_polarity(
3112            this: Allocated<Self>,
3113            identifier: &NSString,
3114            display_name: &NSString,
3115            double_value: c_double,
3116            unit_symbol: &NSString,
3117            polarity: XCTPerformanceMeasurementPolarity,
3118        ) -> Retained<Self>;
3119
3120        #[unsafe(method(init))]
3121        #[unsafe(method_family = init)]
3122        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3123
3124        #[unsafe(method(new))]
3125        #[unsafe(method_family = new)]
3126        pub fn new() -> Retained<Self>;
3127    );
3128}
3129
3130impl DefaultRetained for XCTPerformanceMeasurement {
3131    #[inline]
3132    fn default_retained() -> Retained<Self> {
3133        Self::new()
3134    }
3135}
3136
3137extern_protocol!(
3138    /// Defines a protocol which may be used with the -measureWithMetrics* methods on XCTestCase.
3139    ///
3140    ///
3141    /// Classes conforming to XCTMetric must also adopt NSCopying, as a unique metric instance is copied for each iteration.
3142    ///
3143    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctmetric?language=objc)
3144    pub unsafe trait XCTMetric: NSCopying + NSObjectProtocol {
3145        /// Report measurements for the iteration that started and ended at the specified times.
3146        ///
3147        ///
3148        /// Called after -didStopMeasuring has been invoked and when XCTest is ready to gather
3149        /// the measurements that were collected. You can truncate the data accumulated to be as
3150        /// accurate as possible with the start and end times.
3151        #[unsafe(method(reportMeasurementsFromStartTime:toEndTime:error:_))]
3152        #[unsafe(method_family = none)]
3153        fn reportMeasurementsFromStartTime_toEndTime_error(
3154            &self,
3155            start_time: &XCTPerformanceMeasurementTimestamp,
3156            end_time: &XCTPerformanceMeasurementTimestamp,
3157        ) -> Result<Retained<NSArray<XCTPerformanceMeasurement>>, Retained<NSError>>;
3158
3159        /// Called every iteration just before the measure block is about to be invoked.
3160        /// You should begin measuring when this is called.
3161        #[optional]
3162        #[unsafe(method(willBeginMeasuring))]
3163        #[unsafe(method_family = none)]
3164        fn willBeginMeasuring(&self);
3165
3166        /// Called after the measure block's invocation. You should stop measuring when
3167        /// this is called.
3168        #[optional]
3169        #[unsafe(method(didStopMeasuring))]
3170        #[unsafe(method_family = none)]
3171        fn didStopMeasuring(&self);
3172    }
3173);
3174
3175extern_class!(
3176    /// A metric which gathers monotonic time data.
3177    ///
3178    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctclockmetric?language=objc)
3179    #[unsafe(super(NSObject))]
3180    #[derive(Debug, PartialEq, Eq, Hash)]
3181    pub struct XCTClockMetric;
3182);
3183
3184extern_conformance!(
3185    unsafe impl NSCopying for XCTClockMetric {}
3186);
3187
3188unsafe impl CopyingHelper for XCTClockMetric {
3189    type Result = Self;
3190}
3191
3192extern_conformance!(
3193    unsafe impl NSObjectProtocol for XCTClockMetric {}
3194);
3195
3196extern_conformance!(
3197    unsafe impl XCTMetric for XCTClockMetric {}
3198);
3199
3200impl XCTClockMetric {
3201    extern_methods!(
3202        /// Initializes a metric which is recommended for measuring time.
3203        ///
3204        ///
3205        /// Returns: A new instance of a metric which will measure time.
3206        #[unsafe(method(init))]
3207        #[unsafe(method_family = init)]
3208        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3209    );
3210}
3211
3212/// Methods declared on superclass `NSObject`.
3213impl XCTClockMetric {
3214    extern_methods!(
3215        #[unsafe(method(new))]
3216        #[unsafe(method_family = new)]
3217        pub fn new() -> Retained<Self>;
3218    );
3219}
3220
3221impl DefaultRetained for XCTClockMetric {
3222    #[inline]
3223    fn default_retained() -> Retained<Self> {
3224        Self::new()
3225    }
3226}
3227
3228extern_class!(
3229    /// A metric which measures timestamp data gathered from os_signposts.
3230    /// If the interval being measured is an animation os_signpost interval then the following
3231    /// data will also be gathered:
3232    /// - frame rate (fps)
3233    /// - frame count
3234    /// - number of hitches
3235    /// - hitch total time duration (ms)
3236    /// - hitch time ratio (ms per s)
3237    ///
3238    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctossignpostmetric?language=objc)
3239    #[unsafe(super(NSObject))]
3240    #[derive(Debug, PartialEq, Eq, Hash)]
3241    pub struct XCTOSSignpostMetric;
3242);
3243
3244extern_conformance!(
3245    unsafe impl NSCopying for XCTOSSignpostMetric {}
3246);
3247
3248unsafe impl CopyingHelper for XCTOSSignpostMetric {
3249    type Result = Self;
3250}
3251
3252extern_conformance!(
3253    unsafe impl NSObjectProtocol for XCTOSSignpostMetric {}
3254);
3255
3256extern_conformance!(
3257    unsafe impl XCTMetric for XCTOSSignpostMetric {}
3258);
3259
3260impl XCTOSSignpostMetric {
3261    extern_methods!(
3262        /// Initializes a metric which describes a custom signpost.
3263        ///
3264        ///
3265        /// Parameter `subsystem`: The subsystem of the target signpost.
3266        ///
3267        /// Parameter `category`: The category of the target signpost.
3268        ///
3269        /// Parameter `name`: The name of the target signpost.
3270        ///
3271        /// Returns: A signpost metric describing the target signpost.
3272        #[unsafe(method(initWithSubsystem:category:name:))]
3273        #[unsafe(method_family = init)]
3274        pub fn initWithSubsystem_category_name(
3275            this: Allocated<Self>,
3276            subsystem: &NSString,
3277            category: &NSString,
3278            name: &NSString,
3279        ) -> Retained<Self>;
3280
3281        #[unsafe(method(init))]
3282        #[unsafe(method_family = init)]
3283        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3284
3285        #[unsafe(method(new))]
3286        #[unsafe(method_family = new)]
3287        pub fn new() -> Retained<Self>;
3288    );
3289}
3290
3291impl DefaultRetained for XCTOSSignpostMetric {
3292    #[inline]
3293    fn default_retained() -> Retained<Self> {
3294        Self::new()
3295    }
3296}
3297
3298/// XCTBuiltinOSSignposts.
3299///
3300/// Interface extension describing OS Signposts that are instrumented by the OS.
3301impl XCTOSSignpostMetric {
3302    extern_methods!(
3303        /// The XCTOSSignpostMetric object covering application launch
3304        #[deprecated = "Use XCTApplicationLaunchMetric instead"]
3305        #[unsafe(method(applicationLaunchMetric))]
3306        #[unsafe(method_family = none)]
3307        pub fn applicationLaunchMetric() -> Retained<XCTOSSignpostMetric>;
3308
3309        /// The XCTMetric object covering navigation transitions between views
3310        #[unsafe(method(navigationTransitionMetric))]
3311        #[unsafe(method_family = none)]
3312        pub fn navigationTransitionMetric() -> Retained<ProtocolObject<dyn XCTMetric>>;
3313
3314        /// The XCTMetric object covering custom navigation transitions between views
3315        #[unsafe(method(customNavigationTransitionMetric))]
3316        #[unsafe(method_family = none)]
3317        pub fn customNavigationTransitionMetric() -> Retained<ProtocolObject<dyn XCTMetric>>;
3318
3319        /// The XCTMetric object covering both the scroll and deceleration animations
3320        #[unsafe(method(scrollingAndDecelerationMetric))]
3321        #[unsafe(method_family = none)]
3322        pub fn scrollingAndDecelerationMetric() -> Retained<ProtocolObject<dyn XCTMetric>>;
3323
3324        /// The XCTMetric object covering scroll deceleration animations
3325        #[deprecated]
3326        #[unsafe(method(scrollDecelerationMetric))]
3327        #[unsafe(method_family = none)]
3328        pub fn scrollDecelerationMetric() -> Retained<ProtocolObject<dyn XCTMetric>>;
3329
3330        /// The XCTMetric object covering scroll dragging animations
3331        #[deprecated]
3332        #[unsafe(method(scrollDraggingMetric))]
3333        #[unsafe(method_family = none)]
3334        pub fn scrollDraggingMetric() -> Retained<ProtocolObject<dyn XCTMetric>>;
3335    );
3336}
3337
3338extern_class!(
3339    /// A metric which measures application launch durations.
3340    ///
3341    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctapplicationlaunchmetric?language=objc)
3342    #[unsafe(super(NSObject))]
3343    #[derive(Debug, PartialEq, Eq, Hash)]
3344    pub struct XCTApplicationLaunchMetric;
3345);
3346
3347extern_conformance!(
3348    unsafe impl NSCopying for XCTApplicationLaunchMetric {}
3349);
3350
3351unsafe impl CopyingHelper for XCTApplicationLaunchMetric {
3352    type Result = Self;
3353}
3354
3355extern_conformance!(
3356    unsafe impl NSObjectProtocol for XCTApplicationLaunchMetric {}
3357);
3358
3359extern_conformance!(
3360    unsafe impl XCTMetric for XCTApplicationLaunchMetric {}
3361);
3362
3363impl XCTApplicationLaunchMetric {
3364    extern_methods!(
3365        /// Initializes an application launch metric that measures the amount of time an
3366        /// application takes to display its first frame to screen.
3367        #[unsafe(method(init))]
3368        #[unsafe(method_family = init)]
3369        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3370
3371        /// Initializes an application launch metric that measures the amount of time it takes
3372        /// for an application to display its first frame to screen and for its main thread to be
3373        /// ready to accept user input.
3374        ///
3375        ///
3376        /// Parameter `waitUntilResponsive`: Specifies the end of the application launch
3377        /// interval to be when the application's main thread is responsive to user input.
3378        #[unsafe(method(initWithWaitUntilResponsive:))]
3379        #[unsafe(method_family = init)]
3380        pub fn initWithWaitUntilResponsive(
3381            this: Allocated<Self>,
3382            wait_until_responsive: bool,
3383        ) -> Retained<Self>;
3384    );
3385}
3386
3387/// Methods declared on superclass `NSObject`.
3388impl XCTApplicationLaunchMetric {
3389    extern_methods!(
3390        #[unsafe(method(new))]
3391        #[unsafe(method_family = new)]
3392        pub fn new() -> Retained<Self>;
3393    );
3394}
3395
3396impl DefaultRetained for XCTApplicationLaunchMetric {
3397    #[inline]
3398    fn default_retained() -> Retained<Self> {
3399        Self::new()
3400    }
3401}
3402
3403extern_class!(
3404    /// A metric which measures instructions retired and time utilization of the CPU.
3405    ///
3406    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctcpumetric?language=objc)
3407    #[unsafe(super(NSObject))]
3408    #[derive(Debug, PartialEq, Eq, Hash)]
3409    pub struct XCTCPUMetric;
3410);
3411
3412extern_conformance!(
3413    unsafe impl NSCopying for XCTCPUMetric {}
3414);
3415
3416unsafe impl CopyingHelper for XCTCPUMetric {
3417    type Result = Self;
3418}
3419
3420extern_conformance!(
3421    unsafe impl NSObjectProtocol for XCTCPUMetric {}
3422);
3423
3424extern_conformance!(
3425    unsafe impl XCTMetric for XCTCPUMetric {}
3426);
3427
3428impl XCTCPUMetric {
3429    extern_methods!(
3430        /// Creates a metric which will observe CPU activity for the thread that executes
3431        /// the block being measured. For single-threaded workloads, this provides greater
3432        /// precision and lower variance than -init.
3433        ///
3434        ///
3435        /// Note: The Thread under test is defined as the thread which will perform the execution of the work provided to the -[XCTestCase measure*] API.
3436        ///
3437        ///
3438        /// Returns: An initialized metric.
3439        #[unsafe(method(initLimitingToCurrentThread:))]
3440        #[unsafe(method_family = init)]
3441        pub fn initLimitingToCurrentThread(
3442            this: Allocated<Self>,
3443            limit_to_current_thread: bool,
3444        ) -> Retained<Self>;
3445
3446        /// Creates a metric that will target the current process.
3447        ///
3448        ///
3449        /// Returns: An initialized metric.
3450        #[unsafe(method(init))]
3451        #[unsafe(method_family = init)]
3452        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3453    );
3454}
3455
3456/// Methods declared on superclass `NSObject`.
3457impl XCTCPUMetric {
3458    extern_methods!(
3459        #[unsafe(method(new))]
3460        #[unsafe(method_family = new)]
3461        pub fn new() -> Retained<Self>;
3462    );
3463}
3464
3465impl DefaultRetained for XCTCPUMetric {
3466    #[inline]
3467    fn default_retained() -> Retained<Self> {
3468        Self::new()
3469    }
3470}
3471
3472extern_class!(
3473    /// A metric which measures utilization of physical memory.
3474    ///
3475    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctmemorymetric?language=objc)
3476    #[unsafe(super(NSObject))]
3477    #[derive(Debug, PartialEq, Eq, Hash)]
3478    pub struct XCTMemoryMetric;
3479);
3480
3481extern_conformance!(
3482    unsafe impl NSCopying for XCTMemoryMetric {}
3483);
3484
3485unsafe impl CopyingHelper for XCTMemoryMetric {
3486    type Result = Self;
3487}
3488
3489extern_conformance!(
3490    unsafe impl NSObjectProtocol for XCTMemoryMetric {}
3491);
3492
3493extern_conformance!(
3494    unsafe impl XCTMetric for XCTMemoryMetric {}
3495);
3496
3497impl XCTMemoryMetric {
3498    extern_methods!(
3499        /// Creates a metric that will target the current process.
3500        ///
3501        ///
3502        /// Returns: An initialized metric.
3503        #[unsafe(method(init))]
3504        #[unsafe(method_family = init)]
3505        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3506    );
3507}
3508
3509/// Methods declared on superclass `NSObject`.
3510impl XCTMemoryMetric {
3511    extern_methods!(
3512        #[unsafe(method(new))]
3513        #[unsafe(method_family = new)]
3514        pub fn new() -> Retained<Self>;
3515    );
3516}
3517
3518impl DefaultRetained for XCTMemoryMetric {
3519    #[inline]
3520    fn default_retained() -> Retained<Self> {
3521        Self::new()
3522    }
3523}
3524
3525extern_class!(
3526    /// A metric which measures utilization of the file storage media.
3527    ///
3528    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctstoragemetric?language=objc)
3529    #[unsafe(super(NSObject))]
3530    #[derive(Debug, PartialEq, Eq, Hash)]
3531    pub struct XCTStorageMetric;
3532);
3533
3534extern_conformance!(
3535    unsafe impl NSCopying for XCTStorageMetric {}
3536);
3537
3538unsafe impl CopyingHelper for XCTStorageMetric {
3539    type Result = Self;
3540}
3541
3542extern_conformance!(
3543    unsafe impl NSObjectProtocol for XCTStorageMetric {}
3544);
3545
3546extern_conformance!(
3547    unsafe impl XCTMetric for XCTStorageMetric {}
3548);
3549
3550impl XCTStorageMetric {
3551    extern_methods!(
3552        /// Creates a metric that will target the current process.
3553        ///
3554        ///
3555        /// Returns: An initialized metric.
3556        #[unsafe(method(init))]
3557        #[unsafe(method_family = init)]
3558        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3559    );
3560}
3561
3562/// Methods declared on superclass `NSObject`.
3563impl XCTStorageMetric {
3564    extern_methods!(
3565        #[unsafe(method(new))]
3566        #[unsafe(method_family = new)]
3567        pub fn new() -> Retained<Self>;
3568    );
3569}
3570
3571impl DefaultRetained for XCTStorageMetric {
3572    #[inline]
3573    fn default_retained() -> Retained<Self> {
3574        Self::new()
3575    }
3576}
3577
3578extern_class!(
3579    /// A metric which measures the hitches encountered.
3580    ///
3581    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xcthitchmetric?language=objc)
3582    #[unsafe(super(NSObject))]
3583    #[derive(Debug, PartialEq, Eq, Hash)]
3584    pub struct XCTHitchMetric;
3585);
3586
3587extern_conformance!(
3588    unsafe impl NSCopying for XCTHitchMetric {}
3589);
3590
3591unsafe impl CopyingHelper for XCTHitchMetric {
3592    type Result = Self;
3593}
3594
3595extern_conformance!(
3596    unsafe impl NSObjectProtocol for XCTHitchMetric {}
3597);
3598
3599extern_conformance!(
3600    unsafe impl XCTMetric for XCTHitchMetric {}
3601);
3602
3603impl XCTHitchMetric {
3604    extern_methods!(
3605        #[unsafe(method(init))]
3606        #[unsafe(method_family = init)]
3607        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3608
3609        #[unsafe(method(new))]
3610        #[unsafe(method_family = new)]
3611        pub unsafe fn new() -> Retained<Self>;
3612    );
3613}
3614
3615extern_class!(
3616    /// Contains a file URL and line number representing a distinct location in source code related to a run of a test.
3617    ///
3618    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctsourcecodelocation?language=objc)
3619    #[unsafe(super(NSObject))]
3620    #[derive(Debug, PartialEq, Eq, Hash)]
3621    pub struct XCTSourceCodeLocation;
3622);
3623
3624extern_conformance!(
3625    unsafe impl NSCoding for XCTSourceCodeLocation {}
3626);
3627
3628extern_conformance!(
3629    unsafe impl NSObjectProtocol for XCTSourceCodeLocation {}
3630);
3631
3632extern_conformance!(
3633    unsafe impl NSSecureCoding for XCTSourceCodeLocation {}
3634);
3635
3636impl XCTSourceCodeLocation {
3637    extern_methods!(
3638        #[unsafe(method(initWithFileURL:lineNumber:))]
3639        #[unsafe(method_family = init)]
3640        pub fn initWithFileURL_lineNumber(
3641            this: Allocated<Self>,
3642            file_url: &NSURL,
3643            line_number: NSInteger,
3644        ) -> Retained<Self>;
3645
3646        #[unsafe(method(initWithFilePath:lineNumber:))]
3647        #[unsafe(method_family = init)]
3648        pub fn initWithFilePath_lineNumber(
3649            this: Allocated<Self>,
3650            file_path: &NSString,
3651            line_number: NSInteger,
3652        ) -> Retained<Self>;
3653
3654        #[unsafe(method(init))]
3655        #[unsafe(method_family = init)]
3656        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3657
3658        #[unsafe(method(new))]
3659        #[unsafe(method_family = new)]
3660        pub unsafe fn new() -> Retained<Self>;
3661
3662        #[unsafe(method(fileURL))]
3663        #[unsafe(method_family = none)]
3664        pub fn fileURL(&self) -> Retained<NSURL>;
3665
3666        #[unsafe(method(lineNumber))]
3667        #[unsafe(method_family = none)]
3668        pub fn lineNumber(&self) -> NSInteger;
3669    );
3670}
3671
3672extern_class!(
3673    /// Contains symbolication information for a given frame in a call stack.
3674    ///
3675    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctsourcecodesymbolinfo?language=objc)
3676    #[unsafe(super(NSObject))]
3677    #[derive(Debug, PartialEq, Eq, Hash)]
3678    pub struct XCTSourceCodeSymbolInfo;
3679);
3680
3681extern_conformance!(
3682    unsafe impl NSCoding for XCTSourceCodeSymbolInfo {}
3683);
3684
3685extern_conformance!(
3686    unsafe impl NSObjectProtocol for XCTSourceCodeSymbolInfo {}
3687);
3688
3689extern_conformance!(
3690    unsafe impl NSSecureCoding for XCTSourceCodeSymbolInfo {}
3691);
3692
3693impl XCTSourceCodeSymbolInfo {
3694    extern_methods!(
3695        #[unsafe(method(initWithImageName:symbolName:location:))]
3696        #[unsafe(method_family = init)]
3697        pub fn initWithImageName_symbolName_location(
3698            this: Allocated<Self>,
3699            image_name: &NSString,
3700            symbol_name: &NSString,
3701            location: Option<&XCTSourceCodeLocation>,
3702        ) -> Retained<Self>;
3703
3704        #[unsafe(method(init))]
3705        #[unsafe(method_family = init)]
3706        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3707
3708        #[unsafe(method(new))]
3709        #[unsafe(method_family = new)]
3710        pub unsafe fn new() -> Retained<Self>;
3711
3712        #[unsafe(method(imageName))]
3713        #[unsafe(method_family = none)]
3714        pub fn imageName(&self) -> Retained<NSString>;
3715
3716        #[unsafe(method(symbolName))]
3717        #[unsafe(method_family = none)]
3718        pub fn symbolName(&self) -> Retained<NSString>;
3719
3720        #[unsafe(method(location))]
3721        #[unsafe(method_family = none)]
3722        pub fn location(&self) -> Option<Retained<XCTSourceCodeLocation>>;
3723    );
3724}
3725
3726extern_class!(
3727    /// Represents a single frame in a call stack and supports retrieval of symbol information for the address.
3728    ///
3729    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctsourcecodeframe?language=objc)
3730    #[unsafe(super(NSObject))]
3731    #[derive(Debug, PartialEq, Eq, Hash)]
3732    pub struct XCTSourceCodeFrame;
3733);
3734
3735extern_conformance!(
3736    unsafe impl NSCoding for XCTSourceCodeFrame {}
3737);
3738
3739extern_conformance!(
3740    unsafe impl NSObjectProtocol for XCTSourceCodeFrame {}
3741);
3742
3743extern_conformance!(
3744    unsafe impl NSSecureCoding for XCTSourceCodeFrame {}
3745);
3746
3747impl XCTSourceCodeFrame {
3748    extern_methods!(
3749        #[unsafe(method(initWithAddress:symbolInfo:))]
3750        #[unsafe(method_family = init)]
3751        pub fn initWithAddress_symbolInfo(
3752            this: Allocated<Self>,
3753            address: u64,
3754            symbol_info: Option<&XCTSourceCodeSymbolInfo>,
3755        ) -> Retained<Self>;
3756
3757        #[unsafe(method(initWithAddress:))]
3758        #[unsafe(method_family = init)]
3759        pub fn initWithAddress(this: Allocated<Self>, address: u64) -> Retained<Self>;
3760
3761        #[unsafe(method(init))]
3762        #[unsafe(method_family = init)]
3763        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3764
3765        #[unsafe(method(new))]
3766        #[unsafe(method_family = new)]
3767        pub unsafe fn new() -> Retained<Self>;
3768
3769        #[unsafe(method(address))]
3770        #[unsafe(method_family = none)]
3771        pub fn address(&self) -> u64;
3772
3773        #[unsafe(method(symbolInfo))]
3774        #[unsafe(method_family = none)]
3775        pub fn symbolInfo(&self) -> Option<Retained<XCTSourceCodeSymbolInfo>>;
3776
3777        /// Error previously returned for symbolication attempt. This is not serialized when the frame is encoded.
3778        #[unsafe(method(symbolicationError))]
3779        #[unsafe(method_family = none)]
3780        pub fn symbolicationError(&self) -> Option<Retained<NSError>>;
3781
3782        /// method -symbolInfoWithError:
3783        /// Attempts to get symbol information for the address. This can fail if required symbol data is not available. Only
3784        /// one attempt will be made and the error will be stored and returned for future requests.
3785        #[unsafe(method(symbolInfoWithError:_))]
3786        #[unsafe(method_family = none)]
3787        pub fn symbolInfoWithError(
3788            &self,
3789        ) -> Result<Retained<XCTSourceCodeSymbolInfo>, Retained<NSError>>;
3790    );
3791}
3792
3793extern_class!(
3794    /// Call stack and optional specific location - which may or may not be also included in the call stack
3795    /// providing context around a point of execution in a test.
3796    ///
3797    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctsourcecodecontext?language=objc)
3798    #[unsafe(super(NSObject))]
3799    #[derive(Debug, PartialEq, Eq, Hash)]
3800    pub struct XCTSourceCodeContext;
3801);
3802
3803extern_conformance!(
3804    unsafe impl NSCoding for XCTSourceCodeContext {}
3805);
3806
3807extern_conformance!(
3808    unsafe impl NSObjectProtocol for XCTSourceCodeContext {}
3809);
3810
3811extern_conformance!(
3812    unsafe impl NSSecureCoding for XCTSourceCodeContext {}
3813);
3814
3815impl XCTSourceCodeContext {
3816    extern_methods!(
3817        #[unsafe(method(initWithCallStack:location:))]
3818        #[unsafe(method_family = init)]
3819        pub fn initWithCallStack_location(
3820            this: Allocated<Self>,
3821            call_stack: &NSArray<XCTSourceCodeFrame>,
3822            location: Option<&XCTSourceCodeLocation>,
3823        ) -> Retained<Self>;
3824
3825        /// The call stack addresses could be those from NSThread.callStackReturnAddresses,
3826        /// NSException.callStackReturnAddresses, or another source.
3827        #[unsafe(method(initWithCallStackAddresses:location:))]
3828        #[unsafe(method_family = init)]
3829        pub fn initWithCallStackAddresses_location(
3830            this: Allocated<Self>,
3831            call_stack_addresses: &NSArray<NSNumber>,
3832            location: Option<&XCTSourceCodeLocation>,
3833        ) -> Retained<Self>;
3834
3835        /// Initializes a new instance with call stack derived from NSThread.callStackReturnAddresses and the specified location.
3836        #[unsafe(method(initWithLocation:))]
3837        #[unsafe(method_family = init)]
3838        pub fn initWithLocation(
3839            this: Allocated<Self>,
3840            location: Option<&XCTSourceCodeLocation>,
3841        ) -> Retained<Self>;
3842
3843        /// Initializes a new instance with call stack derived from NSThread.callStackReturnAddresses and a nil location.
3844        #[unsafe(method(init))]
3845        #[unsafe(method_family = init)]
3846        pub fn init(this: Allocated<Self>) -> Retained<Self>;
3847
3848        #[unsafe(method(callStack))]
3849        #[unsafe(method_family = none)]
3850        pub fn callStack(&self) -> Retained<NSArray<XCTSourceCodeFrame>>;
3851
3852        #[unsafe(method(location))]
3853        #[unsafe(method_family = none)]
3854        pub fn location(&self) -> Option<Retained<XCTSourceCodeLocation>>;
3855    );
3856}
3857
3858/// Methods declared on superclass `NSObject`.
3859impl XCTSourceCodeContext {
3860    extern_methods!(
3861        #[unsafe(method(new))]
3862        #[unsafe(method_family = new)]
3863        pub fn new() -> Retained<Self>;
3864    );
3865}
3866
3867impl DefaultRetained for XCTSourceCodeContext {
3868    #[inline]
3869    fn default_retained() -> Retained<Self> {
3870        Self::new()
3871    }
3872}
3873
3874/// Values returned by a waiter when it completes, times out, or is interrupted due to another waiter
3875/// higher in the call stack timing out.
3876///
3877/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctwaiterresult?language=objc)
3878// NS_ENUM
3879#[repr(transparent)]
3880#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
3881pub struct XCTWaiterResult(pub NSInteger);
3882impl XCTWaiterResult {
3883    #[doc(alias = "XCTWaiterResultCompleted")]
3884    pub const Completed: Self = Self(1);
3885    #[doc(alias = "XCTWaiterResultTimedOut")]
3886    pub const TimedOut: Self = Self(2);
3887    #[doc(alias = "XCTWaiterResultIncorrectOrder")]
3888    pub const IncorrectOrder: Self = Self(3);
3889    #[doc(alias = "XCTWaiterResultInvertedFulfillment")]
3890    pub const InvertedFulfillment: Self = Self(4);
3891    #[doc(alias = "XCTWaiterResultInterrupted")]
3892    pub const Interrupted: Self = Self(5);
3893}
3894
3895unsafe impl Encode for XCTWaiterResult {
3896    const ENCODING: Encoding = NSInteger::ENCODING;
3897}
3898
3899unsafe impl RefEncode for XCTWaiterResult {
3900    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3901}
3902
3903extern_class!(
3904    /// Manages waiting - pausing the current execution context - for an array of XCTestExpectations. Waiters
3905    /// can be used with or without a delegate to respond to events such as completion, timeout, or invalid
3906    /// expectation fulfillment. XCTestCase conforms to the delegate protocol and will automatically report
3907    /// timeouts and other unexpected events as test failures.
3908    ///
3909    /// Waiters can be used without a delegate or any association with a test case instance. This allows test
3910    /// support libraries to provide convenience methods for waiting without having to pass test cases through
3911    /// those APIs.
3912    ///
3913    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctwaiter?language=objc)
3914    #[unsafe(super(NSObject))]
3915    #[derive(Debug, PartialEq, Eq, Hash)]
3916    pub struct XCTWaiter;
3917);
3918
3919unsafe impl Send for XCTWaiter {}
3920
3921unsafe impl Sync for XCTWaiter {}
3922
3923extern_conformance!(
3924    unsafe impl NSObjectProtocol for XCTWaiter {}
3925);
3926
3927impl XCTWaiter {
3928    extern_methods!(
3929        /// Creates a new waiter with the specified delegate.
3930        #[unsafe(method(initWithDelegate:))]
3931        #[unsafe(method_family = init)]
3932        pub fn initWithDelegate(
3933            this: Allocated<Self>,
3934            delegate: Option<&ProtocolObject<dyn XCTWaiterDelegate>>,
3935        ) -> Retained<Self>;
3936
3937        /// The waiter delegate will be called with various events described in
3938        /// <XCTWaiterDelegate
3939        /// >.
3940        #[unsafe(method(delegate))]
3941        #[unsafe(method_family = none)]
3942        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn XCTWaiterDelegate>>>;
3943
3944        /// Setter for [`delegate`][Self::delegate].
3945        ///
3946        /// This is a [weak property][objc2::topics::weak_property].
3947        #[unsafe(method(setDelegate:))]
3948        #[unsafe(method_family = none)]
3949        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn XCTWaiterDelegate>>);
3950
3951        /// Returns an array containing the expectations that were fulfilled, in that order, up until the waiter
3952        /// stopped waiting. Expectations fulfilled after the waiter stopped waiting will not be in the array.
3953        /// The array will be empty until the waiter has started waiting, even if expectations have already been
3954        /// fulfilled. If a waiter is used to wait multiple times, this array will contain all of the
3955        /// fulfilled expectations from each wait operation.
3956        #[unsafe(method(fulfilledExpectations))]
3957        #[unsafe(method_family = none)]
3958        pub fn fulfilledExpectations(&self) -> Retained<NSArray<XCTestExpectation>>;
3959
3960        /// Waits on a group of expectations indefinitely.
3961        ///
3962        ///
3963        /// Parameter `expectations`: An array of expectations that must be fulfilled.
3964        ///
3965        ///
3966        /// The test will continue to run until
3967        /// _expectations_are fulfilled or the
3968        /// test reaches its execution time allowance.
3969        ///
3970        /// Expectations can only appear in the list once. This method may return
3971        /// early based on fulfillment of the provided expectations.
3972        ///
3973        /// Enabling test timeouts is recommended when using this method to prevent a
3974        /// runaway expectation from hanging the test.
3975        ///
3976        ///
3977        /// Returns: A value describing the outcome of waiting for
3978        /// _expectations._
3979        #[unsafe(method(waitForExpectations:))]
3980        #[unsafe(method_family = none)]
3981        pub fn waitForExpectations(
3982            &self,
3983            expectations: &NSArray<XCTestExpectation>,
3984        ) -> XCTWaiterResult;
3985
3986        /// Waits on a group of expectations for up to the specified timeout.
3987        ///
3988        ///
3989        /// Parameter `expectations`: An array of expectations that must be fulfilled.
3990        ///
3991        ///
3992        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
3993        ///
3994        ///
3995        /// Expectations can only appear in the list once. This method may return
3996        /// early based on fulfillment of the provided expectations.
3997        ///
3998        ///
3999        /// Returns: A value describing the outcome of waiting for
4000        /// _expectations._
4001        #[unsafe(method(waitForExpectations:timeout:))]
4002        #[unsafe(method_family = none)]
4003        pub fn waitForExpectations_timeout(
4004            &self,
4005            expectations: &NSArray<XCTestExpectation>,
4006            seconds: NSTimeInterval,
4007        ) -> XCTWaiterResult;
4008
4009        /// Waits on a group of expectations indefinitely, optionally enforcing their
4010        /// order of fulfillment.
4011        ///
4012        ///
4013        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4014        ///
4015        ///
4016        /// Parameter `enforceOrderOfFulfillment`: If
4017        /// `YES,`the expectations specified by the
4018        /// _expectations_parameter must
4019        /// be satisfied in the order they appear in the array.
4020        ///
4021        ///
4022        /// The test will continue to run until
4023        /// _expectations_are fulfilled or the
4024        /// test reaches its execution time allowance.
4025        ///
4026        /// Expectations can only appear in the list once. This method may return
4027        /// early based on fulfillment of the provided expectations.
4028        ///
4029        /// Enabling test timeouts is recommended when using this method to prevent a
4030        /// runaway expectation from hanging the test.
4031        ///
4032        ///
4033        /// Returns: A value describing the outcome of waiting for
4034        /// _expectations._
4035        #[unsafe(method(waitForExpectations:enforceOrder:))]
4036        #[unsafe(method_family = none)]
4037        pub fn waitForExpectations_enforceOrder(
4038            &self,
4039            expectations: &NSArray<XCTestExpectation>,
4040            enforce_order_of_fulfillment: bool,
4041        ) -> XCTWaiterResult;
4042
4043        /// Waits on a group of expectations for up to the specified timeout, optionally
4044        /// enforcing their order of fulfillment.
4045        ///
4046        ///
4047        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4048        ///
4049        ///
4050        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
4051        ///
4052        ///
4053        /// Parameter `enforceOrderOfFulfillment`: If
4054        /// `YES,`the expectations specified by the
4055        /// _expectations_parameter must
4056        /// be satisfied in the order they appear in the array.
4057        ///
4058        ///
4059        /// Expectations can only appear in the list once. This method may return
4060        /// early based on fulfillment of the provided expectations.
4061        ///
4062        ///
4063        /// Returns: A value describing the outcome of waiting for
4064        /// _expectations._
4065        #[unsafe(method(waitForExpectations:timeout:enforceOrder:))]
4066        #[unsafe(method_family = none)]
4067        pub fn waitForExpectations_timeout_enforceOrder(
4068            &self,
4069            expectations: &NSArray<XCTestExpectation>,
4070            seconds: NSTimeInterval,
4071            enforce_order_of_fulfillment: bool,
4072        ) -> XCTWaiterResult;
4073
4074        /// Creates a waiter that waits on a group of expectations indefinitely.
4075        ///
4076        ///
4077        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4078        ///
4079        ///
4080        /// The test will continue to run until
4081        /// _expectations_are fulfilled or the
4082        /// test reaches its execution time allowance.
4083        ///
4084        /// Expectations can only appear in the list once. This method may return
4085        /// early based on fulfillment of the provided expectations.
4086        ///
4087        /// Enabling test timeouts is recommended when using this method to prevent a
4088        /// runaway expectation from hanging the test.
4089        ///
4090        /// The waiter is discarded when the wait completes.
4091        ///
4092        ///
4093        /// Returns: A value describing the outcome of waiting for
4094        /// _expectations._
4095        #[must_use]
4096        #[unsafe(method(waitForExpectations:))]
4097        #[unsafe(method_family = none)]
4098        pub fn waitForExpectations_class(
4099            expectations: &NSArray<XCTestExpectation>,
4100        ) -> XCTWaiterResult;
4101
4102        /// Creates a waiter that waits on a group of expectations for up to the
4103        /// specified timeout.
4104        ///
4105        ///
4106        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4107        ///
4108        ///
4109        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
4110        ///
4111        ///
4112        /// Expectations can only appear in the list once. This method may return
4113        /// early based on fulfillment of the provided expectations.
4114        ///
4115        /// The waiter is discarded when the wait completes.
4116        ///
4117        ///
4118        /// Returns: A value describing the outcome of waiting for
4119        /// _expectations._
4120        #[must_use]
4121        #[unsafe(method(waitForExpectations:timeout:))]
4122        #[unsafe(method_family = none)]
4123        pub fn waitForExpectations_timeout_class(
4124            expectations: &NSArray<XCTestExpectation>,
4125            seconds: NSTimeInterval,
4126        ) -> XCTWaiterResult;
4127
4128        /// Creates a waiter that waits on a group of expectations indefinitely,
4129        /// optionally enforcing their order of fulfillment.
4130        ///
4131        ///
4132        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4133        ///
4134        ///
4135        /// Parameter `enforceOrderOfFulfillment`: If
4136        /// `YES,`the expectations specified by the
4137        /// _expectations_parameter must
4138        /// be satisfied in the order they appear in the array.
4139        ///
4140        ///
4141        /// The test will continue to run until
4142        /// _expectations_are fulfilled or the
4143        /// test reaches its execution time allowance.
4144        ///
4145        /// Expectations can only appear in the list once. This method may return
4146        /// early based on fulfillment of the provided expectations.
4147        ///
4148        /// Enabling test timeouts is recommended when using this method to prevent a
4149        /// runaway expectation from hanging the test.
4150        ///
4151        /// The waiter is discarded when the wait completes.
4152        ///
4153        ///
4154        /// Returns: A value describing the outcome of waiting for
4155        /// _expectations._
4156        #[must_use]
4157        #[unsafe(method(waitForExpectations:enforceOrder:))]
4158        #[unsafe(method_family = none)]
4159        pub fn waitForExpectations_enforceOrder_class(
4160            expectations: &NSArray<XCTestExpectation>,
4161            enforce_order_of_fulfillment: bool,
4162        ) -> XCTWaiterResult;
4163
4164        /// Creates a waiter that waits on a group of expectations for up to the
4165        /// specified timeout, optionally enforcing their order of fulfillment.
4166        ///
4167        ///
4168        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4169        ///
4170        ///
4171        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
4172        ///
4173        ///
4174        /// Parameter `enforceOrderOfFulfillment`: If
4175        /// `YES,`the expectations specified by the
4176        /// _expectations_parameter must
4177        /// be satisfied in the order they appear in the array.
4178        ///
4179        ///
4180        /// Expectations can only appear in the list once. This method may return
4181        /// early based on fulfillment of the provided expectations.
4182        ///
4183        /// The waiter is discarded when the wait completes.
4184        ///
4185        ///
4186        /// Returns: A value describing the outcome of waiting for
4187        /// _expectations._
4188        #[must_use]
4189        #[unsafe(method(waitForExpectations:timeout:enforceOrder:))]
4190        #[unsafe(method_family = none)]
4191        pub fn waitForExpectations_timeout_enforceOrder_class(
4192            expectations: &NSArray<XCTestExpectation>,
4193            seconds: NSTimeInterval,
4194            enforce_order_of_fulfillment: bool,
4195        ) -> XCTWaiterResult;
4196    );
4197}
4198
4199/// Methods declared on superclass `NSObject`.
4200impl XCTWaiter {
4201    extern_methods!(
4202        #[unsafe(method(init))]
4203        #[unsafe(method_family = init)]
4204        pub fn init(this: Allocated<Self>) -> Retained<Self>;
4205
4206        #[unsafe(method(new))]
4207        #[unsafe(method_family = new)]
4208        pub fn new() -> Retained<Self>;
4209    );
4210}
4211
4212impl DefaultRetained for XCTWaiter {
4213    #[inline]
4214    fn default_retained() -> Retained<Self> {
4215        Self::new()
4216    }
4217}
4218
4219extern_protocol!(
4220    /// Events are reported to the waiter's delegate via these methods. XCTestCase conforms to the delegate
4221    /// protocol and will automatically report timeouts and other unexpected events as test failures.
4222    ///
4223    ///
4224    /// Note: These methods are invoked on an arbitrary queue.
4225    ///
4226    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctwaiterdelegate?language=objc)
4227    pub unsafe trait XCTWaiterDelegate: NSObjectProtocol {
4228        /// Invoked when not all waited on expectations are fulfilled during the timeout period. If the delegate
4229        /// is an XCTestCase instance, this will be reported as a test failure.
4230        #[optional]
4231        #[unsafe(method(waiter:didTimeoutWithUnfulfilledExpectations:))]
4232        #[unsafe(method_family = none)]
4233        fn waiter_didTimeoutWithUnfulfilledExpectations(
4234            &self,
4235            waiter: &XCTWaiter,
4236            unfulfilled_expectations: &NSArray<XCTestExpectation>,
4237        );
4238
4239        /// Invoked when the -wait call has specified that fulfillment order should be enforced and an expectation
4240        /// has been fulfilled in the wrong order. If the delegate is an XCTestCase instance, this will be reported
4241        /// as a test failure.
4242        #[optional]
4243        #[unsafe(method(waiter:fulfillmentDidViolateOrderingConstraintsForExpectation:requiredExpectation:))]
4244        #[unsafe(method_family = none)]
4245        fn waiter_fulfillmentDidViolateOrderingConstraintsForExpectation_requiredExpectation(
4246            &self,
4247            waiter: &XCTWaiter,
4248            expectation: &XCTestExpectation,
4249            required_expectation: &XCTestExpectation,
4250        );
4251
4252        /// Invoked when an expectation marked as inverted (/see inverted) is fulfilled. If the delegate is an
4253        /// XCTestCase instance, this will be reported as a test failure.
4254        #[optional]
4255        #[unsafe(method(waiter:didFulfillInvertedExpectation:))]
4256        #[unsafe(method_family = none)]
4257        fn waiter_didFulfillInvertedExpectation(
4258            &self,
4259            waiter: &XCTWaiter,
4260            expectation: &XCTestExpectation,
4261        );
4262
4263        /// Invoked when the waiter is interrupted prior to its expectations being fulfilled or timing out.
4264        /// This occurs when an "outer" waiter times out, resulting in any waiters nested inside it being
4265        /// interrupted to allow the call stack to quickly unwind.
4266        #[optional]
4267        #[unsafe(method(nestedWaiter:wasInterruptedByTimedOutWaiter:))]
4268        #[unsafe(method_family = none)]
4269        fn nestedWaiter_wasInterruptedByTimedOutWaiter(
4270            &self,
4271            waiter: &XCTWaiter,
4272            outer_waiter: &XCTWaiter,
4273        );
4274    }
4275);
4276
4277extern_class!(
4278    /// Expectations represent specific conditions in asynchronous testing.
4279    ///
4280    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctestexpectation?language=objc)
4281    #[unsafe(super(NSObject))]
4282    #[derive(Debug, PartialEq, Eq, Hash)]
4283    pub struct XCTestExpectation;
4284);
4285
4286unsafe impl Send for XCTestExpectation {}
4287
4288unsafe impl Sync for XCTestExpectation {}
4289
4290extern_conformance!(
4291    unsafe impl NSObjectProtocol for XCTestExpectation {}
4292);
4293
4294impl XCTestExpectation {
4295    extern_methods!(
4296        /// Designated initializer, requires a nonnull description of the condition the expectation is checking.
4297        #[unsafe(method(initWithDescription:))]
4298        #[unsafe(method_family = init)]
4299        pub fn initWithDescription(
4300            this: Allocated<Self>,
4301            expectation_description: &NSString,
4302        ) -> Retained<Self>;
4303
4304        /// The human readable string used to describe the expectation in log output and test reports.
4305        #[unsafe(method(expectationDescription))]
4306        #[unsafe(method_family = none)]
4307        pub fn expectationDescription(&self) -> Retained<NSString>;
4308
4309        /// Setter for [`expectationDescription`][Self::expectationDescription].
4310        ///
4311        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4312        #[unsafe(method(setExpectationDescription:))]
4313        #[unsafe(method_family = none)]
4314        pub fn setExpectationDescription(&self, expectation_description: &NSString);
4315
4316        /// If an expectation is set to have inverted behavior, then fulfilling it will have a similar effect that
4317        /// failing to fulfill a conventional expectation has, as handled by the waiter and its delegate. Furthermore,
4318        /// waiters that wait on an inverted expectation will allow the full timeout to elapse and not report
4319        /// timeout to the delegate if it is not fulfilled.
4320        #[unsafe(method(isInverted))]
4321        #[unsafe(method_family = none)]
4322        pub fn isInverted(&self) -> bool;
4323
4324        /// Setter for [`isInverted`][Self::isInverted].
4325        #[unsafe(method(setInverted:))]
4326        #[unsafe(method_family = none)]
4327        pub fn setInverted(&self, inverted: bool);
4328
4329        /// The expectedFulfillmentCount is the number of times -fulfill must be called on the expectation in order for it
4330        /// to report complete fulfillment to its waiter. By default, expectations have an expectedFufillmentCount of 1.
4331        /// This value must be greater than 0 and is not meaningful if combined with
4332        /// @
4333        /// inverted.
4334        ///
4335        /// This property is not atomic.
4336        ///
4337        /// # Safety
4338        ///
4339        /// This might not be thread-safe.
4340        #[unsafe(method(expectedFulfillmentCount))]
4341        #[unsafe(method_family = none)]
4342        pub unsafe fn expectedFulfillmentCount(&self) -> NSUInteger;
4343
4344        /// Setter for [`expectedFulfillmentCount`][Self::expectedFulfillmentCount].
4345        ///
4346        /// # Safety
4347        ///
4348        /// This might not be thread-safe.
4349        #[unsafe(method(setExpectedFulfillmentCount:))]
4350        #[unsafe(method_family = none)]
4351        pub unsafe fn setExpectedFulfillmentCount(&self, expected_fulfillment_count: NSUInteger);
4352
4353        /// If set, calls to fulfill() after the expectation has already been fulfilled - exceeding the fulfillment
4354        /// count - will raise. This is the legacy behavior of expectations created through APIs on XCTestCase
4355        /// but is not enabled for expectations created using XCTestExpectation initializers.
4356        ///
4357        /// This property is not atomic.
4358        ///
4359        /// # Safety
4360        ///
4361        /// This might not be thread-safe.
4362        #[unsafe(method(assertForOverFulfill))]
4363        #[unsafe(method_family = none)]
4364        pub unsafe fn assertForOverFulfill(&self) -> bool;
4365
4366        /// Setter for [`assertForOverFulfill`][Self::assertForOverFulfill].
4367        ///
4368        /// # Safety
4369        ///
4370        /// This might not be thread-safe.
4371        #[unsafe(method(setAssertForOverFulfill:))]
4372        #[unsafe(method_family = none)]
4373        pub unsafe fn setAssertForOverFulfill(&self, assert_for_over_fulfill: bool);
4374
4375        /// Call -fulfill to mark an expectation as having been met. It's an error to call -fulfill on an
4376        /// expectation more times than its `expectedFulfillmentCount` value specifies, or when the test case
4377        /// that vended the expectation has already completed. If `assertForOverFulfill` is set when either
4378        /// of these occur, -fulfill will raise an exception.
4379        #[unsafe(method(fulfill))]
4380        #[unsafe(method_family = none)]
4381        pub fn fulfill(&self);
4382    );
4383}
4384
4385/// Methods declared on superclass `NSObject`.
4386impl XCTestExpectation {
4387    extern_methods!(
4388        #[unsafe(method(init))]
4389        #[unsafe(method_family = init)]
4390        pub fn init(this: Allocated<Self>) -> Retained<Self>;
4391
4392        #[unsafe(method(new))]
4393        #[unsafe(method_family = new)]
4394        pub fn new() -> Retained<Self>;
4395    );
4396}
4397
4398impl DefaultRetained for XCTestExpectation {
4399    #[inline]
4400    fn default_retained() -> Retained<Self> {
4401        Self::new()
4402    }
4403}
4404
4405/// A block to be invoked when a change is observed for the keyPath of the observed object.
4406///
4407///
4408/// Parameter `observedObject`: The observed object, provided to avoid block capture issues.
4409///
4410///
4411/// Parameter `change`: The KVO change dictionary.
4412///
4413///
4414/// Returns: Return YES if the expectation is fulfilled, NO if it is not.
4415///
4416/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xckeyvalueobservingexpectationhandler?language=objc)
4417#[cfg(feature = "block2")]
4418pub type XCKeyValueObservingExpectationHandler =
4419    *mut block2::DynBlock<dyn Fn(NonNull<AnyObject>, NonNull<NSDictionary>) -> Bool>;
4420
4421extern_class!(
4422    /// Expectation subclass for waiting on a condition defined Key Value Observation of a key path for an object.
4423    ///
4424    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctkvoexpectation?language=objc)
4425    #[unsafe(super(XCTestExpectation, NSObject))]
4426    #[derive(Debug, PartialEq, Eq, Hash)]
4427    pub struct XCTKVOExpectation;
4428);
4429
4430extern_conformance!(
4431    unsafe impl NSObjectProtocol for XCTKVOExpectation {}
4432);
4433
4434impl XCTKVOExpectation {
4435    extern_methods!(
4436        #[unsafe(method(new))]
4437        #[unsafe(method_family = new)]
4438        pub unsafe fn new() -> Retained<Self>;
4439
4440        #[unsafe(method(init))]
4441        #[unsafe(method_family = init)]
4442        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4443
4444        #[unsafe(method(initWithDescription:))]
4445        #[unsafe(method_family = init)]
4446        pub unsafe fn initWithDescription(
4447            this: Allocated<Self>,
4448            expectation_description: &NSString,
4449        ) -> Retained<Self>;
4450
4451        /// Initializes an expectation that is fulfilled when a key value coding compliant change is made such
4452        /// that the specified key path of the observed object has the expected value.
4453        ///
4454        /// # Safety
4455        ///
4456        /// - `object` should be of the correct type.
4457        /// - `expected_value` should be of the correct type.
4458        #[unsafe(method(initWithKeyPath:object:expectedValue:options:))]
4459        #[unsafe(method_family = init)]
4460        pub unsafe fn initWithKeyPath_object_expectedValue_options(
4461            this: Allocated<Self>,
4462            key_path: &NSString,
4463            object: &AnyObject,
4464            expected_value: Option<&AnyObject>,
4465            options: NSKeyValueObservingOptions,
4466        ) -> Retained<Self>;
4467
4468        /// Initializes an expectation that is fulfilled when a key value coding compliant change is made such
4469        /// that the specified key path of the observed object has the expected value. The NSKeyValueObservingOptions
4470        /// passed for this initializer include NSKeyValueObservingOptionInitial, so the object/key path will be
4471        /// checked immediately. The options also include NSKeyValueObservingOptionNew and NSKeyValueObservingOptionOld,
4472        /// so if a handler is used the change dictionary passed to it will contain NSKeyValueChangeNewKey and
4473        /// NSKeyValueChangeOldKey entries.
4474        ///
4475        /// # Safety
4476        ///
4477        /// - `object` should be of the correct type.
4478        /// - `expected_value` should be of the correct type.
4479        #[unsafe(method(initWithKeyPath:object:expectedValue:))]
4480        #[unsafe(method_family = init)]
4481        pub unsafe fn initWithKeyPath_object_expectedValue(
4482            this: Allocated<Self>,
4483            key_path: &NSString,
4484            object: &AnyObject,
4485            expected_value: Option<&AnyObject>,
4486        ) -> Retained<Self>;
4487
4488        /// Convenience initializer that is fulfilled by any change to the specified key path of the observed object.
4489        /// The NSKeyValueObservingOptions passed for this initializer do not include NSKeyValueObservingOptionInitial
4490        /// since there is no value to check. If that behavior is desired in conjunction with a handler, use the
4491        /// designated initializer. The options do include NSKeyValueObservingOptionNew and NSKeyValueObservingOptionOld,
4492        /// so if a handler is used the change dictionary passed to it will contain NSKeyValueChangeNewKey and
4493        /// NSKeyValueChangeOldKey entries.
4494        ///
4495        /// # Safety
4496        ///
4497        /// `object` should be of the correct type.
4498        #[unsafe(method(initWithKeyPath:object:))]
4499        #[unsafe(method_family = init)]
4500        pub unsafe fn initWithKeyPath_object(
4501            this: Allocated<Self>,
4502            key_path: &NSString,
4503            object: &AnyObject,
4504        ) -> Retained<Self>;
4505
4506        /// Returns the key path that is being monitored for the KVO change.
4507        #[unsafe(method(keyPath))]
4508        #[unsafe(method_family = none)]
4509        pub fn keyPath(&self) -> Retained<NSString>;
4510
4511        /// Returns the object that is being monitored for the KVO change.
4512        #[unsafe(method(observedObject))]
4513        #[unsafe(method_family = none)]
4514        pub fn observedObject(&self) -> Retained<AnyObject>;
4515
4516        /// Returns the value that the expectation is waiting for the observed object/key path to have.
4517        #[unsafe(method(expectedValue))]
4518        #[unsafe(method_family = none)]
4519        pub fn expectedValue(&self) -> Option<Retained<AnyObject>>;
4520
4521        /// The KVO options used when the expectation registered for observation.
4522        #[unsafe(method(options))]
4523        #[unsafe(method_family = none)]
4524        pub fn options(&self) -> NSKeyValueObservingOptions;
4525
4526        #[cfg(feature = "block2")]
4527        /// Allows the caller to install a special handler to do custom evaluation of the change to the value
4528        /// of the object/key path. If a handler is set, expectedValue will be ignored.
4529        ///
4530        /// # Safety
4531        ///
4532        /// The returned block must be sendable.
4533        #[unsafe(method(handler))]
4534        #[unsafe(method_family = none)]
4535        pub unsafe fn handler(&self) -> XCKeyValueObservingExpectationHandler;
4536
4537        #[cfg(feature = "block2")]
4538        /// Setter for [`handler`][Self::handler].
4539        ///
4540        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4541        ///
4542        /// # Safety
4543        ///
4544        /// `handler` must be a valid pointer or null.
4545        #[unsafe(method(setHandler:))]
4546        #[unsafe(method_family = none)]
4547        pub unsafe fn setHandler(&self, handler: XCKeyValueObservingExpectationHandler);
4548    );
4549}
4550
4551/// A block to be invoked when a notification matching the specified name is observed
4552/// from the object.
4553///
4554///
4555/// Parameter `notification`: The notification object.
4556///
4557///
4558/// Returns: Return YES if the expectation is fulfilled, NO if it is not.
4559///
4560/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xcnotificationexpectationhandler?language=objc)
4561#[cfg(feature = "block2")]
4562pub type XCNotificationExpectationHandler =
4563    *mut block2::DynBlock<dyn Fn(NonNull<NSNotification>) -> Bool>;
4564
4565extern_class!(
4566    /// Expectation subclass for waiting on a condition defined by an NSNotification.
4567    ///
4568    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctnsnotificationexpectation?language=objc)
4569    #[unsafe(super(XCTestExpectation, NSObject))]
4570    #[derive(Debug, PartialEq, Eq, Hash)]
4571    pub struct XCTNSNotificationExpectation;
4572);
4573
4574extern_conformance!(
4575    unsafe impl NSObjectProtocol for XCTNSNotificationExpectation {}
4576);
4577
4578impl XCTNSNotificationExpectation {
4579    extern_methods!(
4580        #[unsafe(method(new))]
4581        #[unsafe(method_family = new)]
4582        pub unsafe fn new() -> Retained<Self>;
4583
4584        #[unsafe(method(init))]
4585        #[unsafe(method_family = init)]
4586        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4587
4588        #[unsafe(method(initWithDescription:))]
4589        #[unsafe(method_family = init)]
4590        pub unsafe fn initWithDescription(
4591            this: Allocated<Self>,
4592            expectation_description: &NSString,
4593        ) -> Retained<Self>;
4594
4595        /// Initializes an expectation that waits for an NSNotification to be posted by an optional object from
4596        /// a given notification center.
4597        ///
4598        /// # Safety
4599        ///
4600        /// `object` should be of the correct type.
4601        #[unsafe(method(initWithName:object:notificationCenter:))]
4602        #[unsafe(method_family = init)]
4603        pub unsafe fn initWithName_object_notificationCenter(
4604            this: Allocated<Self>,
4605            notification_name: &NSNotificationName,
4606            object: Option<&AnyObject>,
4607            notification_center: &NSNotificationCenter,
4608        ) -> Retained<Self>;
4609
4610        /// Initializes an expectation that waits for an NSNotification to be posted by an optional object from
4611        /// the default notification center.
4612        ///
4613        /// # Safety
4614        ///
4615        /// `object` should be of the correct type.
4616        #[unsafe(method(initWithName:object:))]
4617        #[unsafe(method_family = init)]
4618        pub unsafe fn initWithName_object(
4619            this: Allocated<Self>,
4620            notification_name: &NSNotificationName,
4621            object: Option<&AnyObject>,
4622        ) -> Retained<Self>;
4623
4624        /// Initializes an expectation that waits for an NSNotification to be posted by any object from
4625        /// the default notification center.
4626        #[unsafe(method(initWithName:))]
4627        #[unsafe(method_family = init)]
4628        pub fn initWithName(
4629            this: Allocated<Self>,
4630            notification_name: &NSNotificationName,
4631        ) -> Retained<Self>;
4632
4633        /// Returns the name of the notification being waited on.
4634        #[unsafe(method(notificationName))]
4635        #[unsafe(method_family = none)]
4636        pub fn notificationName(&self) -> Retained<NSNotificationName>;
4637
4638        /// Returns the object that will post the notification.
4639        #[unsafe(method(observedObject))]
4640        #[unsafe(method_family = none)]
4641        pub fn observedObject(&self) -> Option<Retained<AnyObject>>;
4642
4643        /// Returns the notification center that is being used.
4644        #[unsafe(method(notificationCenter))]
4645        #[unsafe(method_family = none)]
4646        pub fn notificationCenter(&self) -> Retained<NSNotificationCenter>;
4647
4648        #[cfg(feature = "block2")]
4649        /// Allows the caller to install a special handler to do custom evaluation of received notifications
4650        /// matching the specified object and notification center.
4651        ///
4652        /// # Safety
4653        ///
4654        /// The returned block must be sendable.
4655        #[unsafe(method(handler))]
4656        #[unsafe(method_family = none)]
4657        pub unsafe fn handler(&self) -> XCNotificationExpectationHandler;
4658
4659        #[cfg(feature = "block2")]
4660        /// Setter for [`handler`][Self::handler].
4661        ///
4662        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4663        ///
4664        /// # Safety
4665        ///
4666        /// `handler` must be a valid pointer or null.
4667        #[unsafe(method(setHandler:))]
4668        #[unsafe(method_family = none)]
4669        pub unsafe fn setHandler(&self, handler: XCNotificationExpectationHandler);
4670    );
4671}
4672
4673/// Handler called when evaluating the predicate against the object returns true. If the handler is not
4674/// provided the first successful evaluation will fulfill the expectation. If provided, the handler will
4675/// be queried each time the notification is received to determine whether the expectation should be fulfilled
4676/// or not.
4677///
4678/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xcpredicateexpectationhandler?language=objc)
4679#[cfg(feature = "block2")]
4680pub type XCPredicateExpectationHandler = *mut block2::DynBlock<dyn Fn() -> Bool>;
4681
4682extern_class!(
4683    /// Expectation subclass for waiting on a condition defined by an NSPredicate and an object.
4684    ///
4685    /// When an instance of this class is used from Swift and is awaited using
4686    /// `fulfillment(of:)`rather than
4687    /// `wait(for:),`XCTest evaluates the associated predicate on the main actor.
4688    ///
4689    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctnspredicateexpectation?language=objc)
4690    #[unsafe(super(XCTestExpectation, NSObject))]
4691    #[derive(Debug, PartialEq, Eq, Hash)]
4692    pub struct XCTNSPredicateExpectation;
4693);
4694
4695extern_conformance!(
4696    unsafe impl NSObjectProtocol for XCTNSPredicateExpectation {}
4697);
4698
4699impl XCTNSPredicateExpectation {
4700    extern_methods!(
4701        #[unsafe(method(new))]
4702        #[unsafe(method_family = new)]
4703        pub unsafe fn new() -> Retained<Self>;
4704
4705        #[unsafe(method(init))]
4706        #[unsafe(method_family = init)]
4707        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4708
4709        #[unsafe(method(initWithDescription:))]
4710        #[unsafe(method_family = init)]
4711        pub unsafe fn initWithDescription(
4712            this: Allocated<Self>,
4713            expectation_description: &NSString,
4714        ) -> Retained<Self>;
4715
4716        /// Initializes an expectation that waits for a predicate to evaluate as true with the provided object.
4717        ///
4718        /// When an instance of this class is used from Swift and is awaited using
4719        /// `fulfillment(of:)`rather than
4720        /// `wait(for:),`XCTest evaluates
4721        /// _predicate_on the main actor.
4722        ///
4723        /// # Safety
4724        ///
4725        /// `object` should be of the correct type.
4726        #[unsafe(method(initWithPredicate:object:))]
4727        #[unsafe(method_family = init)]
4728        pub unsafe fn initWithPredicate_object(
4729            this: Allocated<Self>,
4730            predicate: &NSPredicate,
4731            object: Option<&AnyObject>,
4732        ) -> Retained<Self>;
4733
4734        /// Returns the predicate used by the expectation.
4735        #[unsafe(method(predicate))]
4736        #[unsafe(method_family = none)]
4737        pub fn predicate(&self) -> Retained<NSPredicate>;
4738
4739        /// Returns the object against which the predicate is evaluated.
4740        #[unsafe(method(object))]
4741        #[unsafe(method_family = none)]
4742        pub fn object(&self) -> Option<Retained<AnyObject>>;
4743
4744        #[cfg(feature = "block2")]
4745        /// Allows the caller to install a special handler to do custom evaluation of predicate and its object.
4746        ///
4747        /// # Safety
4748        ///
4749        /// The returned block must be sendable.
4750        #[unsafe(method(handler))]
4751        #[unsafe(method_family = none)]
4752        pub unsafe fn handler(&self) -> XCPredicateExpectationHandler;
4753
4754        #[cfg(feature = "block2")]
4755        /// Setter for [`handler`][Self::handler].
4756        ///
4757        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4758        ///
4759        /// # Safety
4760        ///
4761        /// `handler` must be a valid pointer or null.
4762        #[unsafe(method(setHandler:))]
4763        #[unsafe(method_family = none)]
4764        pub unsafe fn setHandler(&self, handler: XCPredicateExpectationHandler);
4765
4766        /// Unavailable on this class; XCTNSPredicateExpectation repeatedly evaluates its predicate until it becomes
4767        /// true. Once the predicate has become true, it is expected to remain true and will not be evaluated again.
4768        /// Setting expectedFulfillmentCount has no impact on fulfillment of the expectation.
4769        ///
4770        /// This property is not atomic.
4771        ///
4772        /// # Safety
4773        ///
4774        /// This might not be thread-safe.
4775        #[unsafe(method(expectedFulfillmentCount))]
4776        #[unsafe(method_family = none)]
4777        pub unsafe fn expectedFulfillmentCount(&self) -> NSUInteger;
4778
4779        /// Setter for [`expectedFulfillmentCount`][Self::expectedFulfillmentCount].
4780        ///
4781        /// # Safety
4782        ///
4783        /// This might not be thread-safe.
4784        #[unsafe(method(setExpectedFulfillmentCount:))]
4785        #[unsafe(method_family = none)]
4786        pub unsafe fn setExpectedFulfillmentCount(&self, expected_fulfillment_count: NSUInteger);
4787    );
4788}
4789
4790/// A block to be invoked when a call to -waitForExpectationsWithTimeout:handler: times out or has
4791/// had all associated expectations fulfilled.
4792///
4793///
4794/// Parameter `error`: If the wait timed out or a failure was raised while waiting, the error's code
4795/// will specify the type of failure. Otherwise error will be nil.
4796///
4797/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xcwaitcompletionhandler?language=objc)
4798#[cfg(feature = "block2")]
4799pub type XCWaitCompletionHandler = *mut block2::DynBlock<dyn Fn(*mut NSError)>;
4800
4801/// AsynchronousTesting.
4802///
4803/// This category introduces support for asynchronous testing in XCTestCase. The mechanism
4804/// allows you to specify one or more "expectations" that will occur asynchronously
4805/// as a result of actions in the test. Once all expectations have been set, a "wait"
4806/// API is called that will block execution of subsequent test code until all expected
4807/// conditions have been fulfilled or a timeout occurs.
4808impl XCTestCase {
4809    extern_methods!(
4810        /// Parameter `description`: This string will be displayed in the test log to help diagnose failures.
4811        ///
4812        ///
4813        /// Creates and returns an expectation associated with the test case.
4814        #[must_use]
4815        #[unsafe(method(expectationWithDescription:))]
4816        #[unsafe(method_family = none)]
4817        pub fn expectationWithDescription(
4818            &self,
4819            description: &NSString,
4820        ) -> Retained<XCTestExpectation>;
4821
4822        #[cfg(feature = "block2")]
4823        /// Parameter `timeout`: The amount of time within which all expectations must be fulfilled.
4824        ///
4825        ///
4826        /// Parameter `handler`: If provided, the handler will be invoked both on timeout or fulfillment of all
4827        /// expectations. Timeout is always treated as a test failure.
4828        ///
4829        ///
4830        /// -waitForExpectationsWithTimeout:handler: creates a point of synchronization in the flow of a
4831        /// test. Only one -waitForExpectationsWithTimeout:handler: can be active at any given time, but
4832        /// multiple discrete sequences of { expectations -> wait } can be chained together.
4833        ///
4834        /// -waitForExpectationsWithTimeout:handler: runs the run loop while handling events until all expectations
4835        /// are fulfilled or the timeout is reached. Clients should not manipulate the run
4836        /// loop while using this API.
4837        ///
4838        /// # Safety
4839        ///
4840        /// `handler` must be a valid pointer or null.
4841        #[unsafe(method(waitForExpectationsWithTimeout:handler:))]
4842        #[unsafe(method_family = none)]
4843        pub unsafe fn waitForExpectationsWithTimeout_handler(
4844            &self,
4845            timeout: NSTimeInterval,
4846            handler: XCWaitCompletionHandler,
4847            mtm: MainThreadMarker,
4848        );
4849
4850        /// Waits on a group of expectations indefinitely.
4851        ///
4852        ///
4853        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4854        ///
4855        ///
4856        /// The test will continue to run until
4857        /// _expectations_are fulfilled or the
4858        /// test reaches its execution time allowance.
4859        ///
4860        /// Expectations can only appear in the list once. This method may return
4861        /// early based on fulfillment of the provided expectations.
4862        ///
4863        /// Enabling test timeouts is recommended when using this method to prevent a
4864        /// runaway expectation from hanging the test.
4865        #[unsafe(method(waitForExpectations:))]
4866        #[unsafe(method_family = none)]
4867        pub fn waitForExpectations(&self, expectations: &NSArray<XCTestExpectation>);
4868
4869        /// Waits on a group of expectations for up to the specified timeout.
4870        ///
4871        ///
4872        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4873        ///
4874        ///
4875        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
4876        ///
4877        ///
4878        /// Expectations can only appear in the list once. This method may return
4879        /// early based on fulfillment of the provided expectations.
4880        #[unsafe(method(waitForExpectations:timeout:))]
4881        #[unsafe(method_family = none)]
4882        pub fn waitForExpectations_timeout(
4883            &self,
4884            expectations: &NSArray<XCTestExpectation>,
4885            seconds: NSTimeInterval,
4886        );
4887
4888        /// Waits on a group of expectations indefinitely, optionally enforcing their
4889        /// order of fulfillment.
4890        ///
4891        ///
4892        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4893        ///
4894        ///
4895        /// Parameter `enforceOrderOfFulfillment`: If
4896        /// `YES,`the expectations specified by the
4897        /// _expectations_parameter must
4898        /// be satisfied in the order they appear in the array.
4899        ///
4900        ///
4901        /// The test will continue to run until
4902        /// _expectations_are fulfilled or the
4903        /// test reaches its execution time allowance.
4904        ///
4905        /// Expectations can only appear in the list once. This method may return
4906        /// early based on fulfillment of the provided expectations.
4907        ///
4908        /// Enabling test timeouts is recommended when using this method to prevent a
4909        /// runaway expectation from hanging the test.
4910        #[unsafe(method(waitForExpectations:enforceOrder:))]
4911        #[unsafe(method_family = none)]
4912        pub fn waitForExpectations_enforceOrder(
4913            &self,
4914            expectations: &NSArray<XCTestExpectation>,
4915            enforce_order_of_fulfillment: bool,
4916        );
4917
4918        /// Waits on a group of expectations for up to the specified timeout, optionally
4919        /// enforcing their order of fulfillment.
4920        ///
4921        ///
4922        /// Parameter `expectations`: An array of expectations that must be fulfilled.
4923        ///
4924        ///
4925        /// Parameter `seconds`: The number of seconds within which all expectations must be fulfilled.
4926        ///
4927        ///
4928        /// Parameter `enforceOrderOfFulfillment`: If
4929        /// `YES,`the expectations specified by the
4930        /// _expectations_parameter must
4931        /// be satisfied in the order they appear in the array.
4932        ///
4933        ///
4934        /// Expectations can only appear in the list once. This method may return
4935        /// early based on fulfillment of the provided expectations.
4936        #[unsafe(method(waitForExpectations:timeout:enforceOrder:))]
4937        #[unsafe(method_family = none)]
4938        pub fn waitForExpectations_timeout_enforceOrder(
4939            &self,
4940            expectations: &NSArray<XCTestExpectation>,
4941            seconds: NSTimeInterval,
4942            enforce_order_of_fulfillment: bool,
4943        );
4944
4945        /// A convenience method for asynchronous tests that use Key Value Observing to detect changes
4946        /// to values on an object. This variant takes an expected value and observes changes on the object
4947        /// until the keyPath's value matches the expected value using -[NSObject isEqual:]. If
4948        /// other comparisons are needed, use the variant below that takes a handler block.
4949        ///
4950        ///
4951        /// Parameter `objectToObserve`: The object to observe.
4952        ///
4953        ///
4954        /// Parameter `keyPath`: The key path to observe.
4955        ///
4956        ///
4957        /// Parameter `expectedValue`: Expected value of the keyPath for the object. The expectation will fulfill itself when the
4958        /// keyPath is equal, as tested using -[NSObject isEqual:]. If nil, the expectation will be
4959        /// fulfilled by the first change to the key path of the observed object.
4960        ///
4961        ///
4962        /// Returns: Creates and returns an expectation associated with the test case.
4963        ///
4964        /// # Safety
4965        ///
4966        /// - `object_to_observe` should be of the correct type.
4967        /// - `expected_value` should be of the correct type.
4968        #[unsafe(method(keyValueObservingExpectationForObject:keyPath:expectedValue:))]
4969        #[unsafe(method_family = none)]
4970        pub unsafe fn keyValueObservingExpectationForObject_keyPath_expectedValue(
4971            &self,
4972            object_to_observe: &AnyObject,
4973            key_path: &NSString,
4974            expected_value: Option<&AnyObject>,
4975        ) -> Retained<XCTestExpectation>;
4976
4977        #[cfg(feature = "block2")]
4978        /// Variant of the convenience for tests that use Key Value Observing. Takes a handler
4979        /// block instead of an expected value. Every KVO change will run the handler block until
4980        /// it returns YES (or the wait times out). Returning YES from the block will fulfill the
4981        /// expectation. XCTAssert and related APIs can be used in the block to report a failure.
4982        ///
4983        ///
4984        /// Parameter `objectToObserve`: The object to observe.
4985        ///
4986        ///
4987        /// Parameter `keyPath`: The key path to observe.
4988        ///
4989        ///
4990        /// Parameter `handler`: Optional handler, /see XCKeyValueObservingExpectationHandler. If not provided, the expectation will
4991        /// be fulfilled by the first change to the key path of the observed object.
4992        ///
4993        ///
4994        /// Returns: Creates and returns an expectation associated with the test case.
4995        ///
4996        /// # Safety
4997        ///
4998        /// - `object_to_observe` should be of the correct type.
4999        /// - `handler` must be a valid pointer or null.
5000        #[unsafe(method(keyValueObservingExpectationForObject:keyPath:handler:))]
5001        #[unsafe(method_family = none)]
5002        pub unsafe fn keyValueObservingExpectationForObject_keyPath_handler(
5003            &self,
5004            object_to_observe: &AnyObject,
5005            key_path: &NSString,
5006            handler: XCKeyValueObservingExpectationHandler,
5007        ) -> Retained<XCTestExpectation>;
5008
5009        #[cfg(feature = "block2")]
5010        /// A convenience method for asynchronous tests that observe NSNotifications from the default
5011        /// NSNotificationCenter.
5012        ///
5013        ///
5014        /// Parameter `notificationName`: The notification to register for.
5015        ///
5016        ///
5017        /// Parameter `objectToObserve`: The object to observe.
5018        ///
5019        ///
5020        /// Parameter `handler`: Optional handler, /see XCNotificationExpectationHandler. If not provided, the expectation
5021        /// will be fulfilled by the first notification matching the specified name from the
5022        /// observed object.
5023        ///
5024        ///
5025        /// Returns: Creates and returns an expectation associated with the test case.
5026        ///
5027        /// # Safety
5028        ///
5029        /// - `object_to_observe` should be of the correct type.
5030        /// - `handler` must be a valid pointer or null.
5031        #[unsafe(method(expectationForNotification:object:handler:))]
5032        #[unsafe(method_family = none)]
5033        pub unsafe fn expectationForNotification_object_handler(
5034            &self,
5035            notification_name: &NSNotificationName,
5036            object_to_observe: Option<&AnyObject>,
5037            handler: XCNotificationExpectationHandler,
5038        ) -> Retained<XCTestExpectation>;
5039
5040        #[cfg(feature = "block2")]
5041        /// A convenience method for asynchronous tests that observe NSNotifications from a specific
5042        /// NSNotificationCenter.
5043        ///
5044        ///
5045        /// Parameter `notificationName`: The notification to register for.
5046        ///
5047        ///
5048        /// Parameter `objectToObserve`: The object to observe.
5049        ///
5050        ///
5051        /// Parameter `notificationCenter`: The notification center from which to observe the notification.
5052        ///
5053        ///
5054        /// Parameter `handler`: Optional handler, /see XCNotificationExpectationHandler. If not provided, the expectation
5055        /// will be fulfilled by the first notification matching the specified name from the
5056        /// observed object.
5057        ///
5058        ///
5059        /// Returns: Creates and returns an expectation associated with the test case.
5060        ///
5061        /// # Safety
5062        ///
5063        /// - `object_to_observe` should be of the correct type.
5064        /// - `handler` must be a valid pointer or null.
5065        #[unsafe(method(expectationForNotification:object:notificationCenter:handler:))]
5066        #[unsafe(method_family = none)]
5067        pub unsafe fn expectationForNotification_object_notificationCenter_handler(
5068            &self,
5069            notification_name: &NSNotificationName,
5070            object_to_observe: Option<&AnyObject>,
5071            notification_center: &NSNotificationCenter,
5072            handler: XCNotificationExpectationHandler,
5073        ) -> Retained<XCTestExpectation>;
5074
5075        #[cfg(feature = "block2")]
5076        /// Creates an expectation that is fulfilled if the predicate returns true when evaluated with the given
5077        /// object. The expectation periodically evaluates the predicate and also may use notifications or other
5078        /// events to optimistically re-evaluate.
5079        ///
5080        /// When the resulting expectation is used from Swift and is awaited using
5081        /// `fulfillment(of:)`rather
5082        /// than
5083        /// `wait(for:),`XCTest evaluates
5084        /// _predicate_on the main actor.
5085        ///
5086        /// # Safety
5087        ///
5088        /// - `object` should be of the correct type.
5089        /// - `handler` must be a valid pointer or null.
5090        #[unsafe(method(expectationForPredicate:evaluatedWithObject:handler:))]
5091        #[unsafe(method_family = none)]
5092        pub unsafe fn expectationForPredicate_evaluatedWithObject_handler(
5093            &self,
5094            predicate: &NSPredicate,
5095            object: Option<&AnyObject>,
5096            handler: XCPredicateExpectationHandler,
5097        ) -> Retained<XCTestExpectation>;
5098    );
5099}
5100
5101extern_conformance!(
5102    unsafe impl XCTWaiterDelegate for XCTestCase {}
5103);
5104
5105/// Handler called when the expectation has received the Darwin notification. If the handler is not
5106/// provided the first posting of the notification will fulfill the expectation. If provided, the handler
5107/// will be queried each time the notification is received to determine whether the expectation should
5108/// be fulfilled or not. This allows the caller to check Darwin state variables or perform other logic
5109/// beyond simply verifying that the notification has been posted.
5110///
5111/// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctdarwinnotificationexpectationhandler?language=objc)
5112#[cfg(feature = "block2")]
5113pub type XCTDarwinNotificationExpectationHandler = *mut block2::DynBlock<dyn Fn() -> Bool>;
5114
5115extern_class!(
5116    /// Expectation subclass for waiting on a condition defined by a Darwin notification. The notification
5117    /// which may be posted in the same process or by other processes. Be aware that Darwin notifications
5118    /// may be coalesced when posted in quick succession, so be careful especially when using the
5119    /// `expectedFulfillmentCount` property with this class.
5120    ///
5121    /// See also [Apple's documentation](https://developer.apple.com/documentation/xctest/xctdarwinnotificationexpectation?language=objc)
5122    #[unsafe(super(XCTestExpectation, NSObject))]
5123    #[derive(Debug, PartialEq, Eq, Hash)]
5124    pub struct XCTDarwinNotificationExpectation;
5125);
5126
5127extern_conformance!(
5128    unsafe impl NSObjectProtocol for XCTDarwinNotificationExpectation {}
5129);
5130
5131impl XCTDarwinNotificationExpectation {
5132    extern_methods!(
5133        #[unsafe(method(new))]
5134        #[unsafe(method_family = new)]
5135        pub unsafe fn new() -> Retained<Self>;
5136
5137        #[unsafe(method(init))]
5138        #[unsafe(method_family = init)]
5139        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5140
5141        #[unsafe(method(initWithDescription:))]
5142        #[unsafe(method_family = init)]
5143        pub unsafe fn initWithDescription(
5144            this: Allocated<Self>,
5145            expectation_description: &NSString,
5146        ) -> Retained<Self>;
5147
5148        /// Initializes an expectation that waits for a Darwin notification to be posted.
5149        #[unsafe(method(initWithNotificationName:))]
5150        #[unsafe(method_family = init)]
5151        pub fn initWithNotificationName(
5152            this: Allocated<Self>,
5153            notification_name: &NSString,
5154        ) -> Retained<Self>;
5155
5156        /// Returns the value of the notification name that was provided to the initializer.
5157        #[unsafe(method(notificationName))]
5158        #[unsafe(method_family = none)]
5159        pub fn notificationName(&self) -> Retained<NSString>;
5160
5161        #[cfg(feature = "block2")]
5162        /// Allows the caller to install a special handler to do custom evaluation when the notification is posted.
5163        ///
5164        /// # Safety
5165        ///
5166        /// The returned block must be sendable.
5167        #[unsafe(method(handler))]
5168        #[unsafe(method_family = none)]
5169        pub unsafe fn handler(&self) -> XCTDarwinNotificationExpectationHandler;
5170
5171        #[cfg(feature = "block2")]
5172        /// Setter for [`handler`][Self::handler].
5173        ///
5174        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5175        ///
5176        /// # Safety
5177        ///
5178        /// `handler` must be a valid pointer or null.
5179        #[unsafe(method(setHandler:))]
5180        #[unsafe(method_family = none)]
5181        pub unsafe fn setHandler(&self, handler: XCTDarwinNotificationExpectationHandler);
5182    );
5183}
5184
5185/// XCUIScreenshot_ConvenienceInitializers.
5186impl XCTAttachment {
5187    extern_methods!(
5188        #[cfg(feature = "objc2-xc-ui-automation")]
5189        /// Creates an attachment with a screenshot and the specified quality.
5190        #[unsafe(method(attachmentWithScreenshot:))]
5191        #[unsafe(method_family = none)]
5192        pub fn attachmentWithScreenshot(screenshot: &XCUIScreenshot) -> Retained<Self>;
5193
5194        #[cfg(feature = "objc2-xc-ui-automation")]
5195        /// Creates an attachment with a screenshot and the specified quality.
5196        #[unsafe(method(attachmentWithScreenshot:quality:))]
5197        #[unsafe(method_family = none)]
5198        pub fn attachmentWithScreenshot_quality(
5199            screenshot: &XCUIScreenshot,
5200            quality: XCTImageQuality,
5201        ) -> Retained<Self>;
5202    );
5203}
5204
5205/// XCUIApplication_LaunchTesting.
5206impl XCTestCase {
5207    extern_methods!(
5208        /// Determines whether the tests in this class should run multiple times, once for each of the target application's UI configurations.
5209        ///
5210        /// Returns false by default. If overridden in a UI test subclass to return true, each test in that
5211        /// class will run multiple times, once for each supported UI configuration of the default target application.
5212        ///
5213        /// Supported UI configurations are detected by Xcode according to the settings of the default target app
5214        /// for the UI test target and may include:
5215        ///
5216        /// - Appearances (e.g. light mode, dark mode)
5217        /// - Orientations (e.g. portrait, landscape)
5218        /// - Localizations (e.g. en_US, zh_CN)
5219        ///
5220        /// Given the above example, one UI configuration would be {dark mode, landscape, en_US}, another would be
5221        /// {light mode, portrait, zh_CN}, and so forth. The number of combinations determines the number of times each
5222        /// test will run. The UI configuration is used automatically when calling `XCUIApplication.launch()` in each test.
5223        #[unsafe(method(runsForEachTargetApplicationUIConfiguration))]
5224        #[unsafe(method_family = none)]
5225        pub fn runsForEachTargetApplicationUIConfiguration() -> bool;
5226    );
5227}
5228
5229/// XCUIInterruptionMonitoring.
5230impl XCTestCase {
5231    extern_methods!(
5232        #[cfg(all(feature = "block2", feature = "objc2-xc-ui-automation"))]
5233        /// Adds a monitor to the test. Monitors are automatically removed at the end of the test or can be manually removed using -removeUIInterruptionMonitor:.
5234        /// Monitors are invoked in the reverse order in which they are added until one of the monitors returns true, indicating that it has handled the interruption.
5235        ///
5236        ///
5237        /// Parameter `handlerDescription`: Explanation of the behavior and purpose of this monitor, mainly used for debugging and analysis.
5238        ///
5239        ///
5240        /// Parameter `handler`: Handler block for asynchronous, non-deterministic interrupting UI such as alerts and other dialogs. Handlers should return true if they handled the UI, false if they did not.
5241        /// The handler is passed an XCUIElement representing the top level UI element for the alert.
5242        ///
5243        ///
5244        /// Returns: Returns an opaque token that can be used to remove the monitor.
5245        ///
5246        ///
5247        /// A "UI interruption" is any element which unexpectedly blocks access to an element with which a UI test is trying to interact. Interrupting elements are most commonly alerts,
5248        /// dialogs, or other windows, but can be of other types as well. Interruptions are unexpected or at least not deterministic: the appearance of an alert in direct response to
5249        /// a test action such as clicking a button is not an interruption and should not be handled using a UI interruption monitor. Instead, it's simply part of the UI and should be
5250        /// found using standard queries and interacted with using standard event methods. Note that some interruptions are part of the app's own UI, others are presented on
5251        /// behalf of system apps and services, so queries for these elements must be constructed with the right process at their root.
5252        ///
5253        /// Use a UI interruption monitor for alerts that appear unexpectedly or with non-deterministic timing. Monitors are not invoked simply by the appearance of an alert or similar
5254        /// UI, they are called when the presence of such UI interferes with actions the test is attempting to take. For example, consider the following sequence:
5255        ///
5256        /// - test taps button
5257        /// - app displays confirmation dialog
5258        ///
5259        /// In this case, the dialog that is presented can be anticipated by the test, so a UI interruption monitor should not be used. Instead, the sequence should look like:
5260        ///
5261        /// - test taps button
5262        /// - test constructs an XCUIElement for the dialog and uses XCUIElement.waitForExistence(timeout:) to wait for it to appear
5263        /// - app displays confirmation dialog
5264        /// - test synthesizes a tap for the appropriate button in the dialog
5265        /// - test continues execution
5266        ///
5267        /// There was no UI interruption in this example because every step was deterministic and known in advance. Note the use of XCUIElement.waitForExistence(timeout:) to deal with
5268        /// asynchronous delays in the display of the dialog.
5269        ///
5270        /// By contrast, consider the next sequence, where use of a UI interruption monitor is the correct solution:
5271        ///
5272        /// - test launches app
5273        /// - app initiates asynchronous network request
5274        /// - test interacts with app
5275        /// - network request completes, app decides to display a dialog to the user
5276        /// - dialog appears just as the test is about to tap on a button
5277        /// - the appearance of the dialog is not deterministic
5278        /// - the test can anticipate that the dialog might be displayed at some point, but not when
5279        /// - accordingly, the test has installed a UI interruption monitor that knows how to handle the network response dialog
5280        /// - when XCTest computes a hit point for the button, it discovers the dialog and treats it as "interrupting UI"
5281        /// - the previously installed UI interruption monitor is invoked
5282        /// - it handles the dialog
5283        /// - XCTest computes the hit point for the button and synthesizes the requested tap event
5284        /// - test execution continues...
5285        ///
5286        /// Monitors can be designed to be general or specific in how they handle interruptions. The simplest general approach might simply attempt to cancel/dismiss/close
5287        /// any interrupting dialog/alert/window without consideration for its contents or purpose. A more specific monitor might make decisions based on the UI and contents
5288        /// of the interruption. Tests may install multiple monitors, which will be invoked in reverse order of installation. If a more specific monitor wishes to be skipped for a
5289        /// given interruption, its handler can simply return false - the next monitor will be invoked, and so on, until one of them returns true, signifying that it has handled
5290        /// the interruption. In some cases, a default monitor may handle interruptions.
5291        #[unsafe(method(addUIInterruptionMonitorWithDescription:handler:))]
5292        #[unsafe(method_family = none)]
5293        pub fn addUIInterruptionMonitorWithDescription_handler(
5294            &self,
5295            handler_description: &NSString,
5296            handler: &block2::DynBlock<dyn Fn(NonNull<XCUIElement>) -> Bool>,
5297        ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
5298
5299        /// Removes a monitor using the token provided when it was added.
5300        ///
5301        ///
5302        /// Parameter `monitor`: The token representing the monitor returned from the call to addUIInterruptionMonitorWithDescription:handler: where it was registered.
5303        ///
5304        /// # Safety
5305        ///
5306        /// `monitor` should be of the correct type.
5307        #[unsafe(method(removeUIInterruptionMonitor:))]
5308        #[unsafe(method_family = none)]
5309        pub unsafe fn removeUIInterruptionMonitor(
5310            &self,
5311            monitor: &ProtocolObject<dyn NSObjectProtocol>,
5312        );
5313    );
5314}
5315
5316/// UIAutomation.
5317impl XCTCPUMetric {
5318    extern_methods!(
5319        #[cfg(feature = "objc2-xc-ui-automation")]
5320        /// Creates a metric which will target the process described by the XCUIApplication instance.
5321        ///
5322        ///
5323        /// Parameter `application`: An instance of XCUIApplication which will be targeted to gather measurements.
5324        ///
5325        ///
5326        /// Returns: An initialized metric.
5327        #[unsafe(method(initWithApplication:))]
5328        #[unsafe(method_family = init)]
5329        pub fn initWithApplication(
5330            this: Allocated<Self>,
5331            application: &XCUIApplication,
5332        ) -> Retained<Self>;
5333    );
5334}
5335
5336/// UIAutomation.
5337impl XCTMemoryMetric {
5338    extern_methods!(
5339        #[cfg(feature = "objc2-xc-ui-automation")]
5340        /// Creates a metric which will target the process described by the XCUIApplication instance.
5341        ///
5342        ///
5343        /// Parameter `application`: An instance of XCUIApplication which will be targeted to gather measurements.
5344        ///
5345        ///
5346        /// Returns: An initialized metric.
5347        #[unsafe(method(initWithApplication:))]
5348        #[unsafe(method_family = init)]
5349        pub fn initWithApplication(
5350            this: Allocated<Self>,
5351            application: &XCUIApplication,
5352        ) -> Retained<Self>;
5353    );
5354}
5355
5356/// UIAutomation.
5357impl XCTStorageMetric {
5358    extern_methods!(
5359        #[cfg(feature = "objc2-xc-ui-automation")]
5360        /// Creates a metric which will target the process described by the XCUIApplication instance.
5361        ///
5362        ///
5363        /// Parameter `application`: An instance of XCUIApplication which will be targeted to gather measurements.
5364        ///
5365        ///
5366        /// Returns: An initialized metric.
5367        #[unsafe(method(initWithApplication:))]
5368        #[unsafe(method_family = init)]
5369        pub fn initWithApplication(
5370            this: Allocated<Self>,
5371            application: &XCUIApplication,
5372        ) -> Retained<Self>;
5373    );
5374}
5375
5376/// UIAutomation.
5377impl XCTHitchMetric {
5378    extern_methods!(
5379        #[cfg(feature = "objc2-xc-ui-automation")]
5380        /// Creates a metric which will target the process described by the XCUIApplication instance.
5381        ///
5382        ///
5383        /// Parameter `application`: An instance of XCUIApplication which will be targeted to gather measurements.
5384        ///
5385        ///
5386        /// Returns: An initialized metric.
5387        #[unsafe(method(initWithApplication:))]
5388        #[unsafe(method_family = init)]
5389        pub fn initWithApplication(
5390            this: Allocated<Self>,
5391            application: &XCUIApplication,
5392        ) -> Retained<Self>;
5393    );
5394}