streamer_node_test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 
16 #include <gtest/gtest.h>
17 #include <gmock/gmock.h>
18 
19 #include <aws/core/Aws.h>
23 #include <ros/ros.h>
24 
25 using ::testing::Eq;
26 using ::testing::Return;
27 using ::testing::AtLeast;
28 using Aws::AwsError;
29 
30 using namespace Aws::Kinesis;
31 
33 {
34 public:
36 
37  MOCK_METHOD0(SetDefaultCallbacks, bool());
38  MOCK_METHOD1(SetupImageTransport, bool(const ImageTransportCallbackFn callback));
39  MOCK_METHOD1(set_stream_manager, void(KinesisStreamManagerInterface * stream_manager));
40 };
41 
42 class TestStreamerNode : public ::testing::Test
43 {
44 protected:
45  std::shared_ptr<MockRosStreamSubscriptionInstaller> mock_subscription_installer_;
46  std::shared_ptr<StreamerNode> streamer_node_;
47 
48  void SetUp() override
49  {
50  streamer_node_ = std::make_shared<StreamerNode>("~");
51  mock_subscription_installer_ = std::make_shared<MockRosStreamSubscriptionInstaller>(*streamer_node_);
52  streamer_node_->set_subscription_installer(mock_subscription_installer_);
53  }
54 
55  void TearDown() override
56  {
57  streamer_node_.reset();
58  mock_subscription_installer_.reset();
59  }
60 };
61 
63 {
64  EXPECT_TRUE(true);
65 }
66 
67 TEST_F(TestStreamerNode, InitializeStreamerNode)
68 {
69  EXPECT_CALL(*mock_subscription_installer_, SetDefaultCallbacks())
70  .Times(AtLeast(1)).WillRepeatedly(Return(true));
71  KinesisManagerStatus initialize_result = streamer_node_->Initialize();
72  EXPECT_TRUE(KINESIS_MANAGER_STATUS_SUCCEEDED(initialize_result));
73 }
74 
75 int main(int argc, char ** argv)
76 {
77  Aws::SDKOptions options_;
78  Aws::InitAPI(options_);
79 
80  testing::InitGoogleMock(&argc, argv);
81 
82  ros::init(argc, argv, "test_streamer_node");
83  ros::NodeHandle n("test_streamer_node");
84  n.setParam("aws_client_configuration/region", "us-west-2");
85  int ret = RUN_ALL_TESTS();
86 
87  return ret;
88 }
enum Aws::Kinesis::kinesis_manager_status_e KinesisManagerStatus
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define KINESIS_MANAGER_STATUS_SUCCEEDED(status)
int main(int argc, char **argv)
void TearDown() override
void(* ImageTransportCallbackFn)(const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
std::shared_ptr< StreamerNode > streamer_node_
std::shared_ptr< MockRosStreamSubscriptionInstaller > mock_subscription_installer_
TEST_F(TestStreamerNode, CreateNode)
void SetUp() override
MockRosStreamSubscriptionInstaller(ros::NodeHandle &handle)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const


kinesis_video_streamer
Author(s): AWS RoboMaker
autogenerated on Fri Mar 5 2021 03:29:15