diff options
author | Lajos Molnar <lajos@google.com> | 2014-10-02 16:31:16 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-10-02 16:31:16 -0700 |
commit | f973c881e3f3c1cbb91e4eb0e65f57bb23ed5758 (patch) | |
tree | 4e2b0c2d49c48db5d2ad5a1ddea0734386b2c68c /media/libstagefright/tests | |
parent | d7bdfd7d33789965988079e3a03ec1233f1f5896 (diff) | |
parent | 55fc6a77f5c6e26627098dc5257fcf9b605967ef (diff) | |
download | frameworks_av-f973c881e3f3c1cbb91e4eb0e65f57bb23ed5758.zip frameworks_av-f973c881e3f3c1cbb91e4eb0e65f57bb23ed5758.tar.gz frameworks_av-f973c881e3f3c1cbb91e4eb0e65f57bb23ed5758.tar.bz2 |
resolved conflicts for merge of 55fc6a77 to lmp-mr1-dev-plus-aosp
Change-Id: I6bff1d0d214132cbafda081a39016b5b11730865
Diffstat (limited to 'media/libstagefright/tests')
-rw-r--r-- | media/libstagefright/tests/Android.mk | 29 | ||||
-rw-r--r-- | media/libstagefright/tests/Utils_test.cpp | 101 |
2 files changed, 129 insertions, 1 deletions
diff --git a/media/libstagefright/tests/Android.mk b/media/libstagefright/tests/Android.mk index 724d444..8d6ff5b 100644 --- a/media/libstagefright/tests/Android.mk +++ b/media/libstagefright/tests/Android.mk @@ -8,7 +8,7 @@ LOCAL_MODULE := SurfaceMediaSource_test LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := \ - SurfaceMediaSource_test.cpp \ + SurfaceMediaSource_test.cpp \ DummyRecorder.cpp \ LOCAL_SHARED_LIBRARIES := \ @@ -35,6 +35,33 @@ LOCAL_32_BIT_ONLY := true include $(BUILD_NATIVE_TEST) + +include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk + +LOCAL_MODULE := Utils_test + +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := \ + Utils_test.cpp \ + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + liblog \ + libmedia \ + libstagefright \ + libstagefright_foundation \ + libstagefright_omx \ + +LOCAL_C_INCLUDES := \ + frameworks/av/include \ + frameworks/av/media/libstagefright \ + frameworks/av/media/libstagefright/include \ + $(TOP)/frameworks/native/include/media/openmax \ + +include $(BUILD_NATIVE_TEST) + # Include subdirectory makefiles # ============================================================ diff --git a/media/libstagefright/tests/Utils_test.cpp b/media/libstagefright/tests/Utils_test.cpp new file mode 100644 index 0000000..f2825dd --- /dev/null +++ b/media/libstagefright/tests/Utils_test.cpp @@ -0,0 +1,101 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "Utils_test" + +#include <gtest/gtest.h> +#include <utils/String8.h> +#include <utils/Errors.h> +#include <fcntl.h> +#include <unistd.h> + +#include <media/stagefright/foundation/ADebug.h> +#include <media/stagefright/foundation/AUtils.h> +#include <media/stagefright/Utils.h> + +namespace android { + +class UtilsTest : public ::testing::Test { +}; + +TEST_F(UtilsTest, TestFourCC) { + ASSERT_EQ(FOURCC('s', 't', 'm' , 'u'), 'stmu'); +} + +TEST_F(UtilsTest, TestMathTemplates) { + ASSERT_EQ(divRound(-10, -4), 3); + ASSERT_EQ(divRound(-11, -4), 3); + ASSERT_EQ(divRound(-12, -4), 3); + ASSERT_EQ(divRound(-13, -4), 3); + ASSERT_EQ(divRound(-14, -4), 4); + + ASSERT_EQ(divRound(10, -4), -3); + ASSERT_EQ(divRound(11, -4), -3); + ASSERT_EQ(divRound(12, -4), -3); + ASSERT_EQ(divRound(13, -4), -3); + ASSERT_EQ(divRound(14, -4), -4); + + ASSERT_EQ(divRound(-10, 4), -3); + ASSERT_EQ(divRound(-11, 4), -3); + ASSERT_EQ(divRound(-12, 4), -3); + ASSERT_EQ(divRound(-13, 4), -3); + ASSERT_EQ(divRound(-14, 4), -4); + + ASSERT_EQ(divRound(10, 4), 3); + ASSERT_EQ(divRound(11, 4), 3); + ASSERT_EQ(divRound(12, 4), 3); + ASSERT_EQ(divRound(13, 4), 3); + ASSERT_EQ(divRound(14, 4), 4); + + ASSERT_EQ(divUp(-11, -4), 3); + ASSERT_EQ(divUp(-12, -4), 3); + ASSERT_EQ(divUp(-13, -4), 4); + + ASSERT_EQ(divUp(11, -4), -2); + ASSERT_EQ(divUp(12, -4), -3); + ASSERT_EQ(divUp(13, -4), -3); + + ASSERT_EQ(divUp(-11, 4), -2); + ASSERT_EQ(divUp(-12, 4), -3); + ASSERT_EQ(divUp(-13, 4), -3); + + ASSERT_EQ(divUp(11, 4), 3); + ASSERT_EQ(divUp(12, 4), 3); + ASSERT_EQ(divUp(13, 4), 4); + + ASSERT_EQ(abs(5L), 5L); + ASSERT_EQ(abs(-25), 25); + + ASSERT_EQ(min(5.6f, 6.0f), 5.6f); + ASSERT_EQ(min(6.0f, 5.6f), 5.6f); + ASSERT_EQ(min(-4.3, 8.6), -4.3); + ASSERT_EQ(min(8.6, -4.3), -4.3); + + ASSERT_EQ(max(5.6f, 6.0f), 6.0f); + ASSERT_EQ(max(6.0f, 5.6f), 6.0f); + ASSERT_EQ(max(-4.3, 8.6), 8.6); + ASSERT_EQ(max(8.6, -4.3), 8.6); + + ASSERT_EQ(periodicError(124, 100), 24); + ASSERT_EQ(periodicError(288, 100), 12); + ASSERT_EQ(periodicError(-345, 100), 45); + ASSERT_EQ(periodicError(-493, 100), 7); + ASSERT_EQ(periodicError(-550, 100), 50); + ASSERT_EQ(periodicError(-600, 100), 0); +} + +} // namespace android |