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

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

Issue 299443003: Restore resize throttling on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 947
948 EXPECT_CALL(observer, OnWindowPaintScheduled(view_->window_, 948 EXPECT_CALL(observer, OnWindowPaintScheduled(view_->window_,
949 gfx::Rect(5, 5, 5, 5))); 949 gfx::Rect(5, 5, 5, 5)));
950 view_->OnSwapCompositorFrame( 950 view_->OnSwapCompositorFrame(
951 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5))); 951 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5)));
952 testing::Mock::VerifyAndClearExpectations(&observer); 952 testing::Mock::VerifyAndClearExpectations(&observer);
953 953
954 view_->window_->RemoveObserver(&observer); 954 view_->window_->RemoveObserver(&observer);
955 } 955 }
956 956
957 TEST_F(RenderWidgetHostViewAuraTest, Resize) {
958 gfx::Size size1(100, 100);
959 gfx::Size size2(200, 200);
960 gfx::Size size3(300, 300);
961
962 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
963 view_->InitAsChild(NULL);
964 aura::client::ParentWindowWithContext(
965 view_->GetNativeView(), root_window, gfx::Rect(size1));
966 view_->WasShown();
967 view_->OnSwapCompositorFrame(
968 0, MakeDelegatedFrame(1.f, size1, gfx::Rect(size1)));
969 ui::DrawWaiterForTest::WaitForCommit(
970 root_window->GetHost()->compositor());
971 ViewHostMsg_UpdateRect_Params update_params;
972 update_params.view_size = size1;
973 update_params.scale_factor = 1.f;
974 update_params.flags = ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
975 widget_host_->OnMessageReceived(
976 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params));
977 sink_->ClearMessages();
978 // Resize logic is idle (no pending resize, no pending commit).
979 EXPECT_EQ(size1.ToString(), view_->GetRequestedRendererSize().ToString());
980
981 // Resize renderer, should produce a Resize message
982 view_->SetSize(size2);
983 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
984 EXPECT_EQ(1u, sink_->message_count());
985 {
986 const IPC::Message* msg = sink_->GetMessageAt(0);
987 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
988 ViewMsg_Resize::Param params;
989 ViewMsg_Resize::Read(msg, &params);
990 EXPECT_EQ(size2.ToString(), params.a.new_size.ToString());
991 }
992 // Send resize ack to observe new Resize messages.
993 update_params.view_size = size2;
994 widget_host_->OnMessageReceived(
995 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params));
996 sink_->ClearMessages();
997
998 // Resize renderer again, before receiving a frame. Should not produce a
999 // Resize message.
1000 view_->SetSize(size3);
1001 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1002 EXPECT_EQ(0u, sink_->message_count());
1003
1004 // Receive a frame of the new size, should be skipped and not produce a Resize
1005 // message.
1006 view_->OnSwapCompositorFrame(
1007 0, MakeDelegatedFrame(1.f, size3, gfx::Rect(size3)));
1008 // Expect the frame ack;
1009 EXPECT_EQ(1u, sink_->message_count());
1010 EXPECT_EQ(ViewMsg_SwapCompositorFrameAck::ID, sink_->GetMessageAt(0)->type());
1011 sink_->ClearMessages();
1012 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1013
1014 // Receive a frame of the correct size, should not be skipped and, and should
1015 // produce a Resize message after the commit.
1016 view_->OnSwapCompositorFrame(
1017 0, MakeDelegatedFrame(1.f, size2, gfx::Rect(size2)));
1018 // No frame ack yet.
1019 EXPECT_EQ(0u, sink_->message_count());
1020 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1021
1022 // Wait for commit, then we should unlock the compositor and send a Resize
1023 // message (and a frame ack)
1024 ui::DrawWaiterForTest::WaitForCommit(
1025 root_window->GetHost()->compositor());
1026 EXPECT_EQ(size3.ToString(), view_->GetRequestedRendererSize().ToString());
1027 EXPECT_EQ(2u, sink_->message_count());
1028 EXPECT_EQ(ViewMsg_SwapCompositorFrameAck::ID, sink_->GetMessageAt(0)->type());
1029 {
1030 const IPC::Message* msg = sink_->GetMessageAt(1);
1031 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
1032 ViewMsg_Resize::Param params;
1033 ViewMsg_Resize::Read(msg, &params);
1034 EXPECT_EQ(size3.ToString(), params.a.new_size.ToString());
1035 }
1036 update_params.view_size = size3;
1037 widget_host_->OnMessageReceived(
1038 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params));
1039 sink_->ClearMessages();
1040 }
1041
957 // Skipped frames should not drop their damage. 1042 // Skipped frames should not drop their damage.
958 TEST_F(RenderWidgetHostViewAuraTest, SkippedDelegatedFrames) { 1043 TEST_F(RenderWidgetHostViewAuraTest, SkippedDelegatedFrames) {
959 gfx::Rect view_rect(100, 100); 1044 gfx::Rect view_rect(100, 100);
960 gfx::Size frame_size = view_rect.size(); 1045 gfx::Size frame_size = view_rect.size();
961 1046
962 view_->InitAsChild(NULL); 1047 view_->InitAsChild(NULL);
963 aura::client::ParentWindowWithContext( 1048 aura::client::ParentWindowWithContext(
964 view_->GetNativeView(), 1049 view_->GetNativeView(),
965 parent_view_->GetNativeView()->GetRootWindow(), 1050 parent_view_->GetNativeView()->GetRootWindow(),
966 gfx::Rect()); 1051 gfx::Rect());
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 const IPC::Message *message = sink_->GetFirstMessageMatching( 1499 const IPC::Message *message = sink_->GetFirstMessageMatching(
1415 ViewMsg_Resize::ID); 1500 ViewMsg_Resize::ID);
1416 ASSERT_TRUE(message != NULL); 1501 ASSERT_TRUE(message != NULL);
1417 1502
1418 ViewMsg_Resize::Param params; 1503 ViewMsg_Resize::Param params;
1419 ViewMsg_Resize::Read(message, &params); 1504 ViewMsg_Resize::Read(message, &params);
1420 EXPECT_EQ(60, params.a.visible_viewport_size.height()); 1505 EXPECT_EQ(60, params.a.visible_viewport_size.height());
1421 } 1506 }
1422 1507
1423 } // namespace content 1508 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698