| 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 "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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "ui/aura/layout_manager.h" | 43 #include "ui/aura/layout_manager.h" |
| 44 #include "ui/aura/test/aura_test_helper.h" | 44 #include "ui/aura/test/aura_test_helper.h" |
| 45 #include "ui/aura/test/test_cursor_client.h" | 45 #include "ui/aura/test/test_cursor_client.h" |
| 46 #include "ui/aura/test/test_screen.h" | 46 #include "ui/aura/test/test_screen.h" |
| 47 #include "ui/aura/test/test_window_delegate.h" | 47 #include "ui/aura/test/test_window_delegate.h" |
| 48 #include "ui/aura/window.h" | 48 #include "ui/aura/window.h" |
| 49 #include "ui/aura/window_event_dispatcher.h" | 49 #include "ui/aura/window_event_dispatcher.h" |
| 50 #include "ui/aura/window_observer.h" | 50 #include "ui/aura/window_observer.h" |
| 51 #include "ui/base/ui_base_types.h" | 51 #include "ui/base/ui_base_types.h" |
| 52 #include "ui/compositor/compositor.h" | 52 #include "ui/compositor/compositor.h" |
| 53 #include "ui/compositor/layer_tree_owner.h" |
| 53 #include "ui/compositor/test/draw_waiter_for_test.h" | 54 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 54 #include "ui/events/event.h" | 55 #include "ui/events/event.h" |
| 55 #include "ui/events/event_utils.h" | 56 #include "ui/events/event_utils.h" |
| 56 #include "ui/events/gesture_detection/gesture_configuration.h" | 57 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 57 #include "ui/events/test/event_generator.h" | 58 #include "ui/events/test/event_generator.h" |
| 58 #include "ui/wm/core/default_activation_client.h" | 59 #include "ui/wm/core/default_activation_client.h" |
| 60 #include "ui/wm/core/window_util.h" |
| 59 | 61 |
| 60 using testing::_; | 62 using testing::_; |
| 61 | 63 |
| 62 using blink::WebGestureEvent; | 64 using blink::WebGestureEvent; |
| 63 using blink::WebInputEvent; | 65 using blink::WebInputEvent; |
| 64 using blink::WebMouseEvent; | 66 using blink::WebMouseEvent; |
| 65 using blink::WebMouseWheelEvent; | 67 using blink::WebMouseWheelEvent; |
| 66 using blink::WebTouchEvent; | 68 using blink::WebTouchEvent; |
| 67 using blink::WebTouchPoint; | 69 using blink::WebTouchPoint; |
| 68 | 70 |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 | 1375 |
| 1374 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, | 1376 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, |
| 1375 gfx::Rect(5, 5, 5, 5))); | 1377 gfx::Rect(5, 5, 5, 5))); |
| 1376 view_->OnSwapCompositorFrame( | 1378 view_->OnSwapCompositorFrame( |
| 1377 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5))); | 1379 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5))); |
| 1378 testing::Mock::VerifyAndClearExpectations(&observer); | 1380 testing::Mock::VerifyAndClearExpectations(&observer); |
| 1379 | 1381 |
| 1380 view_->window_->RemoveObserver(&observer); | 1382 view_->window_->RemoveObserver(&observer); |
| 1381 } | 1383 } |
| 1382 | 1384 |
| 1385 // Recreating the layers for a window should cause Surface destruction to |
| 1386 // depend on both layers. |
| 1387 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) { |
| 1388 gfx::Size view_size(100, 100); |
| 1389 gfx::Rect view_rect(view_size); |
| 1390 |
| 1391 view_->InitAsChild(NULL); |
| 1392 aura::client::ParentWindowWithContext( |
| 1393 view_->GetNativeView(), |
| 1394 parent_view_->GetNativeView()->GetRootWindow(), |
| 1395 gfx::Rect()); |
| 1396 view_->SetSize(view_size); |
| 1397 view_->WasShown(); |
| 1398 |
| 1399 view_->OnSwapCompositorFrame(0, |
| 1400 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1401 scoped_ptr<ui::LayerTreeOwner> cloned_owner( |
| 1402 wm::RecreateLayers(view_->GetNativeView())); |
| 1403 |
| 1404 cc::SurfaceHolder* holder = |
| 1405 view_->GetDelegatedFrameHost()->SurfaceHolderForTesting(); |
| 1406 if (holder) { |
| 1407 // Should be a SurfaceSequence for both the original and new layers. |
| 1408 std::set<cc::SurfaceSequence> sequences; |
| 1409 holder->GetSequenceSet(&sequences); |
| 1410 EXPECT_EQ(2u, sequences.size()); |
| 1411 } |
| 1412 } |
| 1413 |
| 1383 TEST_F(RenderWidgetHostViewAuraTest, Resize) { | 1414 TEST_F(RenderWidgetHostViewAuraTest, Resize) { |
| 1384 gfx::Size size1(100, 100); | 1415 gfx::Size size1(100, 100); |
| 1385 gfx::Size size2(200, 200); | 1416 gfx::Size size2(200, 200); |
| 1386 gfx::Size size3(300, 300); | 1417 gfx::Size size3(300, 300); |
| 1387 | 1418 |
| 1388 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); | 1419 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); |
| 1389 view_->InitAsChild(NULL); | 1420 view_->InitAsChild(NULL); |
| 1390 aura::client::ParentWindowWithContext( | 1421 aura::client::ParentWindowWithContext( |
| 1391 view_->GetNativeView(), root_window, gfx::Rect(size1)); | 1422 view_->GetNativeView(), root_window, gfx::Rect(size1)); |
| 1392 view_->WasShown(); | 1423 view_->WasShown(); |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 } | 2935 } |
| 2905 | 2936 |
| 2906 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 2937 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
| 2907 // before RWH), we clean up properly and don't leak the RWHVGuest. | 2938 // before RWH), we clean up properly and don't leak the RWHVGuest. |
| 2908 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 2939 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
| 2909 TearDownEnvironment(); | 2940 TearDownEnvironment(); |
| 2910 ASSERT_FALSE(guest_view_weak_.get()); | 2941 ASSERT_FALSE(guest_view_weak_.get()); |
| 2911 } | 2942 } |
| 2912 | 2943 |
| 2913 } // namespace content | 2944 } // namespace content |
| OLD | NEW |