AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MockAndroidSLESInterface.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #ifndef ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_TEST_ANDROIDUTILITIES_MOCKANDROIDSLESINTERFACE_H_
16 #define ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_TEST_ANDROIDUTILITIES_MOCKANDROIDSLESINTERFACE_H_
17 
18 namespace alexaClientSDK {
19 namespace applicationUtilities {
20 namespace androidUtilities {
21 namespace test {
22 
27 public:
33  virtual void set(void* destination) = 0;
34 
38  virtual ~MockInterface() = default;
39 };
40 
44 template <typename InterfaceT>
46 public:
49  void set(void* destination);
51 
54 
56  ~MockInterfaceImpl();
57 
62  InterfaceT& get();
63 
64 private:
66  InterfaceT** m_mockAndroidSLESObject;
67 };
68 
69 template <typename InterfaceT>
71  auto object = new InterfaceT();
72  auto objectPtr = new InterfaceT*();
73  *objectPtr = object;
74  m_mockAndroidSLESObject = objectPtr;
75 }
76 
77 template <typename InterfaceT>
79  delete *m_mockAndroidSLESObject;
80  delete m_mockAndroidSLESObject;
81 }
82 
83 template <typename InterfaceT>
84 void MockInterfaceImpl<InterfaceT>::set(void* destination) {
85  auto destinationPtr = static_cast<InterfaceT***>(destination);
86  *destinationPtr = m_mockAndroidSLESObject;
87 }
88 
89 template <typename InterfaceT>
91  return **m_mockAndroidSLESObject;
92 }
93 
94 } // namespace test
95 } // namespace androidUtilities
96 } // namespace applicationUtilities
97 } // namespace alexaClientSDK
98 
99 #endif // ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_TEST_ANDROIDUTILITIES_MOCKANDROIDSLESINTERFACE_H_
~MockInterfaceImpl()
Destructor.
Definition: MockAndroidSLESInterface.h:78
MockInterfaceImpl()
Constructor.
Definition: MockAndroidSLESInterface.h:70
void set(void *destination)
Definition: MockAndroidSLESInterface.h:84
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
InterfaceT & get()
Definition: MockAndroidSLESInterface.h:90

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0