Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1292773003: Queue latency info swap promises in a separate already-active queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compilation Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index e5db8f8a244ee62ecdd86294d156ea7c9d3380a6..bf0b2500ff11ed99f65b10f8d7ca6a81315b65a6 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -3860,7 +3860,6 @@ class TestSwapPromise : public SwapPromise {
void DidSwap(CompositorFrameMetadata* metadata) override {
base::AutoLock lock(result_->lock);
- EXPECT_TRUE(result_->did_activate_called);
EXPECT_FALSE(result_->did_swap_called);
EXPECT_FALSE(result_->did_not_swap_called);
result_->did_swap_called = true;
@@ -3883,6 +3882,72 @@ class TestSwapPromise : public SwapPromise {
TestSwapPromiseResult* result_;
};
+class PinnedLayerTreeSwapPromise : public LayerTreeHostTest {
+ protected:
+ PinnedLayerTreeSwapPromise() {}
+
+ void BeginTest() override {
+ PostSetNextCommitForcesRedrawToMainThread();
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ int frame = host_impl->active_tree()->source_frame_number();
+ if (frame == -1) {
+ host_impl->pending_tree()->QueuePinnedSwapPromise(
+ scoped_ptr<SwapPromise>(
Sami 2015/08/18 11:19:18 nit: make_scoped_ptr
Tobias Sargeant 2015/08/18 13:39:52 Done.
+ new TestSwapPromise(&pinned_pending_swap_promise_result_))
+ .Pass());
+ host_impl->active_tree()->QueuePinnedSwapPromise(
+ scoped_ptr<SwapPromise>(
+ new TestSwapPromise(&pinned_active_swap_promise_result_))
+ .Pass());
+
+ host_impl->pending_tree()->QueueSwapPromise(
+ scoped_ptr<SwapPromise>(
+ new TestSwapPromise(&pending_swap_promise_result_))
+ .Pass());
+ host_impl->active_tree()->QueueSwapPromise(
+ scoped_ptr<SwapPromise>(
+ new TestSwapPromise(&active_swap_promise_result_))
+ .Pass());
+ }
+ }
+
+ void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
+ EndTest();
+ }
+
+ void AfterTest() override {
+ // The pending swap promise should activate and swap.
+ EXPECT_TRUE(pending_swap_promise_result_.did_activate_called);
+ EXPECT_TRUE(pending_swap_promise_result_.did_swap_called);
+
+ // The pinned pending swap promise should activate but neither swap nor fail
+ // to swap.
+ EXPECT_TRUE(pinned_pending_swap_promise_result_.did_activate_called);
+ EXPECT_FALSE(pinned_pending_swap_promise_result_.did_swap_called);
+ EXPECT_FALSE(pinned_pending_swap_promise_result_.did_not_swap_called);
+
+ // The active swap promise should fail to swap (it is cancelled by
+ // the activation of a new frame).
+ EXPECT_FALSE(active_swap_promise_result_.did_activate_called);
+ EXPECT_FALSE(active_swap_promise_result_.did_swap_called);
+ EXPECT_TRUE(active_swap_promise_result_.did_not_swap_called);
+ EXPECT_EQ(active_swap_promise_result_.reason, SwapPromise::SWAP_FAILS);
+
+ // The pinned active swap promise should not activate, but should swap.
+ EXPECT_FALSE(pinned_active_swap_promise_result_.did_activate_called);
+ EXPECT_TRUE(pinned_active_swap_promise_result_.did_swap_called);
+ }
+
+ TestSwapPromiseResult pending_swap_promise_result_,
+ pinned_pending_swap_promise_result_, active_swap_promise_result_,
+ pinned_active_swap_promise_result_;
+};
+
+MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise);
+
class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest {
protected:
LayerTreeHostTestBreakSwapPromise()

Powered by Google App Engine
This is Rietveld 408576698