1 /* 2 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_SHARING_MOCK_SCREEN_CAPTURE_CONSUMER_H 17 #define OHOS_SHARING_MOCK_SCREEN_CAPTURE_CONSUMER_H 18 19 #include <gmock/gmock.h> 20 #include "buffer_dispatcher.h" 21 #include "mock_media_channel.h" 22 #define private public 23 #define protected public 24 #include "screen_capture_consumer.h" 25 #undef private 26 #undef protected 27 28 namespace OHOS { 29 namespace Sharing { 30 31 class MockScreenCaptureConsumer : public ScreenCaptureConsumer { 32 public: Initialize(void)33 void Initialize(void) 34 { 35 mediaChannel_ = std::make_shared<MockMediaChannel>(); 36 dispatcher_ = std::make_shared<BufferDispatcher>(); 37 std::weak_ptr<MockMediaChannel> weakListener(mediaChannel_); 38 SetConsumerListener(weakListener); 39 } 40 DeInitialize(void)41 void DeInitialize(void) 42 { 43 dispatcher_ = nullptr; 44 mediaChannel_ = nullptr; 45 } 46 public: 47 std::shared_ptr<MockMediaChannel> mediaChannel_; 48 std::shared_ptr<BufferDispatcher> dispatcher_; 49 }; 50 51 } // namespace Sharing 52 } // namespace OHOS 53 #endif 54