mirror of
				https://gitee.com/jiuyilian/embedded-framework.git
				synced 2025-10-24 18:20:15 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			62 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023 Fancy Code.
 | |
|  * 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.
 | |
|  */
 | |
| #ifndef HAL_TEST_TOOL_H
 | |
| #define HAL_TEST_TOOL_H
 | |
| #include "GtestUsing.h"
 | |
| #include "IHalCpp.h"
 | |
| #include "LedControl.h"
 | |
| class HalTestTool
 | |
| {
 | |
| public:
 | |
|     HalTestTool() = default;
 | |
|     virtual ~HalTestTool() = default;
 | |
|     void Init(void);
 | |
|     void UnInit(void);
 | |
|     void SetAllKeysResult(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
 | |
|     void SetAllLedsResult(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds);
 | |
|     // void SetKeyEvent(const std::string keyName, const KeyHalEvent &event); // TODO: unused function?
 | |
|     void SetKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs = 200);
 | |
|     void SetLedStateExpectations(const std::string &ledName, const LedState &state, const unsigned int &aliveTimeMs,
 | |
|                                  const unsigned int &blinkTimeMs);
 | |
| 
 | |
| protected:
 | |
|     virtual void DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs) {}
 | |
| 
 | |
| private:
 | |
|     void KeyEventHappendOnce(std::shared_ptr<VKeyHal> &vMock, const unsigned int &pressingTimeMs);
 | |
| 
 | |
| private:
 | |
|     void HalMockInit(std::shared_ptr<IHalCpp> &vMock);
 | |
|     void SetAllKeysResult(std::shared_ptr<IHalCpp> &vMock, std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
 | |
|     std::shared_ptr<VKeyHal> SearchKey(const std::string &keyName);
 | |
|     void InitAllKeysMock(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
 | |
|     void InitKeysMock(std::shared_ptr<VKeyHal> &vMock);
 | |
| 
 | |
| private:
 | |
|     void SetAllLedsResult(std::shared_ptr<IHalCpp> &vMock, std::map<std::string, std::shared_ptr<VLedHal>> &allLeds);
 | |
|     std::shared_ptr<VLedHal> &SearchLed(const std::string &ledName);
 | |
|     void InitAllLedsMock(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds);
 | |
|     void InitLedsMock(std::shared_ptr<VLedHal> &vMock);
 | |
| 
 | |
| public:
 | |
|     static std::shared_ptr<VKeyHal> MakeKeyHalTest(const std::string &keyName);
 | |
|     static std::shared_ptr<VLedHal> MakeLedHalTest(const std::string &ledName);
 | |
| 
 | |
| private:
 | |
|     std::shared_ptr<IHalCpp> mHalMock;
 | |
|     std::map<std::string, std::shared_ptr<VKeyHal>> mAllKeys;
 | |
|     std::map<std::string, std::shared_ptr<VLedHal>> mAllLeds;
 | |
| };
 | |
| #endif | 
