mirror of
https://github.com/openharmony/distributed_camera.git
synced 2026-06-30 22:17:57 -04:00
+5
-1
@@ -27,6 +27,7 @@
|
||||
#include "dcamera_source_state_factory.h"
|
||||
#include "dcamera_source_state_machine.h"
|
||||
#include "mock_dcamera_source_dev.h"
|
||||
#include "mock_dcamera_source_state_listener.h"
|
||||
|
||||
#include "anonymous_string.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
void TearDown();
|
||||
|
||||
std::shared_ptr<DCameraSourceDev> camDev_;
|
||||
std::shared_ptr<ICameraStateListener> stateListener_;
|
||||
std::shared_ptr<DCameraSourceStateMachine> stateMachine_;
|
||||
|
||||
private:
|
||||
@@ -150,7 +152,8 @@ void DCameraSourceStateMachineTest::TearDownTestCase(void)
|
||||
|
||||
void DCameraSourceStateMachineTest::SetUp(void)
|
||||
{
|
||||
camDev_ = std::make_shared<MockDCameraSourceDev>(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0);
|
||||
stateListener_ = std::make_shared<MockDCameraSourceStateListener>();
|
||||
camDev_ = std::make_shared<MockDCameraSourceDev>(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, stateListener_);
|
||||
stateMachine_ = std::make_shared<DCameraSourceStateMachine>(camDev_);
|
||||
}
|
||||
|
||||
@@ -158,6 +161,7 @@ void DCameraSourceStateMachineTest::TearDown(void)
|
||||
{
|
||||
stateMachine_ = nullptr;
|
||||
camDev_ = nullptr;
|
||||
stateListener_ = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -25,7 +25,8 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class MockDCameraSourceDev : public DCameraSourceDev {
|
||||
public:
|
||||
MockDCameraSourceDev(std::string devId, std::string dhId) : DCameraSourceDev(devId, dhId, stateLisener_) {};
|
||||
MockDCameraSourceDev(std::string devId, std::string dhId, std::shared_ptr<ICameraStateListener>& stateLisener)
|
||||
: DCameraSourceDev(devId, dhId, stateLisener) {};
|
||||
~MockDCameraSourceDev() = default;
|
||||
|
||||
int32_t ExecuteRegister(std::shared_ptr<DCameraRegistParam>& param)
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
private:
|
||||
std::string devId_;
|
||||
std::string dhId_;
|
||||
std::shared_ptr<ICameraStateListener> stateLisener_ = nullptr;
|
||||
std::shared_ptr<ICameraStateListener> stateLisener_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* 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 OHOS_DISTRIBUTED_CAMERA_MOCKSOURCE_STATE_LISTENER_H
|
||||
#define OHOS_DISTRIBUTED_CAMERA_MOCKSOURCE_STATE_LISTENER_H
|
||||
|
||||
#include "icamera_state_listener.h"
|
||||
|
||||
#include "distributed_camera_errno.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class MockDCameraSourceStateListener : public ICameraStateListener {
|
||||
public:
|
||||
MockDCameraSourceStateListener() {};
|
||||
~MockDCameraSourceStateListener() = default;
|
||||
|
||||
int32_t OnRegisterNotify(const std::string& devId, const std::string& dhId, const std::string& reqId,
|
||||
int32_t status, std::string& data)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
|
||||
int32_t OnUnregisterNotify(const std::string& devId, const std::string& dhId, const std::string& reqId,
|
||||
int32_t status, std::string& data)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user