Source release 16.2.0

This commit is contained in:
John W. Bruce
2020-04-10 16:13:07 -07:00
parent 1ff9f8588a
commit b830b1d1fb
883 changed files with 509706 additions and 143739 deletions

49
util/test/test_sleep.h Normal file
View File

@@ -0,0 +1,49 @@
// Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine Master
// License Agreement.
//
// TestSleep - Controls sleep and clock adjustment during tests.
//
#ifndef WVCDM_UTIL_TEST_SLEEP_H_
#define WVCDM_UTIL_TEST_SLEEP_H_
#include <stdint.h>
namespace wvcdm {
class TestSleep {
public:
// The callback is called when the clock should be advanced.
class CallBack {
public:
virtual void ElapseTime(int64_t milliseconds) = 0;
protected:
virtual ~CallBack(){};
};
// If real_sleep_ is true, then this sleeps for |seconds| of time.
// If the callback exists, this calls the callback.
static void Sleep(unsigned int seconds);
// If we are using a real clock and a fake clock, then the real clock advances
// a little while we are doing work, but the fake one only advances when we
// sleep. This function advances the fake clock to be in sync with the real
// clock. This function should be called to prevent a slow flaky test from
// failing due to this drift.
static void SyncFakeClock();
static void set_real_sleep(bool real_sleep) { real_sleep_ = real_sleep; }
static void set_callback(CallBack* callback) { callback_ = callback; }
private:
// Controls if the test sleep should use real sleep.
static bool real_sleep_;
// Called when the clock should advance.
static CallBack* callback_;
};
} // namespace wvcdm
#endif // WVCDM_UTIL_TEST_SLEEP_H_