|
23 | 23 | #import <Matter/Matter.h>
|
24 | 24 |
|
25 | 25 | #import "MTRErrorTestUtils.h"
|
| 26 | +#import "MTRTestCase+ServerAppRunner.h" |
| 27 | +#import "MTRTestCase.h" |
26 | 28 | #import "MTRTestKeys.h"
|
27 |
| -#import "MTRTestResetCommissioneeHelper.h" |
28 | 29 | #import "MTRTestStorage.h"
|
29 | 30 |
|
30 | 31 | #import <math.h> // For INFINITY
|
31 | 32 |
|
32 | 33 | // system dependencies
|
33 |
| -#import <XCTest/XCTest.h> |
34 | 34 | #import <os/lock.h>
|
35 | 35 |
|
36 | 36 | static uint16_t kTestVendorId = 0xFFF1u;
|
@@ -418,7 +418,8 @@ - (void)readAttributeCacheWithController:(id _Nullable)controller
|
418 | 418 | static const uint16_t kPairingTimeoutInSeconds = 30;
|
419 | 419 | static const uint16_t kTimeoutInSeconds = 3;
|
420 | 420 | static const uint64_t kDeviceId = 0x12344321;
|
421 |
| -static NSString * kOnboardingPayload = @"MT:-24J0AFN00KA0648G00"; |
| 421 | +static NSString * kOnboardingPayload = @"MT:Y.K90SO527JA0648G00"; |
| 422 | +static NSString * kSimpleLogContent = @"This is a simple log\n"; |
422 | 423 | static const uint16_t kLocalPort = 5541;
|
423 | 424 |
|
424 | 425 | // This test suite reuses a device object to speed up the test process for CI.
|
@@ -501,25 +502,38 @@ - (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDevice *)device
|
501 | 502 | }
|
502 | 503 | @end
|
503 | 504 |
|
504 |
| -@interface MTRXPCListenerSampleTests : XCTestCase |
| 505 | +@interface MTRXPCListenerSampleTests : MTRTestCase |
505 | 506 |
|
506 | 507 | @end
|
507 | 508 |
|
508 | 509 | static BOOL sStackInitRan = NO;
|
509 |
| -static BOOL sNeedsStackShutdown = YES; |
510 | 510 |
|
511 | 511 | @implementation MTRXPCListenerSampleTests
|
512 | 512 |
|
| 513 | ++ (void)setUp |
| 514 | +{ |
| 515 | + // Global setup, runs once. |
| 516 | + [super setUp]; |
| 517 | + |
| 518 | + __auto_type * uniqueName = [[NSUUID UUID] UUIDString]; |
| 519 | + __auto_type * uniquePath = [NSTemporaryDirectory() stringByAppendingPathComponent:uniqueName]; |
| 520 | + [[NSFileManager defaultManager] createFileAtPath:uniquePath |
| 521 | + contents:[kSimpleLogContent dataUsingEncoding:NSUTF8StringEncoding] |
| 522 | + attributes:nil]; |
| 523 | + BOOL started = [self startAppWithName:@"all-clusters" |
| 524 | + arguments:@[ |
| 525 | + @"--end_user_support_log", |
| 526 | + uniquePath, |
| 527 | + ] |
| 528 | + payload:kOnboardingPayload]; |
| 529 | + XCTAssertTrue(started); |
| 530 | +} |
| 531 | + |
513 | 532 | + (void)tearDown
|
514 | 533 | {
|
515 | 534 | // Global teardown, runs once
|
516 |
| - if (sNeedsStackShutdown) { |
517 |
| - // We don't need to worry about ResetCommissionee. If we get here, |
518 |
| - // we're running only one of our test methods (using |
519 |
| - // -only-testing:MatterTests/MTROTAProviderTests/testMethodName), since |
520 |
| - // we did not run test999_TearDown. |
521 |
| - // [self shutdownStack]; |
522 |
| - } |
| 535 | + [self shutdownStack]; |
| 536 | + [super tearDown]; |
523 | 537 | }
|
524 | 538 |
|
525 | 539 | - (void)setUp
|
@@ -591,8 +605,6 @@ - (void)initStack
|
591 | 605 |
|
592 | 606 | + (void)shutdownStack
|
593 | 607 | {
|
594 |
| - sNeedsStackShutdown = NO; |
595 |
| - |
596 | 608 | [mSampleListener stop];
|
597 | 609 | mSampleListener = nil;
|
598 | 610 |
|
@@ -1953,7 +1965,7 @@ - (void)test016_DownloadLog
|
1953 | 1965 | NSError * readError;
|
1954 | 1966 | NSString * fileContent = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&readError];
|
1955 | 1967 | XCTAssertNil(readError);
|
1956 |
| - XCTAssertEqualObjects(fileContent, @"This is a simple log\n"); |
| 1968 | + XCTAssertEqualObjects(fileContent, kSimpleLogContent); |
1957 | 1969 | [expectation fulfill];
|
1958 | 1970 | }];
|
1959 | 1971 | [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil];
|
@@ -2079,11 +2091,4 @@ - (void)test900_SubscribeClusterStateCache
|
2079 | 2091 | [self waitForExpectations:@[ expectation ] timeout:kTimeoutInSeconds];
|
2080 | 2092 | }
|
2081 | 2093 |
|
2082 |
| -- (void)test999_TearDown |
2083 |
| -{ |
2084 |
| - ResetCommissionee( |
2085 |
| - [MTRBaseDevice deviceWithNodeID:@(kDeviceId) controller:sController], dispatch_get_main_queue(), self, kTimeoutInSeconds); |
2086 |
| - [[self class] shutdownStack]; |
2087 |
| -} |
2088 |
| - |
2089 | 2094 | @end
|
0 commit comments