summaryrefslogtreecommitdiff
path: root/src/components/protocol_handler
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-03-10 10:59:30 +0200
committerKozoriz <kozorizandriy@gmail.com>2016-03-10 13:28:45 +0200
commit253f9a224e8e78182b3e5f26c422002a3b581c2c (patch)
tree8cc3351651158b71eb374ec734171df947b131fb /src/components/protocol_handler
parent358ca6459aa2e9b2fe9ace737cc396937311c014 (diff)
downloadsdl_core-253f9a224e8e78182b3e5f26c422002a3b581c2c.tar.gz
TimeTester refatctoring.
Removed singletone using from TimeTester. TimeTester renamed -> TelemetryMonitor. All files and directories corrected. Tests corrected, all works. Disabled 2 tests(task created). Related to : APPLINK-21915
Diffstat (limited to 'src/components/protocol_handler')
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h26
-rw-r--r--src/components/protocol_handler/include/protocol_handler/telemetry_observer.h (renamed from src/components/protocol_handler/include/protocol_handler/time_metric_observer.h)4
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc46
-rw-r--r--src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h54
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc2
5 files changed, 96 insertions, 36 deletions
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index 9795adaa54..bda65803e8 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -57,9 +57,10 @@
#include "transport_manager/transport_manager_listener_empty.h"
#include "connection_handler/connection_handler.h"
-#ifdef TIME_TESTER
-#include "protocol_handler/time_metric_observer.h"
-#endif // TIME_TESTER
+#ifdef TELEMETRY_MONITOR
+#include "protocol_handler/telemetry_observer.h"
+#include "telemetry_monitor/telemetry_observable.h"
+#endif // TELEMETRY_MONITOR
#ifdef ENABLE_SECURITY
#include "security_manager/security_manager.h"
@@ -138,7 +139,12 @@ class ProtocolHandlerImpl
: public ProtocolHandler,
public TransportManagerListenerEmpty,
public impl::FromMobileQueue::Handler,
- public impl::ToMobileQueue::Handler {
+ public impl::ToMobileQueue::Handler
+#ifdef TELEMETRY_MONITOR
+ ,
+ public telemetry_monitor::TelemetryObservable<PHTelemetryObserver>
+#endif // TELEMETRY_MONITOR
+ {
public:
/**
* @brief Constructor
@@ -194,14 +200,14 @@ class ProtocolHandlerImpl
*/
void SendFramesNumber(uint32_t connection_key, int32_t number_of_frames);
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
/**
* @brief Setup observer for time metric.
*
* @param observer - pointer to observer
*/
- void SetTimeMetricObserver(PHMetricObserver *observer);
-#endif // TIME_TESTER
+ void SetTelemetryObserver(PHTelemetryObserver *observer);
+#endif // TELEMETRY_MONITOR
/*
* Prepare and send heartbeat message to mobile
@@ -545,9 +551,9 @@ class ProtocolHandlerImpl
sync_primitives::Lock protocol_observers_lock_;
-#ifdef TIME_TESTER
- PHMetricObserver *metric_observer_;
-#endif // TIME_TESTER
+#ifdef TELEMETRY_MONITOR
+ PHTelemetryObserver *metric_observer_;
+#endif // TELEMETRY_MONITOR
};
} // namespace protocol_handler
#endif // SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_IMPL_H_
diff --git a/src/components/protocol_handler/include/protocol_handler/time_metric_observer.h b/src/components/protocol_handler/include/protocol_handler/telemetry_observer.h
index 1d3d83ea48..f0923623e0 100644
--- a/src/components/protocol_handler/include/protocol_handler/time_metric_observer.h
+++ b/src/components/protocol_handler/include/protocol_handler/telemetry_observer.h
@@ -39,7 +39,7 @@
namespace protocol_handler {
-class PHMetricObserver {
+class PHTelemetryObserver {
public:
struct MessageMetric {
RawMessagePtr raw_msg;
@@ -50,7 +50,7 @@ class PHMetricObserver {
};
virtual void StartMessageProcess(uint32_t message_id, const TimevalStruct &start_time) = 0;
virtual void EndMessageProcess(utils::SharedPtr<MessageMetric> m) = 0;
- virtual ~PHMetricObserver(){}
+ virtual ~PHTelemetryObserver(){}
};
} // protocol_handler
#endif // SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_TIME_METRIC_OBSERVER_H_
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index e0ab97bdcb..f701fb02e5 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -74,9 +74,9 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(const ProtocolHandlerSettings& settings
threads::ThreadOptions(kStackSize)),
raw_ford_messages_to_mobile_("PH ToMobile", this,
threads::ThreadOptions(kStackSize))
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
, metric_observer_(NULL)
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
{
LOG4CXX_AUTO_TRACE(logger_);
@@ -320,9 +320,9 @@ void ProtocolHandlerImpl::SendHeartBeat(int32_t connection_id,
void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message,
bool final_message) {
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
LOG4CXX_AUTO_TRACE(logger_);
if (!message) {
LOG4CXX_ERROR(logger_,
@@ -334,12 +334,12 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message,
uint8_t sessionID = 0;
session_observer_.PairFromKey(message->connection_key(), &connection_handle,
&sessionID);
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
uint32_t message_id = message_counters_[sessionID];
if (metric_observer_) {
metric_observer_->StartMessageProcess(message_id, start_time);
}
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
const size_t max_frame_size = get_settings().maximum_payload_size();
size_t frame_size = MAXIMUM_FRAME_DATA_V2_SIZE;
switch (message->protocol_version()) {
@@ -394,10 +394,10 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message,
"ProtocolHandler failed to send multiframe messages.");
}
}
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
if (metric_observer_) {
- PHMetricObserver::MessageMetric *metric
- = new PHMetricObserver::MessageMetric();
+ PHTelemetryObserver::MessageMetric *metric
+ = new PHTelemetryObserver::MessageMetric();
metric->message_id = message_id;
metric->connection_key = message->connection_key();
metric->raw_msg = message;
@@ -448,9 +448,9 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) {
for (ProtocolFramePtrList::const_iterator it =
protocol_frames.begin(); it != protocol_frames.end(); ++it) {
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
ProtocolFramePtr frame = *it;
#ifdef ENABLE_SECURITY
const RESULT_CODE result = DecryptFrame(frame);
@@ -460,11 +460,11 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) {
}
#endif // ENABLE_SECURITY
impl::RawFordMessageFromMobile msg(frame);
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
if (metric_observer_) {
metric_observer_->StartMessageProcess(msg->message_id(), start_time);
}
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
raw_ford_messages_from_mobile_.PostMessage(msg);
}
@@ -729,10 +729,10 @@ RESULT_CODE ProtocolHandlerImpl::HandleSingleFrameMessage(const ProtocolFramePtr
if (!rawMessage) {
return RESULT_FAIL;
}
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
if (metric_observer_) {
- PHMetricObserver::MessageMetric *metric
- = new PHMetricObserver::MessageMetric();
+ PHTelemetryObserver::MessageMetric *metric
+ = new PHTelemetryObserver::MessageMetric();
metric->message_id = packet->message_id();
metric->connection_key = connection_key;
metric->raw_msg = rawMessage;
@@ -1058,14 +1058,14 @@ void ProtocolHandlerImpl::PopValideAndExpirateMultiframes() {
frame->payload_size()));
DCHECK(rawMessage);
-#ifdef TIME_TESTER
+#ifdef TELEMETRY_MONITOR
if (metric_observer_) {
- PHMetricObserver::MessageMetric *metric =
- new PHMetricObserver::MessageMetric();
+ PHTelemetryObserver::MessageMetric *metric =
+ new PHTelemetryObserver::MessageMetric();
metric->raw_msg = rawMessage;
metric_observer_->EndMessageProcess(metric);
}
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
NotifySubscribers(rawMessage);
}
}
@@ -1296,11 +1296,11 @@ void ProtocolHandlerImpl::SendFramesNumber(uint32_t connection_key,
}
}
-#ifdef TIME_TESTER
-void ProtocolHandlerImpl::SetTimeMetricObserver(PHMetricObserver *observer) {
+#ifdef TELEMETRY_MONITOR
+void ProtocolHandlerImpl::SetTelemetryObserver(PHTelemetryObserver *observer) {
metric_observer_ = observer;
}
-#endif // TIME_TESTER
+#endif // TELEMETRY_MONITOR
std::string ConvertPacketDataToString(const uint8_t *data,
const size_t data_size) {
diff --git a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h
new file mode 100644
index 0000000000..83037c9631
--- /dev/null
+++ b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h
@@ -0,0 +1,54 @@
+/*
+ * 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 SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TIME_METRIC_OBSERVER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TIME_METRIC_OBSERVER_H_
+
+#include "gmock/gmock.h"
+#include "protocol_handler/time_metric_observer.h"
+#include "utils/shared_ptr.h"
+
+namespace test {
+namespace components {
+namespace protocol_handler_test {
+
+class MockPHTelemetryObserver : public ::protocol_handler::PHTelemetryObserver {
+ public:
+ MOCK_METHOD2(StartMessageProcess, void(uint32_t, const TimevalStruct&));
+ MOCK_METHOD2(EndMessageProcess, void(utils::SharedPtr<MessageMetric>));
+};
+
+} // namespace protocol_handler_test
+} // namespace components
+} // namespace test
+
+-#endif // SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TIME_METRIC_OBSERVER_H_
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 769678dc27..3f04ea5564 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -193,7 +193,7 @@ class ProtocolHandlerImplTest : public ::testing::Test {
std::vector<uint8_t> some_data;
// Strict mocks (same as all methods EXPECT_CALL().Times(0))
testing::NiceMock<connection_handler_test::MockConnectionHandler> connection_handler_mock;
- testing::StrictMock<transport_manager_test::TransportManagerMock> transport_manager_mock;
+ testing::StrictMock<transport_manager_test::MockTransportManager> transport_manager_mock;
testing::StrictMock<protocol_handler_test::MockSessionObserver> session_observer_mock;
#ifdef ENABLE_SECURITY
testing::NiceMock<protocol_handler_test::SecurityManagerMock> security_manager_mock;