summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Kramchaninov <PKramchaninov@luxoft.com>2014-10-07 17:25:21 +0300
committerPavel Kramchaninov <PKramchaninov@luxoft.com>2014-10-07 17:25:21 +0300
commit8457a2f5cf339074cf2bce5cdc9d51e8db349d97 (patch)
treebdf3d89d5c6a434e628450d2de40c9d182aaacdd
parent6d6b297ee2f6114b41f5b49785930550b5506e92 (diff)
downloadsmartdevicelink-8457a2f5cf339074cf2bce5cdc9d51e8db349d97.tar.gz
Revert "APPLINK-9509: Unit-Test refactoring"
This reverts commit 3b621c81d9a3127a555d5d7cb30326f980873da1.
-rw-r--r--src/appMain/CMakeLists.txt29
-rw-r--r--src/appMain/main_test.cc61
-rw-r--r--src/components/media_manager/CMakeLists.txt21
-rwxr-xr-xsrc/components/media_manager/src/main.cc7
-rw-r--r--src/components/utils/CMakeLists.txt21
-rw-r--r--src/components/utils/src/date_time_test.cc128
-rw-r--r--src/components/utils/src/file_system_test.cc111
-rwxr-xr-xsrc/components/utils/src/main.cc7
-rw-r--r--test/components/utils/CMakeLists.txt2
-rw-r--r--test/components/utils/include/utils/data_time_tests.h127
-rw-r--r--test/components/utils/include/utils/file_system_tests.h115
-rw-r--r--test/components/utils/src/data_time_tests.cc (renamed from src/components/media_manager/src/media_adapter_impl_test.cc)7
-rw-r--r--test/components/utils/src/file_system_tests.cc31
13 files changed, 276 insertions, 391 deletions
diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt
index 9261961e9..05dfb8102 100644
--- a/src/appMain/CMakeLists.txt
+++ b/src/appMain/CMakeLists.txt
@@ -111,13 +111,11 @@ include_directories (
../components/transport_manager/include
${SecurityManagerIncludeDir}
../components/config_profile/include
- ../components/utils/
../components/utils/include/
../components/connection_handler/include/
../components/hmi_message_handler/include
../components/request_watchdog/include
../components/smart_objects/include/
- ../components/media_manager/
../components/media_manager/include/
${CMAKE_SOURCE_DIR}/src/components/time_tester/include
${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/include/
@@ -158,33 +156,6 @@ endif()
add_executable(${PROJECT} ${SOURCES})
target_link_libraries(${PROJECT} ${LIBRARIES})
-
-#======================= Unit-Test section =======================
-if(BUILD_TESTS)
- include_directories (
- ../3rd_party-static/gmock-1.7.0/include
- ../3rd_party-static/gmock-1.7.0/gtest/include)
-
- set(testSources
- ./main_test.cc
- ../components/utils/src/file_system_test.cc
- ../components/utils/src/date_time_test.cc
- ../components/media_manager/src/media_adapter_impl_test.cc)
-
- set(testLibraries
- gmock
- gtest
- ConfigProfile
- log4cxx -L${LOG4CXX_LIBS_DIRECTORY}
- apr-1 -L${APR_LIBS_DIRECTORY}
- aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}
- expat -L${EXPAT_LIBS_DIRECTORY})
-
- add_executable(${PROJECT}_test ${testSources})
- target_link_libraries(${PROJECT}_test ${testLibraries})
-endif()
-#=================================================================
-
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/audio.8bit.wav DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/appMain/main_test.cc b/src/appMain/main_test.cc
deleted file mode 100644
index 26da24ce1..000000000
--- a/src/appMain/main_test.cc
+++ /dev/null
@@ -1,61 +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.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "config_profile/profile.h"
-#include "utils/logger.h"
-
-#ifdef __cplusplus
-extern "C" void __gcov_flush();
-#endif
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
-
- profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
- INIT_LOGGER("log4cxx.properties");
-
- int result = RUN_ALL_TESTS();
-
-#if defined(__cplusplus) and defined(GCOV_ENABLED)
- __gcov_flush();
-#endif
-
- sleep(2);
- DEINIT_LOGGER();
- return result;
-}
diff --git a/src/components/media_manager/CMakeLists.txt b/src/components/media_manager/CMakeLists.txt
index 532cb8cd4..a01ab852b 100644
--- a/src/components/media_manager/CMakeLists.txt
+++ b/src/components/media_manager/CMakeLists.txt
@@ -46,8 +46,6 @@ set(LIBRARIES
endif()
include_directories (
- /home/vagrant/Work/GIT/applink/src/3rd_party-static/gmock-1.7.0/include
- /home/vagrant/Work/GIT/applink/src/3rd_party-static/gmock-1.7.0/gtest/include
./include
./include/audio/
./include/video/
@@ -77,22 +75,3 @@ set (SOURCES
add_library("MediaManager" ${SOURCES} ${default_sources})
target_link_libraries("MediaManager" ${LIBRARIES})
-
-#======================= Unit-Test section =======================
-if(BUILD_TESTS)
- include_directories (
- ../../3rd_party-static/gmock-1.7.0/include
- ../../3rd_party-static/gmock-1.7.0/gtest/include)
-
- set(testSources
- ./src/main.cc
- ./src/media_adapter_impl_test.cc)
-
- set(testLibraries
- gmock
- gtest)
-
- add_executable(media_manager_test ${testSources})
- target_link_libraries(media_manager_test ${testLibraries})
-endif()
-#=================================================================
diff --git a/src/components/media_manager/src/main.cc b/src/components/media_manager/src/main.cc
deleted file mode 100755
index 59fa20e8b..000000000
--- a/src/components/media_manager/src/main.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "gmock/gmock.h"
-
-int main(int argc, char** argv) {
- testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
diff --git a/src/components/utils/CMakeLists.txt b/src/components/utils/CMakeLists.txt
index 74b798692..5b446f00f 100644
--- a/src/components/utils/CMakeLists.txt
+++ b/src/components/utils/CMakeLists.txt
@@ -52,24 +52,3 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries("Utils" pthread ${RTLIB})
endif()
-
-#======================= Unit-Test section =======================
-if(BUILD_TESTS)
- include_directories (
- ../../3rd_party-static/gmock-1.7.0/include
- ../../3rd_party-static/gmock-1.7.0/gtest/include)
-
- set(testSources
- ./src/main.cc
- ./src/file_system_test.cc
- ./src/date_time_test.cc)
-
- set(testLibraries
- gmock
- gtest
- Utils)
-
- add_executable(utils_test ${testSources})
- target_link_libraries(utils_test ${testLibraries})
-endif()
-#=================================================================
diff --git a/src/components/utils/src/date_time_test.cc b/src/components/utils/src/date_time_test.cc
deleted file mode 100644
index 749a634f6..000000000
--- a/src/components/utils/src/date_time_test.cc
+++ /dev/null
@@ -1,128 +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.
-*/
-
-#include <unistd.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "utils/date_time.h"
-
-namespace test {
-namespace components {
-namespace utils {
-
-TEST(DateTimeTest, GetCurrentTime) {
- const TimevalStruct time1 = date_time::DateTime::getCurrentTime();
- ASSERT_NE(0, time1.tv_sec);
- ASSERT_GE(time1.tv_usec, 0);
-
- const TimevalStruct time2 = date_time::DateTime::getCurrentTime();
- ASSERT_NE(0, time2.tv_sec);
- ASSERT_GE(time2.tv_usec, 0);
- ASSERT_GE(time2.tv_sec, time1.tv_sec);
-}
-
-TEST(DateTimeTest, GetmSecs) {
- TimevalStruct time;
- time.tv_sec = 1;
- time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
-
- ASSERT_EQ(time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND +
- time.tv_usec / date_time::DateTime::MICROSECONDS_IN_MILLISECONDS,
- date_time::DateTime::getmSecs(time));
-}
-
-TEST(DateTimeTest, GetuSecs) {
- TimevalStruct time;
- time.tv_sec = 3;
- time.tv_usec = 4;
-
- ASSERT_EQ(time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND *
- date_time::DateTime::MICROSECONDS_IN_MILLISECONDS + time.tv_usec,
- date_time::DateTime::getuSecs(time));
-}
-
-TEST(DateTimeTest, GetuSecsmSecs) {
- TimevalStruct time;
- time.tv_sec = 5;
- time.tv_usec = 6;
-
- ASSERT_EQ( date_time::DateTime::getmSecs(time),
- date_time::DateTime::getuSecs(time) / date_time::DateTime::MICROSECONDS_IN_MILLISECONDS);
-}
-
-TEST(DateTimeTest, CalculateTimeSpan) {
- const TimevalStruct time = date_time::DateTime::getCurrentTime();
-
- const uint32_t sleep_time_mSec = 10;
- usleep(sleep_time_mSec * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS);
-
- ASSERT_GE(date_time::DateTime::calculateTimeSpan(time),
- sleep_time_mSec);
-}
-
-TEST(DateTimeTest, CalculateTimeDiff) {
- TimevalStruct time1;
- time1.tv_sec = 1;
- time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
-
- TimevalStruct time2;
- time2.tv_sec = 3;
- time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
-
- //time2 to time1
- TimevalStruct diff1;
- diff1.tv_sec = time2.tv_sec - time1.tv_sec;
- diff1.tv_usec = time2.tv_usec - time1.tv_usec;
-
- const int64_t mSecDiff = static_cast<int64_t>(diff1.tv_sec) * 1000
- + diff1.tv_usec / 1000;
-
- ASSERT_EQ(mSecDiff,
- date_time::DateTime::calculateTimeDiff(time2, time1));
-
- //time1 to time2
- TimevalStruct diff2;
- diff2.tv_sec = time1.tv_sec - time2.tv_sec;
- diff2.tv_usec = time1.tv_usec - time2.tv_usec;
-
- const int64_t mSecDiff2 = static_cast<int64_t>(diff2.tv_sec) * 1000
- + diff2.tv_usec / 1000;
-
- ASSERT_EQ(mSecDiff2,
- date_time::DateTime::calculateTimeDiff(time1, time2));
-}
-
-} // namespace utils
-} // namespace components
-} // namespace test
diff --git a/src/components/utils/src/file_system_test.cc b/src/components/utils/src/file_system_test.cc
deleted file mode 100644
index abf09735b..000000000
--- a/src/components/utils/src/file_system_test.cc
+++ /dev/null
@@ -1,111 +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.
- */
-
-#include "gmock/gmock.h"
-#include "utils/file_system.h"
-
-namespace test {
-namespace components {
-namespace utils {
-
-TEST(FileSystemTest, CommonFileSystemTest) {
- // Directory creation
- ASSERT_FALSE(file_system::DirectoryExists("./Test directory"));
-
- file_system::CreateDirectory("./Test directory");
-
- ASSERT_TRUE(file_system::DirectoryExists("./Test directory"));
-
- ASSERT_TRUE(file_system::IsDirectory("./Test directory"));
-
- // File creation
- ASSERT_FALSE(file_system::FileExists("./Test directory/test file"));
-
- std::vector<unsigned char> data;
- data.push_back('t');
- data.push_back('e');
- data.push_back('s');
- data.push_back('t');
-
- ASSERT_TRUE(file_system::Write("./Test directory/test file", data));
-
- ASSERT_TRUE(file_system::FileExists("./Test directory/test file"));
-
- ASSERT_FALSE(file_system::IsDirectory("./Test directory/test file"));
-
- // Read data from file
- std::vector<unsigned char> result;
-
- ASSERT_TRUE(file_system::ReadBinaryFile("./Test directory/test file",
- result));
- ASSERT_FALSE(result.empty());
-
- // list files
- ASSERT_TRUE(file_system::Write("./Test directory/test file 2", data));
-
- std::vector<std::string> list;
- list = file_system::ListFiles("./Test directory");
-
- ASSERT_FALSE(list.empty());
- std::sort(list.begin(), list.end());
- ASSERT_EQ("test file", list[0]);
- ASSERT_EQ("test file 2", list[1]);
-
- // Delete file
- ASSERT_TRUE(file_system::FileExists("./Test directory/test file 2"));
- ASSERT_TRUE(file_system::DeleteFile("./Test directory/test file 2"));
- ASSERT_FALSE(file_system::FileExists("./Test directory/test file 2"));
-
- // Delete empty directory
- file_system::CreateDirectory("./Test directory/Empty directory");
-
- ASSERT_TRUE(file_system::DirectoryExists(
- "./Test directory/Empty directory"));
- ASSERT_TRUE(file_system::RemoveDirectory(
- "./Test directory/Empty directory", false));
- ASSERT_FALSE(file_system::DirectoryExists(
- "./Test directory/Empty directory"));
-
- ASSERT_FALSE(file_system::RemoveDirectory("./Test directory", false));
- ASSERT_TRUE(file_system::DirectoryExists("./Test directory"));
-
- // Delete directory recursively
- file_system::CreateDirectory("./Test directory/Test directory 2");
- ASSERT_TRUE(file_system::Write(
- "./Test directory/Test directory 2/test file 2", data));
- ASSERT_TRUE(file_system::RemoveDirectory("./Test directory", true));
-
- ASSERT_FALSE(file_system::DirectoryExists("./Test directory"));
-}
-} // namespace utils
-} // namespace components
-} // namespace test
diff --git a/src/components/utils/src/main.cc b/src/components/utils/src/main.cc
deleted file mode 100755
index 59fa20e8b..000000000
--- a/src/components/utils/src/main.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "gmock/gmock.h"
-
-int main(int argc, char** argv) {
- testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
diff --git a/test/components/utils/CMakeLists.txt b/test/components/utils/CMakeLists.txt
index c1e95550d..b7acf6d56 100644
--- a/test/components/utils/CMakeLists.txt
+++ b/test/components/utils/CMakeLists.txt
@@ -14,6 +14,8 @@ set(LIBRARIES
)
set(SOURCES
+ ./src/file_system_tests.cc
+ ./src/data_time_tests.cc
./src/prioritized_queue_tests.cc
)
diff --git a/test/components/utils/include/utils/data_time_tests.h b/test/components/utils/include/utils/data_time_tests.h
new file mode 100644
index 000000000..abb760f4f
--- /dev/null
+++ b/test/components/utils/include/utils/data_time_tests.h
@@ -0,0 +1,127 @@
+/*
+* 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 DATA_TIME_TESTS_H
+#define DATA_TIME_TESTS_H
+
+#include <unistd.h>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "utils/date_time.h"
+
+namespace test {
+namespace components {
+namespace utils {
+ TEST(DateTimeTest, GetCurrentTime) {
+ const TimevalStruct time1 = date_time::DateTime::getCurrentTime();
+ ASSERT_NE(0, time1.tv_sec);
+ ASSERT_GE(time1.tv_usec, 0);
+
+ const TimevalStruct time2 = date_time::DateTime::getCurrentTime();
+ ASSERT_NE(0, time2.tv_sec);
+ ASSERT_GE(time2.tv_usec, 0);
+ ASSERT_GE(time2.tv_sec, time1.tv_sec);
+ }
+
+ TEST(DateTimeTest, GetmSecs) {
+ TimevalStruct time;
+ time.tv_sec = 1;
+ time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
+
+ ASSERT_EQ(time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND +
+ time.tv_usec / date_time::DateTime::MICROSECONDS_IN_MILLISECONDS,
+ date_time::DateTime::getmSecs(time));
+ }
+ TEST(DateTimeTest, GetuSecs) {
+ TimevalStruct time;
+ time.tv_sec = 3;
+ time.tv_usec = 4;
+
+ ASSERT_EQ(time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND *
+ date_time::DateTime::MICROSECONDS_IN_MILLISECONDS + time.tv_usec,
+ date_time::DateTime::getuSecs(time));
+ }
+ TEST(DateTimeTest, GetuSecsmSecs) {
+ TimevalStruct time;
+ time.tv_sec = 5;
+ time.tv_usec = 6;
+
+ ASSERT_EQ( date_time::DateTime::getmSecs(time),
+ date_time::DateTime::getuSecs(time) / date_time::DateTime::MICROSECONDS_IN_MILLISECONDS);
+ }
+
+ TEST(DateTimeTest, CalculateTimeSpan) {
+ const TimevalStruct time = date_time::DateTime::getCurrentTime();
+
+ const uint32_t sleep_time_mSec = 10;
+ usleep(sleep_time_mSec * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS);
+
+ ASSERT_GE(date_time::DateTime::calculateTimeSpan(time),
+ sleep_time_mSec);
+ }
+
+ TEST(DateTimeTest, CalculateTimeDiff) {
+ TimevalStruct time1;
+ time1.tv_sec = 1;
+ time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
+
+ TimevalStruct time2;
+ time2.tv_sec = 3;
+ time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECONDS;
+
+ //time2 to time1
+ TimevalStruct diff1;
+ diff1.tv_sec = time2.tv_sec - time1.tv_sec;
+ diff1.tv_usec = time2.tv_usec - time1.tv_usec;
+
+ const int64_t mSecDiff = static_cast<int64_t>(diff1.tv_sec) * 1000
+ + diff1.tv_usec / 1000;
+
+ ASSERT_EQ(mSecDiff,
+ date_time::DateTime::calculateTimeDiff(time2, time1));
+
+ //time1 to time2
+ TimevalStruct diff2;
+ diff2.tv_sec = time1.tv_sec - time2.tv_sec;
+ diff2.tv_usec = time1.tv_usec - time2.tv_usec;
+
+ const int64_t mSecDiff2 = static_cast<int64_t>(diff2.tv_sec) * 1000
+ + diff2.tv_usec / 1000;
+
+ ASSERT_EQ(mSecDiff2,
+ date_time::DateTime::calculateTimeDiff(time1, time2));
+ }
+} // namespace utils
+} // namespace components
+} // namespace test
+#endif // DATA_TIME_TESTS_H
diff --git a/test/components/utils/include/utils/file_system_tests.h b/test/components/utils/include/utils/file_system_tests.h
new file mode 100644
index 000000000..aefca92f3
--- /dev/null
+++ b/test/components/utils/include/utils/file_system_tests.h
@@ -0,0 +1,115 @@
+// Copyright (c) 2013, 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_UTILS_INCLUDE_REQUEST_UTILS_FILE_SYSTEM_TESTS_H_
+#define TEST_COMPONENTS_UTILS_INCLUDE_REQUEST_UTILS_FILE_SYSTEM_TESTS_H_
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "utils/file_system.h"
+
+namespace test {
+namespace components {
+namespace utils {
+ TEST(FileSystemTest, CommonFileSystemTest) {
+ // Directory creation
+ ASSERT_FALSE(file_system::DirectoryExists("./Test directory"));
+
+ file_system::CreateDirectory("./Test directory");
+
+ ASSERT_TRUE(file_system::DirectoryExists("./Test directory"));
+
+ ASSERT_TRUE(file_system::IsDirectory("./Test directory"));
+
+ // File creation
+ ASSERT_FALSE(file_system::FileExists("./Test directory/test file"));
+
+ std::vector<unsigned char> data;
+ data.push_back('t');
+ data.push_back('e');
+ data.push_back('s');
+ data.push_back('t');
+
+ ASSERT_TRUE(file_system::Write("./Test directory/test file", data));
+
+ ASSERT_TRUE(file_system::FileExists("./Test directory/test file"));
+
+ ASSERT_FALSE(file_system::IsDirectory("./Test directory/test file"));
+
+ // Read data from file
+ std::vector<unsigned char> result;
+
+ ASSERT_TRUE(file_system::ReadBinaryFile("./Test directory/test file",
+ result));
+ ASSERT_FALSE(result.empty());
+
+ // list files
+ ASSERT_TRUE(file_system::Write("./Test directory/test file 2", data));
+
+ std::vector<std::string> list;
+ list = file_system::ListFiles("./Test directory");
+
+ ASSERT_FALSE(list.empty());
+ std::sort(list.begin(), list.end());
+ ASSERT_EQ("test file", list[0]);
+ ASSERT_EQ("test file 2", list[1]);
+
+ // Delete file
+ ASSERT_TRUE(file_system::FileExists("./Test directory/test file 2"));
+ ASSERT_TRUE(file_system::DeleteFile("./Test directory/test file 2"));
+ ASSERT_FALSE(file_system::FileExists("./Test directory/test file 2"));
+
+ // Delete empty directory
+ file_system::CreateDirectory("./Test directory/Empty directory");
+
+ ASSERT_TRUE(file_system::DirectoryExists(
+ "./Test directory/Empty directory"));
+ ASSERT_TRUE(file_system::RemoveDirectory(
+ "./Test directory/Empty directory", false));
+ ASSERT_FALSE(file_system::DirectoryExists(
+ "./Test directory/Empty directory"));
+
+ ASSERT_FALSE(file_system::RemoveDirectory("./Test directory", false));
+ ASSERT_TRUE(file_system::DirectoryExists("./Test directory"));
+
+ // Delete directory recursively
+ file_system::CreateDirectory("./Test directory/Test directory 2");
+ ASSERT_TRUE(file_system::Write(
+ "./Test directory/Test directory 2/test file 2", data));
+ ASSERT_TRUE(file_system::RemoveDirectory("./Test directory", true));
+
+ ASSERT_FALSE(file_system::DirectoryExists("./Test directory"));
+ }
+} // namespace utils
+} // namespace components
+} // namespace test
+
+#endif //TEST_COMPONENTS_UTILS_INCLUDE_REQUEST_UTILS_FILE_SYSTEM_TESTS_H_
diff --git a/src/components/media_manager/src/media_adapter_impl_test.cc b/test/components/utils/src/data_time_tests.cc
index f6a6ffa51..daa3e650b 100644
--- a/src/components/media_manager/src/media_adapter_impl_test.cc
+++ b/test/components/utils/src/data_time_tests.cc
@@ -29,9 +29,4 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include "gmock/gmock.h"
-
-TEST(MediaAdapterImplTest, DummyTest) {
- ASSERT_TRUE(true);
-}
+#include "utils/data_time_tests.h"
diff --git a/test/components/utils/src/file_system_tests.cc b/test/components/utils/src/file_system_tests.cc
new file mode 100644
index 000000000..107b7092b
--- /dev/null
+++ b/test/components/utils/src/file_system_tests.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2013, 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 "utils/file_system_tests.h"