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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 10 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 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 cc::FrameSinkId(0, 1), 1826 cc::FrameSinkId(0, 1),
1827 cc::LocalFrameId(2, base::UnguessableToken::Create())); 1827 cc::LocalFrameId(2, base::UnguessableToken::Create()));
1828 cc::SurfaceInfo surface_info(surface_id, 1.0f, gfx::Size(10, 10)); 1828 cc::SurfaceInfo surface_info(surface_id, 1.0f, gfx::Size(10, 10));
1829 layer->SetShowSurface(surface_info, new TestSurfaceReferenceFactory()); 1829 layer->SetShowSurface(surface_info, new TestSurfaceReferenceFactory());
1830 1830
1831 const auto mirror = layer->Mirror(); 1831 const auto mirror = layer->Mirror();
1832 auto* const cc_layer = mirror->cc_layer_for_testing(); 1832 auto* const cc_layer = mirror->cc_layer_for_testing();
1833 const auto* surface = static_cast<cc::SurfaceLayer*>(cc_layer); 1833 const auto* surface = static_cast<cc::SurfaceLayer*>(cc_layer);
1834 1834
1835 // Mirroring preserves surface state. 1835 // Mirroring preserves surface state.
1836 EXPECT_EQ(surface_info, surface->surface_info()); 1836 EXPECT_EQ(surface_info, surface->primary_surface_info());
1837 1837
1838 surface_id = 1838 surface_id =
1839 cc::SurfaceId(cc::FrameSinkId(1, 2), 1839 cc::SurfaceId(cc::FrameSinkId(1, 2),
1840 cc::LocalFrameId(3, base::UnguessableToken::Create())); 1840 cc::LocalFrameId(3, base::UnguessableToken::Create()));
1841 cc::SurfaceInfo surface_info_2(surface_id, 2.0f, gfx::Size(20, 20)); 1841 cc::SurfaceInfo surface_info_2(surface_id, 2.0f, gfx::Size(20, 20));
1842 layer->SetShowSurface(surface_info_2, new TestSurfaceReferenceFactory()); 1842 layer->SetShowSurface(surface_info_2, new TestSurfaceReferenceFactory());
1843 1843
1844 // A new cc::Layer should be created for the mirror. 1844 // A new cc::Layer should be created for the mirror.
1845 EXPECT_NE(cc_layer, mirror->cc_layer_for_testing()); 1845 EXPECT_NE(cc_layer, mirror->cc_layer_for_testing());
1846 surface = static_cast<cc::SurfaceLayer*>(mirror->cc_layer_for_testing()); 1846 surface = static_cast<cc::SurfaceLayer*>(mirror->cc_layer_for_testing());
1847 1847
1848 // Surface updates propagate to the mirror. 1848 // Surface updates propagate to the mirror.
1849 EXPECT_EQ(surface_info_2, surface->surface_info()); 1849 EXPECT_EQ(surface_info_2, surface->primary_surface_info());
1850 } 1850 }
1851 1851
1852 // Test if frame size in dip is properly calculated in SetShowSurface 1852 // Test if frame size in dip is properly calculated in SetShowSurface
1853 TEST_F(LayerWithDelegateTest, FrameSizeInDip) { 1853 TEST_F(LayerWithDelegateTest, FrameSizeInDip) {
1854 std::unique_ptr<Layer> layer(CreateLayer(LAYER_SOLID_COLOR)); 1854 std::unique_ptr<Layer> layer(CreateLayer(LAYER_SOLID_COLOR));
1855 1855
1856 cc::SurfaceId surface_id( 1856 cc::SurfaceId surface_id(
1857 cc::FrameSinkId(0, 1), 1857 cc::FrameSinkId(0, 1),
1858 cc::LocalFrameId(2, base::UnguessableToken::Create())); 1858 cc::LocalFrameId(2, base::UnguessableToken::Create()));
1859 1859
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 layer.set_name("foo"); 2233 layer.set_name("foo");
2234 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = 2234 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info =
2235 layer.TakeDebugInfo(nullptr); 2235 layer.TakeDebugInfo(nullptr);
2236 std::string trace_format("bar,"); 2236 std::string trace_format("bar,");
2237 debug_info->AppendAsTraceFormat(&trace_format); 2237 debug_info->AppendAsTraceFormat(&trace_format);
2238 std::string expected("bar,{\"layer_name\":\"foo\"}"); 2238 std::string expected("bar,{\"layer_name\":\"foo\"}");
2239 EXPECT_EQ(expected, trace_format); 2239 EXPECT_EQ(expected, trace_format);
2240 } 2240 }
2241 2241
2242 } // namespace ui 2242 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698