123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #define LOG_TAG "audio_utils_powerlog_tests"
- #include <audio_utils/PowerLog.h>
- #include <gtest/gtest.h>
- #include <iostream>
- #include <log/log.h>
- using namespace android;
- static size_t countNewLines(const std::string &s) {
- return std::count(s.begin(), s.end(), '\n');
- }
- TEST(audio_utils_powerlog, basic) {
- auto plog = std::make_unique<PowerLog>(
- 48000 ,
- 1 ,
- AUDIO_FORMAT_PCM_16_BIT,
- 100 ,
- 1 );
-
- EXPECT_EQ((size_t)1, countNewLines(plog->dumpToString()));
- const int16_t zero = 0;
- const int16_t half = 0x4000;
- plog->log(&half, 1 , 0 );
- plog->log(&half, 1 , 1 );
- plog->log(&half, 1 , 2 );
-
- EXPECT_EQ((size_t)2, countNewLines(plog->dumpToString()));
- plog->log(&zero, 1 , 3 );
-
- EXPECT_EQ((size_t)2, countNewLines(plog->dumpToString()));
-
- plog->log(&half, 1 , 4 );
- EXPECT_EQ((size_t)3, countNewLines(plog->dumpToString()));
-
- EXPECT_EQ((size_t)2, countNewLines(plog->dumpToString(
- "" , 2 )));
-
- EXPECT_EQ((size_t)3, countNewLines(plog->dumpToString(
- "" , 0 , 2 )));
- EXPECT_EQ((size_t)2, countNewLines(plog->dumpToString(
- "" , 0 , 3 )));
- plog->dump(0 );
-
-
-
- }
- TEST(audio_utils_powerlog, c) {
- power_log_t *power_log = power_log_create(
- 48000 ,
- 1 ,
- AUDIO_FORMAT_PCM_16_BIT,
- 100 ,
- 1 );
-
- const int16_t zero = 0;
- const int16_t quarter = 0x2000;
- power_log_log(power_log, &quarter, 1 , 0 );
- power_log_log(power_log, &zero, 1 , 1 );
- power_log_dump(power_log, 0 , " " , 0 , 0 );
- power_log_destroy(power_log);
-
-
-
- }
|