| OLD | NEW |
| 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 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 report_called_ = true; | 2200 report_called_ = true; |
| 2201 } | 2201 } |
| 2202 | 2202 |
| 2203 private: | 2203 private: |
| 2204 bool report_called_ = false; | 2204 bool report_called_ = false; |
| 2205 int value_ = -1; | 2205 int value_ = -1; |
| 2206 | 2206 |
| 2207 DISALLOW_COPY_AND_ASSIGN(TestMetricsReporter); | 2207 DISALLOW_COPY_AND_ASSIGN(TestMetricsReporter); |
| 2208 }; | 2208 }; |
| 2209 | 2209 |
| 2210 // TODO(crbug/709080): LayerWithRealCompositorTest.ReportMetrics is flaky on | |
| 2211 // Windows. | |
| 2212 #if defined(OS_WIN) | |
| 2213 #define MAYBE_ReportMetrics DISABLED_ReportMetrics | |
| 2214 #else | |
| 2215 #define MAYBE_ReportMetrics ReportMetrics | |
| 2216 #endif | |
| 2217 | |
| 2218 // Starts an animation and tests that incrementing compositor frame count can | 2210 // Starts an animation and tests that incrementing compositor frame count can |
| 2219 // be used to report animation smoothness metrics. | 2211 // be used to report animation smoothness metrics. |
| 2220 TEST_F(LayerWithRealCompositorTest, MAYBE_ReportMetrics) { | 2212 TEST_F(LayerWithRealCompositorTest, ReportMetrics) { |
| 2221 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR)); | 2213 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR)); |
| 2222 GetCompositor()->SetRootLayer(root.get()); | 2214 GetCompositor()->SetRootLayer(root.get()); |
| 2223 LayerAnimator* animator = root->GetAnimator(); | 2215 LayerAnimator* animator = root->GetAnimator(); |
| 2224 std::unique_ptr<ui::LayerAnimationElement> animation_element = | 2216 std::unique_ptr<ui::LayerAnimationElement> animation_element = |
| 2225 ui::LayerAnimationElement::CreateColorElement( | 2217 ui::LayerAnimationElement::CreateColorElement( |
| 2226 SK_ColorRED, base::TimeDelta::FromMilliseconds(100)); | 2218 SK_ColorRED, base::TimeDelta::FromMilliseconds(100)); |
| 2227 ui::LayerAnimationSequence* animation_sequence = | 2219 ui::LayerAnimationSequence* animation_sequence = |
| 2228 new ui::LayerAnimationSequence(std::move(animation_element)); | 2220 new ui::LayerAnimationSequence(std::move(animation_element)); |
| 2229 TestMetricsReporter reporter; | 2221 TestMetricsReporter reporter; |
| 2230 animation_sequence->SetAnimationMetricsReporter(&reporter); | 2222 animation_sequence->SetAnimationMetricsReporter(&reporter); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2243 layer.set_name("foo"); | 2235 layer.set_name("foo"); |
| 2244 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = | 2236 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = |
| 2245 layer.TakeDebugInfo(nullptr); | 2237 layer.TakeDebugInfo(nullptr); |
| 2246 std::string trace_format("bar,"); | 2238 std::string trace_format("bar,"); |
| 2247 debug_info->AppendAsTraceFormat(&trace_format); | 2239 debug_info->AppendAsTraceFormat(&trace_format); |
| 2248 std::string expected("bar,{\"layer_name\":\"foo\"}"); | 2240 std::string expected("bar,{\"layer_name\":\"foo\"}"); |
| 2249 EXPECT_EQ(expected, trace_format); | 2241 EXPECT_EQ(expected, trace_format); |
| 2250 } | 2242 } |
| 2251 | 2243 |
| 2252 } // namespace ui | 2244 } // namespace ui |
| OLD | NEW |