/* * 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. */ #include "ILog.h" #include "LinuxApiMock.h" #include "UartDevice.h" #include "UartDeviceTestTool.h" #include #include namespace UartDeviceMockTest { const char *gDeviceName = "dev/s1"; static uart_info gUartDevice = { gDeviceName, 1152000, 'N', 8, 1, 'N', }; class UartDeviceMockTest : public testing::Test, public UartDeviceTestTool { public: UartDeviceMockTest() {} virtual ~UartDeviceMockTest() {} static void SetUpTestCase() { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); } static void TearDownTestCase() { ILogUnInit(); } virtual void SetUp() { mLinuxTest = LinuxTest::CreateLinuxTest(); std::shared_ptr test = mLinuxTest; LinuxApiMock::GetInstance(&test); UartDeviceDefaultInit(mLinuxTest, gUartDevice); } virtual void TearDown() {} public: std::shared_ptr mLinuxTest; // std::shared_ptr mLinuxApiMock; }; // ../output_files/test/bin/UartDeviceTest --gtest_filter=UartDeviceMockTest.Demo TEST_F(UartDeviceMockTest, Demo) { // EXPECT_CALL(*mLinuxTest.get(), fx_open(deviceName, ::testing::_)) // .WillRepeatedly(::testing::DoAll((::testing::Return(1000000000)))); void *object = CreateUartDevice(gUartDevice); IUartOpen(object); // IUartSend(object, nullptr, 0); // IUartRecv(object, nullptr, 0, 0); // IUartTcflush(object); IUartDeviceFree(object); } } // namespace UartDeviceMockTest