usingnamespace mozilla; usingnamespace mozilla::gfx; usingnamespace mozilla::layers; using ::testing::_;
// Timeout for vsync events to occur in milliseconds // Windows 8.1 has intermittents at 50 ms. Raise limit to 5 vsync intervals. constint kVsyncTimeoutMS = 80;
class TestVsyncObserver : public VsyncObserver {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TestVsyncObserver, override)
staticvoid FlushMainThreadLoop() { // Some tasks are pushed onto the main thread when adding vsync observers // This function will ensure all tasks are executed on the main thread // before returning.
nsCOMPtr<nsIThread> mainThread;
nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread));
ASSERT_NS_SUCCEEDED(rv);
// Tests that we can enable/disable vsync notifications
TEST_F(VsyncTester, EnableVsync) {
mVsyncSource->DisableVsync();
ASSERT_FALSE(mVsyncSource->IsVsyncEnabled());
// Test that if we have vsync enabled, the source should get vsync // notifications
TEST_F(VsyncTester, CompositorGetVsyncNotifications) {
mVsyncSource->DisableVsync();
ASSERT_FALSE(mVsyncSource->IsVsyncEnabled());
RefPtr<CompositorVsyncDispatcher> vsyncDispatcher = new CompositorVsyncDispatcher(mVsyncDispatcher);
RefPtr<TestVsyncObserver> testVsyncObserver = new TestVsyncObserver();
// Test that child refresh vsync observers get vsync notifications
TEST_F(VsyncTester, ChildRefreshDriverGetVsyncNotifications) {
mVsyncSource->DisableVsync();
ASSERT_FALSE(mVsyncSource->IsVsyncEnabled());
ASSERT_TRUE(mVsyncDispatcher != nullptr);
RefPtr<TestVsyncObserver> testVsyncObserver = new TestVsyncObserver();
mVsyncDispatcher->AddVsyncObserver(testVsyncObserver);
ASSERT_TRUE(mVsyncSource->IsVsyncEnabled());
// Test that we can read the vsync rate
TEST_F(VsyncTester, VsyncSourceHasVsyncRate) {
TimeDuration vsyncRate = mVsyncSource->GetVsyncRate();
ASSERT_NE(vsyncRate, TimeDuration::Forever());
ASSERT_GT(vsyncRate.ToMilliseconds(), 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.