2017-05-26 23:06:14 +00:00
|
|
|
/*
|
2018-02-12 23:31:53 +00:00
|
|
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-06-23 23:26:34 +00:00
|
|
|
*
|
2018-02-12 23:31:53 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* A copy of the License is located at
|
2017-06-23 23:26:34 +00:00
|
|
|
*
|
2018-02-12 23:31:53 +00:00
|
|
|
* http://aws.amazon.com/apache2.0/
|
2017-06-23 23:26:34 +00:00
|
|
|
*
|
2018-02-12 23:31:53 +00:00
|
|
|
* or in the "license" file accompanying this file. This file 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.
|
2017-06-23 23:26:34 +00:00
|
|
|
*/
|
2018-02-12 23:31:53 +00:00
|
|
|
|
2017-12-09 00:07:37 +00:00
|
|
|
#ifndef ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_COMMON_TESTABLEATTACHMENTWRITER_H_
|
|
|
|
#define ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_COMMON_TESTABLEATTACHMENTWRITER_H_
|
2017-05-26 23:06:14 +00:00
|
|
|
|
|
|
|
#include <AVSCommon/AVS/Attachment/InProcessAttachmentWriter.h>
|
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
|
|
|
namespace acl {
|
2017-06-09 23:23:31 +00:00
|
|
|
namespace test {
|
2017-05-26 23:06:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A version of the Decorator Pattern, this class allows us to simulate pausing writes without requiring
|
|
|
|
* an actual (slow) AttachmentReader anywhere in the test code. Besides this small change in functionality, all real
|
|
|
|
* work is done by the encapsulated InProcessAttachmentWriter object.
|
|
|
|
*/
|
|
|
|
class TestableAttachmentWriter : public avsCommon::avs::attachment::InProcessAttachmentWriter {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param dummySDS An SDS used to instantiate this class, although it will never be used. This is to avert any
|
|
|
|
* risk of this wrapper object being created with a nullptr.
|
|
|
|
* @param writer The AttachmentWriter object to be wrapped by this class.
|
|
|
|
*/
|
2017-10-02 22:59:05 +00:00
|
|
|
TestableAttachmentWriter(
|
|
|
|
std::shared_ptr<avsCommon::utils::sds::InProcessSDS> dummySDS,
|
|
|
|
std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> writer);
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2018-01-12 23:45:42 +00:00
|
|
|
std::size_t write(
|
|
|
|
const void* buf,
|
|
|
|
std::size_t numBytes,
|
|
|
|
WriteStatus* writeStatus,
|
|
|
|
std::chrono::milliseconds timeout) override;
|
2017-05-26 23:06:14 +00:00
|
|
|
|
|
|
|
void close() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// The AttachmentWriter object to be wrapped by this class.
|
|
|
|
std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> m_writer;
|
|
|
|
|
|
|
|
bool m_hasWriteBeenInvoked;
|
|
|
|
};
|
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
} // namespace test
|
|
|
|
} // namespace acl
|
|
|
|
} // namespace alexaClientSDK
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-12-09 00:07:37 +00:00
|
|
|
#endif // ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_COMMON_TESTABLEATTACHMENTWRITER_H_
|