diff options
Diffstat (limited to 'src/components/time_tester/test')
11 files changed, 0 insertions, 868 deletions
diff --git a/src/components/time_tester/test/CMakeLists.txt b/src/components/time_tester/test/CMakeLists.txt deleted file mode 100644 index 006f6a430f..0000000000 --- a/src/components/time_tester/test/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2015, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -if(BUILD_TESTS) - -include_directories ( - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/include - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/gtest/include - ${COMPONENTS_DIR}/include/utils - ${COMPONENTS_DIR}/include/protocol_handler - ${COMPONENTS_DIR}/time_tester/include - ${COMPONENTS_DIR}/utils/include - ${COMPONENTS_DIR}/protocol_handler/include - ${COMPONENTS_DIR}/application_manager/include - ${COMPONENTS_DIR}/protocol_handler/test - ) - - -set(testSources - #metric_wrapper_test.cc - #time_manager_test.cc - #protocol_handler_metric_test.cc - protocol_handler_observer_test.cc - #transport_manager_metric_test.cc - transport_manager_observer_test.cc - #application_manager_metric_test.cc - application_manager_observer_test.cc -) - -set(testLibraries - gmock - TimeTester - jsoncpp - Utils - MediaManager - ProtocolHandler - v4_protocol_v1_2_no_extra - SmartObjects - ProtocolLibrary - ConfigProfile - connectionHandler - ApplicationManager - Resumption - jsoncpp - transport_manager - MediaManager - ProtocolHandler -) - -if (BUILD_USB_SUPPORT) - list(APPEND testLibraries Libusb-1.0.16) -endif() - -if (BUILD_BT_SUPPORT) - list(APPEND testLibraries bluetooth) -endif() - -if (BUILD_AVAHI_SUPPORT) - list(APPEND testLibraries avahi-client avahi-common) -endif() - -file(COPY log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -create_test("time_tester_test" "${testSources}" "${testLibraries}") - -endif() diff --git a/src/components/time_tester/test/application_manager_metric_test.cc b/src/components/time_tester/test/application_manager_metric_test.cc deleted file mode 100644 index 7d09cc85c9..0000000000 --- a/src/components/time_tester/test/application_manager_metric_test.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "json_keys.h" -#include "utils/resource_usage.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager_metric.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(ApplicationManagerMetricWrapper, grabResources) { - ApplicationManagerMetricWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(ApplicationManagerMetricWrapper, GetJsonMetric) { - ApplicationManagerMetricWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new application_manager::AMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - NsSmartDeviceLink::NsSmartObjects::SmartObject obj; - obj["params"][application_manager::strings::correlation_id] = 11; - obj["params"][application_manager::strings::connection_key] = 12; - metric_test.message_metric->message = new NsSmartDeviceLink::NsSmartObjects::SmartObject(obj); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[time_tester::strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[time_tester::strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[time_tester::strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[time_tester::strings::correlation_id].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::connection_key].asInt(), jvalue[time_tester::strings::connection_key].asInt()); -} - -TEST(ApplicationManagerMetricWrapper, GetJsonMetricWithGrabResources) { - ApplicationManagerMetricWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - - metric_test.message_metric = new application_manager::AMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - NsSmartDeviceLink::NsSmartObjects::SmartObject obj; - obj["params"][application_manager::strings::correlation_id] = 11; - obj["params"][application_manager::strings::connection_key] = 12; - metric_test.message_metric->message = new NsSmartDeviceLink::NsSmartObjects::SmartObject(obj); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[time_tester::strings::correlation_id].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::connection_key].asInt(), jvalue[time_tester::strings::connection_key].asInt()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - - EXPECT_NEAR(resources->stime, jvalue[time_tester::strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[time_tester::strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[time_tester::strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/application_manager_observer_test.cc b/src/components/time_tester/test/application_manager_observer_test.cc deleted file mode 100644 index f63394e4f2..0000000000 --- a/src/components/time_tester/test/application_manager_observer_test.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "include/time_manager_mock.h" -#include "application_manager/time_metric_observer.h" -#include "application_manager_metric.h" -#include "application_manager_observer.h" -#include "utils/shared_ptr.h" -#include "time_manager.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(ApplicationManagerObserver, DISABLED_CallOnMessage) { - TimeManagerMock time_manager_mock; - ApplicationManagerObserver app_observer(&time_manager_mock); - typedef application_manager::AMMetricObserver::MessageMetric AMMetric; - utils::SharedPtr<AMMetric> ptr = application_manager::AMMetricObserver::MessageMetricSharedPtr(); - EXPECT_CALL(time_manager_mock, SendMetric(_)); - app_observer.OnMessage(ptr); -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/include/time_manager_mock.h b/src/components/time_tester/test/include/time_manager_mock.h deleted file mode 100644 index dfdfa2da7b..0000000000 --- a/src/components/time_tester/test/include/time_manager_mock.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ -#define TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ - -#include <gmock/gmock.h> -#include "time_manager.h" -#include "metric_wrapper.h" -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -/* - * MOCK implementation of ::security_manager::SecurityManager - */ -class TimeManagerMock : public time_tester::TimeManager { - public: - MOCK_METHOD1(Init, void(protocol_handler::ProtocolHandlerImpl* ph)); - MOCK_METHOD0(Stop, void()); - MOCK_METHOD0(Start, void()); - MOCK_METHOD1(SendMetric, void(utils::SharedPtr<MetricWrapper> metric)); -}; -} // time_tester_test -} // components -} // test -#endif // TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ diff --git a/src/components/time_tester/test/log4cxx.properties b/src/components/time_tester/test/log4cxx.properties deleted file mode 100644 index 68adbfa7f3..0000000000 --- a/src/components/time_tester/test/log4cxx.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Only ERROR and FATAL messages are logged to console -log4j.appender.Console=org.apache.log4j.ConsoleAppender -log4j.appender.Console.ImmediateFlush=true -log4j.appender.Console.layout=org.apache.log4j.PatternLayout -log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n -log4j.appender.Console.Threshold=DEBUG - -# Log for all SmartDeviceLinkCore messages -log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.FileAppender -log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log -log4j.appender.SmartDeviceLinkCoreLogFile.append=true -log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm -log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true -log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout -log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n - - -# All SmartDeviceLinkCore logs -log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile diff --git a/src/components/time_tester/test/metric_wrapper_test.cc b/src/components/time_tester/test/metric_wrapper_test.cc deleted file mode 100644 index 5eddf0fb62..0000000000 --- a/src/components/time_tester/test/metric_wrapper_test.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "metric_wrapper.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(MetricWrapper, grabResources) { - MetricWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(MetricWrapper, GetJsonMetricWithoutGrab) { - MetricWrapper metric_test; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); -} - -TEST(MetricWrapper, GetJsonMetricWithGrabResources) { - MetricWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_TRUE(jvalue[strings::stime].isInt()); - EXPECT_TRUE(jvalue[strings::utime].isInt()); - EXPECT_TRUE(jvalue[strings::memory].isInt()); - EXPECT_NE("null/n", jvalue[strings::stime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::utime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::memory].toStyledString()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/protocol_handler_metric_test.cc b/src/components/time_tester/test/protocol_handler_metric_test.cc deleted file mode 100644 index 150e1205fe..0000000000 --- a/src/components/time_tester/test/protocol_handler_metric_test.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" -#include "protocol_handler_metric.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(ProtocolHandlerMetricTest, grabResources) { - ProtocolHandlerMecticWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(ProtocolHandlerMetricTest, GetJsonMetric) { - ProtocolHandlerMecticWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new protocol_handler::PHMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->message_id = 5; - metric_test.message_metric->connection_key = 2; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("\"ProtocolHandler\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); - EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); -} - -TEST(ProtocolHandlerMetricTest, GetJsonMetricWithGrabResources) { - ProtocolHandlerMecticWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new protocol_handler::PHMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->message_id = 5; - metric_test.message_metric->connection_key = 2; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_TRUE(jvalue[strings::stime].isInt()); - EXPECT_TRUE(jvalue[strings::utime].isInt()); - EXPECT_TRUE(jvalue[strings::memory].isInt()); - EXPECT_NE("null/n", jvalue[strings::stime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::utime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); - EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/protocol_handler_observer_test.cc b/src/components/time_tester/test/protocol_handler_observer_test.cc deleted file mode 100644 index 8922334aee..0000000000 --- a/src/components/time_tester/test/protocol_handler_observer_test.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "time_manager.h" -#include "include/time_manager_mock.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(ProtocolHandlerObserverTest, DISABLED_MessageProcess) { - TimeManagerMock time_manager_mock; - - ProtocolHandlerObserver pr_handler(&time_manager_mock); - uint32_t message_id = 1; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - pr_handler.StartMessageProcess(message_id, start_time); - - typedef protocol_handler::PHMetricObserver::MessageMetric MetricType; - utils::SharedPtr<MetricType> message_metric = new MetricType(); - message_metric->message_id = 1; - EXPECT_CALL(time_manager_mock, SendMetric(_)); - pr_handler.EndMessageProcess(message_metric); -} - -TEST(ProtocolHandlerObserverTest, MessageProcessWithZeroMessageId) { - TimeManagerMock time_manager_mock; - - ProtocolHandlerObserver pr_handler(&time_manager_mock); - uint32_t message_id = 0; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - pr_handler.StartMessageProcess(message_id, start_time); - - typedef protocol_handler::PHMetricObserver::MessageMetric MetricType; - utils::SharedPtr<MetricType> message_metric = new MetricType(); - message_metric->message_id = 0; - EXPECT_CALL(time_manager_mock, SendMetric(_)).Times(0); - pr_handler.EndMessageProcess(message_metric); -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/time_manager_test.cc b/src/components/time_tester/test/time_manager_test.cc deleted file mode 100644 index 60f3bd6814..0000000000 --- a/src/components/time_tester/test/time_manager_test.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "gmock/gmock.h" -#include "time_manager.h" -#include "protocol_handler/time_metric_observer.h" -#include "protocol_handler.h" -#include "include/protocol_handler_mock.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; - -class StreamerMock : public Streamer { - public: - StreamerMock(TimeManager* const server) - : Streamer(server) { - is_client_connected_ = true; - } - MOCK_METHOD1(PushMessage,void(utils::SharedPtr<MetricWrapper> metric)); -}; - -TEST(TimeManagerTest, DISABLED_MessageProcess) { - //TODO(AK) APPLINK-13351 Disable due to refactor TimeTester - protocol_handler_test::TransportManagerMock transport_manager_mock; - protocol_handler::ProtocolHandlerImpl protocol_handler_mock(&transport_manager_mock, 0, 0, 0, 0, 0); - TimeManager * time_manager = new TimeManager(); - // Streamer will be deleted by Thread - StreamerMock* streamer_mock = new StreamerMock(time_manager); - time_manager->set_streamer(streamer_mock); - time_manager->Init(&protocol_handler_mock); - utils::SharedPtr<MetricWrapper> test_metric; - EXPECT_CALL(*streamer_mock, PushMessage(test_metric)); - time_manager->SendMetric(test_metric); - delete time_manager; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/transport_manager_metric_test.cc b/src/components/time_tester/test/transport_manager_metric_test.cc deleted file mode 100644 index 2bb09416ed..0000000000 --- a/src/components/time_tester/test/transport_manager_metric_test.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" -#include "transport_manager_metric.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(TransportManagerMetricWrapper, grabResources) { - TransportManagerMecticWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(TransportManagerMetricWrapper, GetJsonMetric) { - TransportManagerMecticWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new transport_manager::TMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->data_size = 1000; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); -} - -TEST(TransportManagerMetricWrapper, GetJsonMetricWithGrabResources) { - TransportManagerMecticWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new transport_manager::TMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - - metric_test.message_metric->data_size = 1000; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("\"TransportManager\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/transport_manager_observer_test.cc b/src/components/time_tester/test/transport_manager_observer_test.cc deleted file mode 100644 index 9dcf27bd97..0000000000 --- a/src/components/time_tester/test/transport_manager_observer_test.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "gtest/gtest.h" -#include "include/time_manager_mock.h" -#include "protocol_handler/time_metric_observer.h" -#include "transport_manager_metric.h" -#include "transport_manager_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(TransportManagerObserverTest, DISABLED_MessageProcess) { - TimeManagerMock time_manager_mock; - TransportManagerObserver tr_observer(&time_manager_mock); - protocol_handler::RawMessage* ptr = new ::protocol_handler::RawMessage(0, 0, NULL, 0); - tr_observer.StartRawMsg(ptr); - EXPECT_CALL(time_manager_mock, SendMetric(_)); - tr_observer.StopRawMsg(ptr); - delete ptr; -} - -} // namespace time_tester -} // namespace components -} // namespace test |