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

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

Issue 2383263002: Generalize layer mirroring for phantom windows (Closed)
Patch Set: Rebase 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 1885
1886 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, 1886 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_,
1887 gfx::Rect(5, 5, 5, 5))); 1887 gfx::Rect(5, 5, 5, 5)));
1888 view_->OnSwapCompositorFrame( 1888 view_->OnSwapCompositorFrame(
1889 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5))); 1889 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5)));
1890 testing::Mock::VerifyAndClearExpectations(&observer); 1890 testing::Mock::VerifyAndClearExpectations(&observer);
1891 1891
1892 view_->window_->RemoveObserver(&observer); 1892 view_->window_->RemoveObserver(&observer);
1893 } 1893 }
1894 1894
1895 // Recreating the layers for a window should cause Surface destruction to 1895 // Mirroring the layers for a window should cause Surface destruction to
1896 // depend on both layers. 1896 // depend on both layers.
1897 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) { 1897 TEST_F(RenderWidgetHostViewAuraTest, MirrorLayers) {
1898 gfx::Size view_size(100, 100); 1898 gfx::Size view_size(100, 100);
1899 gfx::Rect view_rect(view_size); 1899 gfx::Rect view_rect(view_size);
1900 aura::Window* const root = parent_view_->GetNativeView()->GetRootWindow();
1900 1901
1901 view_->InitAsChild(nullptr); 1902 view_->InitAsChild(nullptr);
1902 aura::client::ParentWindowWithContext( 1903 aura::client::ParentWindowWithContext(
1903 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), 1904 view_->GetNativeView(), root, gfx::Rect());
1904 gfx::Rect());
1905 view_->SetSize(view_size); 1905 view_->SetSize(view_size);
1906 view_->Show(); 1906 view_->Show();
1907 1907
1908 view_->OnSwapCompositorFrame(0, 1908 view_->OnSwapCompositorFrame(0,
1909 MakeDelegatedFrame(1.f, view_size, view_rect)); 1909 MakeDelegatedFrame(1.f, view_size, view_rect));
1910 std::unique_ptr<ui::LayerTreeOwner> cloned_owner( 1910 std::unique_ptr<ui::LayerTreeOwner> mirror(wm::MirrorLayers(
1911 wm::RecreateLayers(view_->GetNativeView(), nullptr)); 1911 view_->GetNativeView(), nullptr, false /* sync_bounds */));
1912 1912
1913 cc::SurfaceId id = view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); 1913 cc::SurfaceId id = view_->GetDelegatedFrameHost()->SurfaceIdForTesting();
1914 if (!id.is_null()) { 1914 if (!id.is_null()) {
1915 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1915 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1916 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1916 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1917 cc::Surface* surface = manager->GetSurfaceForId(id); 1917 cc::Surface* surface = manager->GetSurfaceForId(id);
1918 EXPECT_TRUE(surface); 1918 EXPECT_TRUE(surface);
1919 // Should be a SurfaceSequence for both the original and new layers. 1919
1920 // An orphaned mirror should not be a destruction dependency.
1921 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
1922
1923 // Both layers should be destruction dependencies.
1924 root->layer()->Add(mirror->root());
1920 EXPECT_EQ(2u, surface->GetDestructionDependencyCount()); 1925 EXPECT_EQ(2u, surface->GetDestructionDependencyCount());
1926 root->layer()->Remove(mirror->root());
1921 } 1927 }
1922 } 1928 }
1923 1929
1924 // If the view size is larger than the compositor frame then extra layers 1930 // If the view size is larger than the compositor frame then extra layers
1925 // should be created to fill the gap. 1931 // should be created to fill the gap.
1926 TEST_F(RenderWidgetHostViewAuraTest, DelegatedFrameGutter) { 1932 TEST_F(RenderWidgetHostViewAuraTest, DelegatedFrameGutter) {
1927 gfx::Size large_size(100, 100); 1933 gfx::Size large_size(100, 100);
1928 gfx::Size small_size(40, 45); 1934 gfx::Size small_size(40, 45);
1929 gfx::Size medium_size(40, 95); 1935 gfx::Size medium_size(40, 95);
1930 1936
(...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 4688
4683 // Retrieve the selected text from clipboard and verify it is as expected. 4689 // Retrieve the selected text from clipboard and verify it is as expected.
4684 base::string16 result_text; 4690 base::string16 result_text;
4685 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); 4691 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text);
4686 EXPECT_EQ(expected_text, result_text); 4692 EXPECT_EQ(expected_text, result_text);
4687 } 4693 }
4688 } 4694 }
4689 #endif 4695 #endif
4690 4696
4691 } // namespace content 4697 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698