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

Side by Side Diff: content/browser/renderer_host/compositor_resize_lock_unittest.cc

Issue 2790623003: ui: Rework CompositorResizeLock interaction with DelegatedFrameHost (Closed)
Patch Set: shouldskip: allowskipafterframe Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/renderer_host/compositor_resize_lock.h" 5 #include "content/browser/renderer_host/compositor_resize_lock.h"
6 6
7 #include "base/bind.h"
8 #include "base/callback.h"
7 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/compositor/test/fake_compositor_lock.h" 11 #include "ui/compositor/test/fake_compositor_lock.h"
10 12
11 namespace content { 13 namespace content {
12 namespace { 14 namespace {
13 15
14 class FakeCompositorResizeLockClient 16 class FakeCompositorResizeLockClient
15 : public CompositorResizeLockClient, 17 : public CompositorResizeLockClient,
16 public NON_EXPORTED_BASE(ui::CompositorLockDelegate) { 18 public NON_EXPORTED_BASE(ui::CompositorLockDelegate) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_TRUE(resize_client.created()); 124 EXPECT_TRUE(resize_client.created());
123 EXPECT_FALSE(resize_client.ended()); 125 EXPECT_FALSE(resize_client.ended());
124 126
125 // A timeout tells the client that the lock ended. 127 // A timeout tells the client that the lock ended.
126 resize_client.CauseTimeout(); 128 resize_client.CauseTimeout();
127 EXPECT_TRUE(resize_client.unlocked()); 129 EXPECT_TRUE(resize_client.unlocked());
128 EXPECT_TRUE(resize_client.ended()); 130 EXPECT_TRUE(resize_client.ended());
129 } 131 }
130 } 132 }
131 133
134 class CallbackClient : public FakeCompositorResizeLockClient {
135 public:
136 CallbackClient() = default;
137
138 void CompositorResizeLockEnded() override {
139 std::move(resize_lock_ended_).Run();
140 }
141
142 void set_resize_lock_ended(base::OnceClosure c) {
143 resize_lock_ended_ = std::move(c);
144 }
145
146 private:
147 base::OnceClosure resize_lock_ended_;
148 };
149
150 TEST(CompositorResizeLockTest, TimeoutSetBeforeClientTold) {
151 CallbackClient resize_client;
152 gfx::Size resize_to(10, 11);
153
154 {
155 CompositorResizeLock resize_lock(&resize_client, resize_to);
156 resize_lock.Lock();
157
158 // When the resize lock times out, it should report that before telling
159 // the client about that.
160 bool saw_resize_lock_end = false;
161 auto resize_lock_ended = [](CompositorResizeLock* resize_lock, bool* saw) {
162 EXPECT_TRUE(resize_lock->timed_out());
163 *saw = true;
164 };
165 resize_client.set_resize_lock_ended(
166 base::BindOnce(resize_lock_ended, &resize_lock, &saw_resize_lock_end));
167
168 // A timeout tells the client that the lock ended.
169 resize_client.CauseTimeout();
170 EXPECT_TRUE(saw_resize_lock_end);
171 }
172 }
173
132 } // namespace 174 } // namespace
133 } // namespace content 175 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_resize_lock.cc ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698