diff --git a/cobalt/build/cobalt_configuration.py b/cobalt/build/cobalt_configuration.py index e1320ab077c1..ca1c943ea270 100644 --- a/cobalt/build/cobalt_configuration.py +++ b/cobalt/build/cobalt_configuration.py @@ -133,8 +133,7 @@ def GetTestTargets(self): 'media_capture_test', 'media_session_test', 'media_stream_test', - # TODO(b/292030213): Crashes on evergreen - # 'media_test', + 'media_test', 'memory_store_test', 'metrics_test', 'nb_test', diff --git a/cobalt/media/base/cval_stats_test.cc b/cobalt/media/base/cval_stats_test.cc index 673e20cc477f..ceba32024d9a 100644 --- a/cobalt/media/base/cval_stats_test.cc +++ b/cobalt/media/base/cval_stats_test.cc @@ -12,16 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef _WIN32 -#include -#else -#include -#endif +#include "cobalt/media/base/cval_stats.h" #include #include -#include "cobalt/media/base/cval_stats.h" +#include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -33,21 +29,11 @@ const char kCValnameMinimum[] = "Media.SbPlayerCreateTime.Minimum"; const char kPipelineIdentifier[] = "test_pipeline"; -constexpr int kSleepTimeMs = 50; +constexpr SbTime kSleepTime = 50; // 50 microseconds namespace cobalt { namespace media { -namespace { -void sleep_ms(int ms) { -#ifdef _WIN32 - Sleep(ms); -#else - usleep(ms); -#endif -} -} // namespace - TEST(MediaCValStatsTest, InitiallyEmpty) { base::CValManager* cvm = base::CValManager::GetInstance(); EXPECT_TRUE(cvm); @@ -71,7 +57,8 @@ TEST(MediaCValStatsTest, NothingRecorded) { CValStats cval_stats_; cval_stats_.StartTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); - sleep_ms(kSleepTimeMs); + SbThreadSleep(kSleepTime); + cval_stats_.StopTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); base::Optional result = @@ -88,7 +75,7 @@ TEST(MediaCValStatsTest, EnableRecording) { cval_stats_.Enable(true); cval_stats_.StartTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); - sleep_ms(kSleepTimeMs); + SbThreadSleep(kSleepTime); cval_stats_.StopTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); base::Optional result = @@ -114,7 +101,7 @@ TEST(MediaCValStatsTest, DontGenerateHistoricalData) { for (int i = 0; i < kMediaDefaultMaxSamplesBeforeCalculation - 1; i++) { cval_stats_.StartTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); - sleep_ms(kSleepTimeMs); + SbThreadSleep(kSleepTime); cval_stats_.StopTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); } @@ -141,7 +128,7 @@ TEST(MediaCValStatsTest, GenerateHistoricalData) { for (int i = 0; i < kMediaDefaultMaxSamplesBeforeCalculation; i++) { cval_stats_.StartTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); - sleep_ms(kSleepTimeMs); + SbThreadSleep(kSleepTime); cval_stats_.StopTimer(MediaTiming::SbPlayerCreate, kPipelineIdentifier); }