Merge changes I442b7919,Ie5b4ff75

* changes:
  Improve android MediaDrm property latency
  Delay OEMCrypto Termination
This commit is contained in:
Rahul Frias
2020-02-19 15:51:14 +00:00
committed by Android (Google) Code Review
11 changed files with 254 additions and 108 deletions

View File

@@ -8,17 +8,46 @@
namespace wvcdm {
namespace {
// duration in seconds after starting the timer
constexpr uint32_t kTestDuration = 5;
// duration in seconds after test completes, before evaluating the result
constexpr uint32_t kPostTestDuration = 3;
} // namespace
class TestTimerHandler : public TimerHandler {
public:
TestTimerHandler() : timer_events_(0){};
TestTimerHandler() : timer_events_count_(0){};
virtual ~TestTimerHandler(){};
virtual void OnTimerEvent() { timer_events_++; }
virtual void OnTimerEvent() { timer_events_count_++; }
uint32_t timer_events() { return timer_events_; }
uint32_t timer_events_count() { return timer_events_count_; }
private:
uint32_t timer_events_;
protected:
uint32_t timer_events_count_;
};
class TestStopTimerHandler : public TestTimerHandler {
public:
TestStopTimerHandler(uint32_t stop_at_timer_events_count, Timer* timer)
: stop_at_timer_events_count_(stop_at_timer_events_count),
timer_(timer) {}
virtual ~TestStopTimerHandler() {}
virtual void OnTimerEvent() {
if (++timer_events_count_ >= stop_at_timer_events_count_) {
if (timer_ != nullptr) {
timer_->Stop(false);
}
}
}
protected:
uint32_t stop_at_timer_events_count_;
Timer* timer_;
};
TEST(TimerTest, ParametersCheck) {
@@ -29,25 +58,58 @@ TEST(TimerTest, ParametersCheck) {
EXPECT_FALSE(timer.Start(&handler, 0));
}
TEST(TimerTest, TimerCheck) {
TEST(TimerTest, TimerCheck_StopAndWaitForExit) {
TestTimerHandler handler;
Timer timer;
uint32_t duration = 10;
EXPECT_EQ(0u, handler.timer_events());
EXPECT_EQ(0u, handler.timer_events_count());
EXPECT_FALSE(timer.IsRunning());
EXPECT_TRUE(timer.Start(&handler, 1));
EXPECT_TRUE(timer.IsRunning());
sleep(duration);
sleep(kTestDuration);
EXPECT_LE(duration - 1, handler.timer_events());
EXPECT_LE(handler.timer_events(), duration + 1);
timer.Stop();
EXPECT_LE(kTestDuration - 1, handler.timer_events_count());
EXPECT_LE(handler.timer_events_count(), kTestDuration + 1);
timer.Stop(true);
EXPECT_FALSE(timer.IsRunning());
sleep(duration);
sleep(kPostTestDuration);
EXPECT_LE(duration - 1, handler.timer_events());
EXPECT_LE(handler.timer_events(), duration + 1);
EXPECT_LE(kTestDuration - 1, handler.timer_events_count());
EXPECT_LE(handler.timer_events_count(), kTestDuration + 1);
}
TEST(TimerTest, TimerCheck_Stop) {
TestTimerHandler handler;
Timer timer;
EXPECT_EQ(0u, handler.timer_events_count());
EXPECT_FALSE(timer.IsRunning());
EXPECT_TRUE(timer.Start(&handler, 1));
EXPECT_TRUE(timer.IsRunning());
sleep(kTestDuration);
EXPECT_LE(kTestDuration - 1, handler.timer_events_count());
EXPECT_LE(handler.timer_events_count(), kTestDuration + 1);
timer.Stop(false);
sleep(kPostTestDuration);
EXPECT_FALSE(timer.IsRunning());
}
TEST(TimerTest, StopOnTimerThread) {
Timer timer;
TestStopTimerHandler handler(kTestDuration - 2, &timer);
EXPECT_EQ(0u, handler.timer_events_count());
EXPECT_FALSE(timer.IsRunning());
EXPECT_TRUE(timer.Start(&handler, 1));
EXPECT_TRUE(timer.IsRunning());
sleep(kTestDuration + kPostTestDuration);
EXPECT_FALSE(timer.IsRunning());
}
} // namespace wvcdm