diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index be8bbf5d3f1724..b947b93ee5bcd2 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -51,6 +51,7 @@ 991DC0892475F47D00C13860 /* CHIPDeviceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 991DC0872475F47D00C13860 /* CHIPDeviceController.mm */; }; 991DC08B247704DC00C13860 /* CHIPLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC08A247704DC00C13860 /* CHIPLogging.h */; }; 9956064426420367000C28DE /* CHIPSetupPayload_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9956064326420367000C28DE /* CHIPSetupPayload_Internal.h */; }; + 99C65E10267282F1003402F6 /* CHIPControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* CHIPControllerTests.m */; }; B20252972459E34F00F97062 /* CHIP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B202528D2459E34F00F97062 /* CHIP.framework */; }; B289D4212639C0D300D4E314 /* CHIPOnboardingPayloadParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B289D41F2639C0D300D4E314 /* CHIPOnboardingPayloadParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B289D4222639C0D300D4E314 /* CHIPOnboardingPayloadParser.m in Sources */ = {isa = PBXBuildFile; fileRef = B289D4202639C0D300D4E314 /* CHIPOnboardingPayloadParser.m */; }; @@ -122,6 +123,7 @@ 991DC0872475F47D00C13860 /* CHIPDeviceController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDeviceController.mm; sourceTree = ""; }; 991DC08A247704DC00C13860 /* CHIPLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPLogging.h; sourceTree = ""; }; 9956064326420367000C28DE /* CHIPSetupPayload_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPSetupPayload_Internal.h; sourceTree = ""; }; + 99C65E0F267282F1003402F6 /* CHIPControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHIPControllerTests.m; sourceTree = ""; }; B202528D2459E34F00F97062 /* CHIP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CHIP.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B20252912459E34F00F97062 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B20252962459E34F00F97062 /* CHIPTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CHIPTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -264,6 +266,7 @@ isa = PBXGroup; children = ( 1EB41B7A263C4CC60048E4C1 /* CHIPClustersTests.m */, + 99C65E0F267282F1003402F6 /* CHIPControllerTests.m */, B2F53AF1245B0DCF0010745E /* CHIPSetupPayloadParserTests.m */, B202529D2459E34F00F97062 /* Info.plist */, ); @@ -470,6 +473,7 @@ buildActionMask = 2147483647; files = ( 1EB41B7B263C4CC60048E4C1 /* CHIPClustersTests.m in Sources */, + 99C65E10267282F1003402F6 /* CHIPControllerTests.m in Sources */, B2F53AF2245B0DCF0010745E /* CHIPSetupPayloadParserTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 85841daaa94aa1..85dbede0828e78 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -178,9 +178,10 @@ - (BOOL)startup:(_Nullable id)storageDelegate // Start the IO pump self.cppCommissioner->ServiceEvents(); + commissionerInitialized = YES; }); - return YES; + return commissionerInitialized; } - (NSNumber *)getControllerNodeId diff --git a/src/darwin/Framework/CHIPTests/CHIPControllerTests.m b/src/darwin/Framework/CHIPTests/CHIPControllerTests.m new file mode 100644 index 00000000000000..0e5e910eda0d42 --- /dev/null +++ b/src/darwin/Framework/CHIPTests/CHIPControllerTests.m @@ -0,0 +1,43 @@ +// +// CHIPControllerTests.m +// CHIPControllerTests +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +// system dependencies +#import + +@interface CHIPControllerTests : XCTestCase + +@end + +@implementation CHIPControllerTests + +- (void)testControllerLifecycle +{ + CHIPDeviceController * controller = [CHIPDeviceController sharedController]; + XCTAssertTrue([controller startup:nil]); + XCTAssertTrue([controller shutdown]); + + // now try to restart the controller + XCTAssertTrue([controller startup:nil]); + XCTAssertTrue([controller shutdown]); +} + +@end diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index 63b988bb404134..041f84d8457129 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -270,6 +270,7 @@ inline CHIP_ERROR PlatformManager::StartChipTimer(uint32_t durationMS) inline CHIP_ERROR PlatformManager::Shutdown() { + mInitialized = false; return static_cast(this)->_Shutdown(); }