throughput_tracker_unittest.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/test/bind.h"
  5. #include "ui/compositor/compositor.h"
  6. #include "ui/compositor/layer.h"
  7. #include "ui/compositor/layer_animator.h"
  8. #include "ui/compositor/test/animation_throughput_reporter_test_base.h"
  9. #include "ui/compositor/test/throughput_report_checker.h"
  10. namespace ui {
  11. using ThroughputReporterTest = AnimationThroughputReporterTestBase;
  12. TEST_F(ThroughputReporterTest, ThreadCheck) {
  13. Layer layer;
  14. root_layer()->Add(&layer);
  15. LayerAnimator* animator = new LayerAnimator(base::Milliseconds(32));
  16. layer.SetAnimator(animator);
  17. ThroughputReportChecker checker(this);
  18. auto once_callback = checker.once_callback();
  19. ui::Compositor* c = compositor();
  20. auto callback = [&](const cc::FrameSequenceMetrics::CustomReportData& data) {
  21. c->ScheduleDraw();
  22. std::move(once_callback).Run(data);
  23. };
  24. auto tracker = c->RequestNewThroughputTracker();
  25. tracker.Start(base::BindLambdaForTesting(callback));
  26. tracker.Stop();
  27. EXPECT_TRUE(checker.WaitUntilReported());
  28. }
  29. } // namespace ui