OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/ipc/service/gpu_vsync_provider.h" | 5 #include "gpu/ipc/service/gpu_vsync_provider.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 window); | 58 window); |
59 | 59 |
60 constexpr base::TimeDelta wait_timeout = | 60 constexpr base::TimeDelta wait_timeout = |
61 base::TimeDelta::FromMilliseconds(300); | 61 base::TimeDelta::FromMilliseconds(300); |
62 | 62 |
63 // Verify that there are no VSync signals before provider is enabled | 63 // Verify that there are no VSync signals before provider is enabled |
64 bool wait_result = vsync_event_.TimedWait(wait_timeout); | 64 bool wait_result = vsync_event_.TimedWait(wait_timeout); |
65 EXPECT_FALSE(wait_result); | 65 EXPECT_FALSE(wait_result); |
66 EXPECT_EQ(0, vsync_count()); | 66 EXPECT_EQ(0, vsync_count()); |
67 | 67 |
68 provider->EnableVSync(true); | 68 provider->SetNeedsVSync(true); |
69 | 69 |
70 vsync_event_.Wait(); | 70 vsync_event_.Wait(); |
71 | 71 |
72 provider->EnableVSync(false); | 72 provider->SetNeedsVSync(false); |
73 | 73 |
74 // Verify that VSync callbacks stop coming after disabling. | 74 // Verify that VSync callbacks stop coming after disabling. |
75 // Please note that it might still be possible for one | 75 // Please note that it might still be possible for one |
76 // callback to be in flight on VSync worker thread, so |vsync_count_| | 76 // callback to be in flight on VSync worker thread, so |vsync_count_| |
77 // could still be incremented once, but not enough times to trigger | 77 // could still be incremented once, but not enough times to trigger |
78 // |vsync_event_|. | 78 // |vsync_event_|. |
79 reset_vsync_count(); | 79 reset_vsync_count(); |
80 wait_result = vsync_event_.TimedWait(wait_timeout); | 80 wait_result = vsync_event_.TimedWait(wait_timeout); |
81 EXPECT_FALSE(wait_result); | 81 EXPECT_FALSE(wait_result); |
82 } | 82 } |
83 | 83 |
84 } // namespace gpu | 84 } // namespace gpu |
OLD | NEW |