forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding *TestAccess Classes to allow access to private Members of test…
…ed functions
- Loading branch information
1 parent
304f3e8
commit f3c23e5
Showing
6 changed files
with
231 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/reporting/Engine.h> | ||
|
||
using namespace chip::app::reporting; | ||
|
||
namespace chip { | ||
namespace Test { | ||
|
||
/** | ||
* @brief Class acts as an accessor to private methods of the Engine class without needing to give friend access to | ||
* each individual test. | ||
* This is not a Global API and should only be used for (Unit) Testing. | ||
*/ | ||
class EngineTestAccess | ||
{ | ||
public: | ||
EngineTestAccess(Engine * aEngine) : pEngine(aEngine) {} | ||
|
||
CHIP_ERROR BuildAndSendSingleReportData(chip::app::ReadHandler * apReadHandler) | ||
{ | ||
return pEngine->BuildAndSendSingleReportData(apReadHandler); | ||
} | ||
|
||
Engine * GetEngine() { return pEngine; } | ||
|
||
ObjectPool<Engine::AttributePathParamsWithGeneration, CHIP_IM_SERVER_MAX_NUM_DIRTY_SET, ObjectPoolMem::kInline> & | ||
GetGlobalDirtySet() | ||
{ | ||
return pEngine->mGlobalDirtySet; | ||
} | ||
|
||
bool MergeOverlappedAttributePath(const chip::app::AttributePathParams & aAttributePath) | ||
{ | ||
return pEngine->MergeOverlappedAttributePath(aAttributePath); | ||
} | ||
|
||
inline void BumpDirtySetGeneration() { pEngine->BumpDirtySetGeneration(); } | ||
|
||
CHIP_ERROR InsertPathIntoDirtySet(const chip::app::AttributePathParams & aAttributePath) | ||
{ | ||
return pEngine->InsertPathIntoDirtySet(aAttributePath); | ||
} | ||
|
||
private: | ||
Engine * pEngine = nullptr; | ||
}; | ||
|
||
} // namespace Test | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/ReadHandler.h> | ||
|
||
using namespace chip::app; | ||
|
||
namespace chip { | ||
namespace Test { | ||
|
||
/** | ||
* @brief Class acts as an accessor to private methods of the ReadHandler class without needing to give friend access to | ||
* each individual test. | ||
* This is not a Global API and should only be used for (Unit) Testing. | ||
*/ | ||
class ReadHandlerTestAccess | ||
{ | ||
public: | ||
ReadHandlerTestAccess(ReadHandler * aReadHandler) : pReadHandler(aReadHandler) {} | ||
|
||
void OnInitialRequest(System::PacketBufferHandle && aPayload) | ||
{ | ||
if (pReadHandler != nullptr) | ||
{ | ||
pReadHandler->OnInitialRequest(std::move(aPayload)); | ||
} | ||
} | ||
ReadHandler * GetReadHandler() { return pReadHandler; } | ||
|
||
private: | ||
ReadHandler * pReadHandler = nullptr; | ||
}; | ||
|
||
} // namespace Test | ||
} // namespace chip |
Oops, something went wrong.