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

Side by Side Diff: ui/compositor/layer_unittest.cc

Issue 2444563002: cc: Remove "SwapBuffers" naming from LayerTreeHostSingleThreadClient (Closed)
Patch Set: Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 void OnPaintLayer(const ui::PaintContext& context) override {} 385 void OnPaintLayer(const ui::PaintContext& context) override {}
386 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} 386 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
387 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} 387 void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
388 388
389 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate); 389 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate);
390 }; 390 };
391 391
392 // Remembers if it has been notified. 392 // Remembers if it has been notified.
393 class TestCompositorObserver : public CompositorObserver { 393 class TestCompositorObserver : public CompositorObserver {
394 public: 394 public:
395 TestCompositorObserver() 395 TestCompositorObserver() = default;
396 : committed_(false), started_(false), ended_(false), aborted_(false) {}
397 396
398 bool committed() const { return committed_; } 397 bool committed() const { return committed_; }
399 bool notified() const { return started_ && ended_; } 398 bool notified() const { return started_ && ended_; }
400 bool aborted() const { return aborted_; }
401 399
402 void Reset() { 400 void Reset() {
403 committed_ = false; 401 committed_ = false;
404 started_ = false; 402 started_ = false;
405 ended_ = false; 403 ended_ = false;
406 aborted_ = false;
407 } 404 }
408 405
409 private: 406 private:
410 void OnCompositingDidCommit(Compositor* compositor) override { 407 void OnCompositingDidCommit(Compositor* compositor) override {
411 committed_ = true; 408 committed_ = true;
412 } 409 }
413 410
414 void OnCompositingStarted(Compositor* compositor, 411 void OnCompositingStarted(Compositor* compositor,
415 base::TimeTicks start_time) override { 412 base::TimeTicks start_time) override {
416 started_ = true; 413 started_ = true;
417 } 414 }
418 415
419 void OnCompositingEnded(Compositor* compositor) override { ended_ = true; } 416 void OnCompositingEnded(Compositor* compositor) override { ended_ = true; }
420 417
421 void OnCompositingAborted(Compositor* compositor) override {
422 aborted_ = true;
423 }
424
425 void OnCompositingLockStateChanged(Compositor* compositor) override {} 418 void OnCompositingLockStateChanged(Compositor* compositor) override {}
426 419
427 void OnCompositingShuttingDown(Compositor* compositor) override {} 420 void OnCompositingShuttingDown(Compositor* compositor) override {}
428 421
429 bool committed_; 422 bool committed_ = false;
430 bool started_; 423 bool started_ = false;
431 bool ended_; 424 bool ended_ = false;
432 bool aborted_;
433 425
434 DISALLOW_COPY_AND_ASSIGN(TestCompositorObserver); 426 DISALLOW_COPY_AND_ASSIGN(TestCompositorObserver);
435 }; 427 };
436 428
437 class TestCompositorAnimationObserver : public CompositorAnimationObserver { 429 class TestCompositorAnimationObserver : public CompositorAnimationObserver {
438 public: 430 public:
439 explicit TestCompositorAnimationObserver(ui::Compositor* compositor) 431 explicit TestCompositorAnimationObserver(ui::Compositor* compositor)
440 : compositor_(compositor), 432 : compositor_(compositor),
441 animation_step_count_(0), 433 animation_step_count_(0),
442 shutdown_(false) { 434 shutdown_(false) {
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 // Setting the transform of a layer should alert the observers. 1238 // Setting the transform of a layer should alert the observers.
1247 observer.Reset(); 1239 observer.Reset();
1248 gfx::Transform transform; 1240 gfx::Transform transform;
1249 transform.Translate(200.0, 200.0); 1241 transform.Translate(200.0, 200.0);
1250 transform.Rotate(90.0); 1242 transform.Rotate(90.0);
1251 transform.Translate(-200.0, -200.0); 1243 transform.Translate(-200.0, -200.0);
1252 l2->SetTransform(transform); 1244 l2->SetTransform(transform);
1253 WaitForSwap(); 1245 WaitForSwap();
1254 EXPECT_TRUE(observer.notified()); 1246 EXPECT_TRUE(observer.notified());
1255 1247
1256 // A change resulting in an aborted swap buffer should alert the observer
1257 // and also signal an abort.
1258 observer.Reset();
1259 l2->SetOpacity(0.1f);
1260 GetCompositor()->DidAbortSwapBuffers();
1261 WaitForSwap();
1262 EXPECT_TRUE(observer.notified());
1263 EXPECT_TRUE(observer.aborted());
1264
1265 GetCompositor()->RemoveObserver(&observer); 1248 GetCompositor()->RemoveObserver(&observer);
1266 1249
1267 // Opacity changes should no longer alert the removed observer. 1250 // Opacity changes should no longer alert the removed observer.
1268 observer.Reset(); 1251 observer.Reset();
1269 l2->SetOpacity(0.5f); 1252 l2->SetOpacity(0.5f);
1270 WaitForSwap(); 1253 WaitForSwap();
1271 1254
1272 EXPECT_FALSE(observer.notified()); 1255 EXPECT_FALSE(observer.notified());
1273 } 1256 }
1274 1257
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 root->SetOpacity(0.5f); 2079 root->SetOpacity(0.5f);
2097 WaitForSwap(); 2080 WaitForSwap();
2098 EXPECT_EQ(1u, animation_observer.animation_step_count()); 2081 EXPECT_EQ(1u, animation_observer.animation_step_count());
2099 2082
2100 EXPECT_FALSE(animation_observer.shutdown()); 2083 EXPECT_FALSE(animation_observer.shutdown());
2101 ResetCompositor(); 2084 ResetCompositor();
2102 EXPECT_TRUE(animation_observer.shutdown()); 2085 EXPECT_TRUE(animation_observer.shutdown());
2103 } 2086 }
2104 2087
2105 } // namespace ui 2088 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698