Skip to content

Commit da51f2b

Browse files
committed
test bootstrap: server protocol
1 parent 817ade3 commit da51f2b

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
/**
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#import <Matter/Matter.h>
19+
20+
NS_ASSUME_NONNULL_BEGIN
21+
22+
@protocol MTRDeviceXPCServerProtocol <NSObject>
23+
24+
25+
typedef void (^MTRDeviceXPCServerPingResult)(NSString *);
26+
typedef void (^MTRDeviceXPCServerAttributeReadResult)(NSDictionary<NSString *, id> * _Nullable);
27+
28+
- (void)pingWithResultHandler:(MTRDeviceXPCServerPingResult)resultHandler;
29+
30+
- (void)readAttributeWithEndpointID:(NSNumber *)endpointID
31+
clusterID:(NSNumber *)clusterID
32+
attributeID:(NSNumber *)attributeID
33+
params:(MTRReadParams * _Nullable)params
34+
resultHandler:(MTRDeviceXPCServerAttributeReadResult)resultHandler;
35+
36+
// TODO: more methods! kmo 26 jul 2924 10h28
37+
38+
@end
39+
40+
41+
@interface MTRDevice (XPC)
42+
43+
+ (NSXPCInterface *)xpcInterfaceForServerProtocol MTR_UNSTABLE_API;
44+
45+
@end
46+
47+
NS_ASSUME_NONNULL_END
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
/**
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#import <Foundation/Foundation.h>
19+
#import "MTRDevice+XPC.h"
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@implementation MTRDevice (XPC)
24+
25+
26+
+ (NSXPCInterface *)xpcInterfaceForServerProtocol {
27+
NSXPCInterface * xpcInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRDeviceXPCServerProtocol)];
28+
return xpcInterface;
29+
}
30+
31+
@end
32+
33+
NS_ASSUME_NONNULL_END

src/darwin/Framework/CHIPTests/MTRDeviceXPCTests.m

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
*/
1717

1818
#import <XCTest/XCTest.h>
19+
#import <Matter/Matter.h>
1920

2021
@interface MTRDeviceXPCTests : XCTestCase
21-
22+
@property (nonatomic, readonly, strong) NSXPCInterface * serviceInterface;
23+
@property (nonatomic, readonly, strong) NSXPCInterface * clientInterface;
24+
@property (nonatomic, readonly, strong) NSXPCListener * xpcListener;
2225
@end
2326

2427
@implementation MTRDeviceXPCTests
2528

29+
- (instancetype)init
30+
{
31+
_serviceInterface = [MTRDevice xpcInterfaceForServerProtocol];
32+
}
33+
2634
- (void)setUp {
2735
// Put setup code here. This method is called before the invocation of each test method in the class.
2836
}

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@
302302
99C65E10267282F1003402F6 /* MTRControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* MTRControllerTests.m */; };
303303
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D466E02798936D0089A18F /* MTRCommissioningParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
304304
9BD359B92C545F9E00CCFE4D /* MTRDeviceXPCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD359B82C545F9E00CCFE4D /* MTRDeviceXPCTests.m */; };
305+
9BD359BB2C5461DB00CCFE4D /* MTRDevice+XPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD359BA2C5461DB00CCFE4D /* MTRDevice+XPC.h */; settings = {ATTRIBUTES = (Public, ); }; };
306+
9BD359BF2C5462B800CCFE4D /* MTRDevice+XPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD359BE2C5462AE00CCFE4D /* MTRDevice+XPC.m */; };
305307
AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
306308
AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */; };
307309
AF5F90FF2878D351005503FA /* MTROTAProviderDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = AF5F90FE2878D351005503FA /* MTROTAProviderDelegateBridge.mm */; };
@@ -729,6 +731,8 @@
729731
99C65E0F267282F1003402F6 /* MTRControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRControllerTests.m; sourceTree = "<group>"; };
730732
99D466E02798936D0089A18F /* MTRCommissioningParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRCommissioningParameters.h; sourceTree = "<group>"; };
731733
9BD359B82C545F9E00CCFE4D /* MTRDeviceXPCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRDeviceXPCTests.m; sourceTree = "<group>"; };
734+
9BD359BA2C5461DB00CCFE4D /* MTRDevice+XPC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MTRDevice+XPC.h"; sourceTree = "<group>"; };
735+
9BD359BE2C5462AE00CCFE4D /* MTRDevice+XPC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MTRDevice+XPC.m"; sourceTree = "<group>"; };
732736
AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegate.h; sourceTree = "<group>"; };
733737
AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegateBridge.h; sourceTree = "<group>"; };
734738
AF5F90FE2878D351005503FA /* MTROTAProviderDelegateBridge.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTROTAProviderDelegateBridge.mm; sourceTree = "<group>"; };
@@ -1393,6 +1397,8 @@
13931397
5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */,
13941398
515BE4EC2B72C0C5000BC1FD /* MTRUnfairLock.h */,
13951399
3D69867E29382E58007314E7 /* Resources */,
1400+
9BD359BA2C5461DB00CCFE4D /* MTRDevice+XPC.h */,
1401+
9BD359BE2C5462AE00CCFE4D /* MTRDevice+XPC.m */,
13961402
);
13971403
path = CHIP;
13981404
sourceTree = "<group>";
@@ -1602,6 +1608,7 @@
16021608
5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */,
16031609
3D843717294979230070D20A /* MTRClusters_Internal.h in Headers */,
16041610
7596A85728788557004DAE0E /* MTRClusters.h in Headers */,
1611+
9BD359BB2C5461DB00CCFE4D /* MTRDevice+XPC.h in Headers */,
16051612
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */,
16061613
75B3269C2BCDB9D600E17C4E /* MTRDeviceConnectivityMonitor.h in Headers */,
16071614
754784672BFE93B00089C372 /* MTRDeviceStorageBehaviorConfiguration.h in Headers */,
@@ -1938,6 +1945,7 @@
19381945
93B2CF9A2B56E45C00E4D187 /* MTRClusterNames.mm in Sources */,
19391946
998F287126D56940001846C6 /* MTRP256KeypairBridge.mm in Sources */,
19401947
516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */,
1948+
9BD359BF2C5462B800CCFE4D /* MTRDevice+XPC.m in Sources */,
19411949
51D0B1412B61B3A4006E3511 /* MTRServerCluster.mm in Sources */,
19421950
514C79FC2B62F94C00DD6D7B /* ota-provider.cpp in Sources */,
19431951
5136661428067D550025EDAE /* MTRDeviceControllerFactory.mm in Sources */,

0 commit comments

Comments
 (0)