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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <tuple> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/test/simple_test_tick_clock.h" | 20 #include "base/test/simple_test_tick_clock.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 void AckLastSentInputEventIfNecessary(InputEventAckState ack_result) { | 523 void AckLastSentInputEventIfNecessary(InputEventAckState ack_result) { |
523 if (!sink_->message_count()) | 524 if (!sink_->message_count()) |
524 return; | 525 return; |
525 | 526 |
526 InputMsg_HandleInputEvent::Param params; | 527 InputMsg_HandleInputEvent::Param params; |
527 if (!InputMsg_HandleInputEvent::Read( | 528 if (!InputMsg_HandleInputEvent::Read( |
528 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { | 529 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { |
529 return; | 530 return; |
530 } | 531 } |
531 | 532 |
532 InputEventDispatchType dispatch_type = base::get<2>(params); | 533 InputEventDispatchType dispatch_type = std::get<2>(params); |
533 if (dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING) | 534 if (dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING) |
534 return; | 535 return; |
535 | 536 |
536 const blink::WebInputEvent* event = base::get<0>(params); | 537 const blink::WebInputEvent* event = std::get<0>(params); |
537 SendTouchEventACK(event->type, ack_result, | 538 SendTouchEventACK(event->type, ack_result, |
538 WebInputEventTraits::GetUniqueTouchEventId(*event)); | 539 WebInputEventTraits::GetUniqueTouchEventId(*event)); |
539 } | 540 } |
540 | 541 |
541 const ui::MotionEventAura& pointer_state() { | 542 const ui::MotionEventAura& pointer_state() { |
542 return view_->pointer_state_for_test(); | 543 return view_->pointer_state_for_test(); |
543 } | 544 } |
544 | 545 |
545 protected: | 546 protected: |
546 // If true, then calls RWH::Shutdown() instead of deleting RWH. | 547 // If true, then calls RWH::Shutdown() instead of deleting RWH. |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 917 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
917 sink_->ClearMessages(); | 918 sink_->ClearMessages(); |
918 | 919 |
919 // Move parents. | 920 // Move parents. |
920 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); | 921 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); |
921 ASSERT_EQ(1U, sink_->message_count()); | 922 ASSERT_EQ(1U, sink_->message_count()); |
922 const IPC::Message* msg = sink_->GetMessageAt(0); | 923 const IPC::Message* msg = sink_->GetMessageAt(0); |
923 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); | 924 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
924 ViewMsg_UpdateScreenRects::Param params; | 925 ViewMsg_UpdateScreenRects::Param params; |
925 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); | 926 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
926 EXPECT_EQ(gfx::Rect(24, 24, 100, 100), base::get<0>(params)); | 927 EXPECT_EQ(gfx::Rect(24, 24, 100, 100), std::get<0>(params)); |
927 EXPECT_EQ(gfx::Rect(1, 1, 300, 300), base::get<1>(params)); | 928 EXPECT_EQ(gfx::Rect(1, 1, 300, 300), std::get<1>(params)); |
928 sink_->ClearMessages(); | 929 sink_->ClearMessages(); |
929 widget_host_->OnMessageReceived( | 930 widget_host_->OnMessageReceived( |
930 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 931 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
931 // There should not be any pending update. | 932 // There should not be any pending update. |
932 EXPECT_EQ(0U, sink_->message_count()); | 933 EXPECT_EQ(0U, sink_->message_count()); |
933 | 934 |
934 parent1->SetBounds(gfx::Rect(10, 10, 300, 300)); | 935 parent1->SetBounds(gfx::Rect(10, 10, 300, 300)); |
935 ASSERT_EQ(1U, sink_->message_count()); | 936 ASSERT_EQ(1U, sink_->message_count()); |
936 msg = sink_->GetMessageAt(0); | 937 msg = sink_->GetMessageAt(0); |
937 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); | 938 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
938 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); | 939 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
939 EXPECT_EQ(gfx::Rect(33, 33, 100, 100), base::get<0>(params)); | 940 EXPECT_EQ(gfx::Rect(33, 33, 100, 100), std::get<0>(params)); |
940 EXPECT_EQ(gfx::Rect(10, 10, 300, 300), base::get<1>(params)); | 941 EXPECT_EQ(gfx::Rect(10, 10, 300, 300), std::get<1>(params)); |
941 sink_->ClearMessages(); | 942 sink_->ClearMessages(); |
942 widget_host_->OnMessageReceived( | 943 widget_host_->OnMessageReceived( |
943 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 944 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
944 // There should not be any pending update. | 945 // There should not be any pending update. |
945 EXPECT_EQ(0U, sink_->message_count()); | 946 EXPECT_EQ(0U, sink_->message_count()); |
946 } | 947 } |
947 | 948 |
948 // Checks that a fullscreen view is destroyed when it loses the focus. | 949 // Checks that a fullscreen view is destroyed when it loses the focus. |
949 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { | 950 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { |
950 view_->InitAsFullscreen(parent_view_); | 951 view_->InitAsFullscreen(parent_view_); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 view_->SetCompositionText(composition_text); | 1102 view_->SetCompositionText(composition_text); |
1102 EXPECT_TRUE(view_->has_composition_text_); | 1103 EXPECT_TRUE(view_->has_composition_text_); |
1103 { | 1104 { |
1104 const IPC::Message* msg = | 1105 const IPC::Message* msg = |
1105 sink_->GetFirstMessageMatching(InputMsg_ImeSetComposition::ID); | 1106 sink_->GetFirstMessageMatching(InputMsg_ImeSetComposition::ID); |
1106 ASSERT_TRUE(msg != NULL); | 1107 ASSERT_TRUE(msg != NULL); |
1107 | 1108 |
1108 InputMsg_ImeSetComposition::Param params; | 1109 InputMsg_ImeSetComposition::Param params; |
1109 InputMsg_ImeSetComposition::Read(msg, ¶ms); | 1110 InputMsg_ImeSetComposition::Read(msg, ¶ms); |
1110 // composition text | 1111 // composition text |
1111 EXPECT_EQ(composition_text.text, base::get<0>(params)); | 1112 EXPECT_EQ(composition_text.text, std::get<0>(params)); |
1112 // underlines | 1113 // underlines |
1113 ASSERT_EQ(underlines.size(), base::get<1>(params).size()); | 1114 ASSERT_EQ(underlines.size(), std::get<1>(params).size()); |
1114 for (size_t i = 0; i < underlines.size(); ++i) { | 1115 for (size_t i = 0; i < underlines.size(); ++i) { |
1115 EXPECT_EQ(underlines[i].start_offset, | 1116 EXPECT_EQ(underlines[i].start_offset, std::get<1>(params)[i].startOffset); |
1116 base::get<1>(params)[i].startOffset); | 1117 EXPECT_EQ(underlines[i].end_offset, std::get<1>(params)[i].endOffset); |
1117 EXPECT_EQ(underlines[i].end_offset, base::get<1>(params)[i].endOffset); | 1118 EXPECT_EQ(underlines[i].color, std::get<1>(params)[i].color); |
1118 EXPECT_EQ(underlines[i].color, base::get<1>(params)[i].color); | 1119 EXPECT_EQ(underlines[i].thick, std::get<1>(params)[i].thick); |
1119 EXPECT_EQ(underlines[i].thick, base::get<1>(params)[i].thick); | |
1120 EXPECT_EQ(underlines[i].background_color, | 1120 EXPECT_EQ(underlines[i].background_color, |
1121 base::get<1>(params)[i].backgroundColor); | 1121 std::get<1>(params)[i].backgroundColor); |
1122 } | 1122 } |
1123 EXPECT_EQ(gfx::Range::InvalidRange(), base::get<2>(params)); | 1123 EXPECT_EQ(gfx::Range::InvalidRange(), std::get<2>(params)); |
1124 // highlighted range | 1124 // highlighted range |
1125 EXPECT_EQ(4, base::get<3>(params)) << "Should be the same to the caret pos"; | 1125 EXPECT_EQ(4, std::get<3>(params)) << "Should be the same to the caret pos"; |
1126 EXPECT_EQ(4, base::get<4>(params)) << "Should be the same to the caret pos"; | 1126 EXPECT_EQ(4, std::get<4>(params)) << "Should be the same to the caret pos"; |
1127 } | 1127 } |
1128 | 1128 |
1129 view_->ImeCancelComposition(); | 1129 view_->ImeCancelComposition(); |
1130 EXPECT_FALSE(view_->has_composition_text_); | 1130 EXPECT_FALSE(view_->has_composition_text_); |
1131 } | 1131 } |
1132 | 1132 |
1133 // Checks that sequence of IME-composition-event and mouse-event when mouse | 1133 // Checks that sequence of IME-composition-event and mouse-event when mouse |
1134 // clicking to cancel the composition. | 1134 // clicking to cancel the composition. |
1135 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { | 1135 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { |
1136 view_->InitAsChild(NULL); | 1136 view_->InitAsChild(NULL); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 sink_->ClearMessages(); | 1388 sink_->ClearMessages(); |
1389 view_->SetSize(gfx::Size(100, 100)); | 1389 view_->SetSize(gfx::Size(100, 100)); |
1390 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); | 1390 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); |
1391 EXPECT_EQ(1u, sink_->message_count()); | 1391 EXPECT_EQ(1u, sink_->message_count()); |
1392 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); | 1392 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); |
1393 { | 1393 { |
1394 const IPC::Message* msg = sink_->GetMessageAt(0); | 1394 const IPC::Message* msg = sink_->GetMessageAt(0); |
1395 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1395 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1396 ViewMsg_Resize::Param params; | 1396 ViewMsg_Resize::Param params; |
1397 ViewMsg_Resize::Read(msg, ¶ms); | 1397 ViewMsg_Resize::Read(msg, ¶ms); |
1398 EXPECT_EQ("100x100", base::get<0>(params).new_size.ToString()); // dip size | 1398 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size |
1399 EXPECT_EQ("100x100", | 1399 EXPECT_EQ( |
1400 base::get<0>(params).physical_backing_size.ToString()); // backing size | 1400 "100x100", |
| 1401 std::get<0>(params).physical_backing_size.ToString()); // backing size |
1401 } | 1402 } |
1402 | 1403 |
1403 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1404 widget_host_->ResetSizeAndRepaintPendingFlags(); |
1404 sink_->ClearMessages(); | 1405 sink_->ClearMessages(); |
1405 | 1406 |
1406 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f); | 1407 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f); |
1407 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString()); | 1408 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString()); |
1408 // Extra ScreenInfoChanged message for |parent_view_|. | 1409 // Extra ScreenInfoChanged message for |parent_view_|. |
1409 EXPECT_EQ(1u, sink_->message_count()); | 1410 EXPECT_EQ(1u, sink_->message_count()); |
1410 { | 1411 { |
1411 const IPC::Message* msg = sink_->GetMessageAt(0); | 1412 const IPC::Message* msg = sink_->GetMessageAt(0); |
1412 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1413 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1413 ViewMsg_Resize::Param params; | 1414 ViewMsg_Resize::Param params; |
1414 ViewMsg_Resize::Read(msg, ¶ms); | 1415 ViewMsg_Resize::Read(msg, ¶ms); |
1415 EXPECT_EQ(2.0f, base::get<0>(params).screen_info.deviceScaleFactor); | 1416 EXPECT_EQ(2.0f, std::get<0>(params).screen_info.deviceScaleFactor); |
1416 EXPECT_EQ("100x100", base::get<0>(params).new_size.ToString()); // dip size | 1417 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size |
1417 EXPECT_EQ("200x200", | 1418 EXPECT_EQ( |
1418 base::get<0>(params).physical_backing_size.ToString()); // backing size | 1419 "200x200", |
| 1420 std::get<0>(params).physical_backing_size.ToString()); // backing size |
1419 } | 1421 } |
1420 | 1422 |
1421 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1423 widget_host_->ResetSizeAndRepaintPendingFlags(); |
1422 sink_->ClearMessages(); | 1424 sink_->ClearMessages(); |
1423 | 1425 |
1424 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f); | 1426 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f); |
1425 // Extra ScreenInfoChanged message for |parent_view_|. | 1427 // Extra ScreenInfoChanged message for |parent_view_|. |
1426 EXPECT_EQ(1u, sink_->message_count()); | 1428 EXPECT_EQ(1u, sink_->message_count()); |
1427 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); | 1429 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); |
1428 { | 1430 { |
1429 const IPC::Message* msg = sink_->GetMessageAt(0); | 1431 const IPC::Message* msg = sink_->GetMessageAt(0); |
1430 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1432 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1431 ViewMsg_Resize::Param params; | 1433 ViewMsg_Resize::Param params; |
1432 ViewMsg_Resize::Read(msg, ¶ms); | 1434 ViewMsg_Resize::Read(msg, ¶ms); |
1433 EXPECT_EQ(1.0f, base::get<0>(params).screen_info.deviceScaleFactor); | 1435 EXPECT_EQ(1.0f, std::get<0>(params).screen_info.deviceScaleFactor); |
1434 EXPECT_EQ("100x100", base::get<0>(params).new_size.ToString()); // dip size | 1436 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size |
1435 EXPECT_EQ("100x100", | 1437 EXPECT_EQ( |
1436 base::get<0>(params).physical_backing_size.ToString()); // backing size | 1438 "100x100", |
| 1439 std::get<0>(params).physical_backing_size.ToString()); // backing size |
1437 } | 1440 } |
1438 } | 1441 } |
1439 | 1442 |
1440 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched | 1443 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched |
1441 // to the renderer at the correct times. | 1444 // to the renderer at the correct times. |
1442 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { | 1445 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { |
1443 view_->InitAsChild(NULL); | 1446 view_->InitAsChild(NULL); |
1444 aura::client::ParentWindowWithContext( | 1447 aura::client::ParentWindowWithContext( |
1445 view_->GetNativeView(), | 1448 view_->GetNativeView(), |
1446 parent_view_->GetNativeView()->GetRootWindow(), | 1449 parent_view_->GetNativeView()->GetRootWindow(), |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 sink_->ClearMessages(); | 1593 sink_->ClearMessages(); |
1591 | 1594 |
1592 // Call WasResized to flush the old screen info. | 1595 // Call WasResized to flush the old screen info. |
1593 view_->GetRenderWidgetHost()->WasResized(); | 1596 view_->GetRenderWidgetHost()->WasResized(); |
1594 { | 1597 { |
1595 // 0 is CreatingNew message. | 1598 // 0 is CreatingNew message. |
1596 const IPC::Message* msg = sink_->GetMessageAt(0); | 1599 const IPC::Message* msg = sink_->GetMessageAt(0); |
1597 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1600 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1598 ViewMsg_Resize::Param params; | 1601 ViewMsg_Resize::Param params; |
1599 ViewMsg_Resize::Read(msg, ¶ms); | 1602 ViewMsg_Resize::Read(msg, ¶ms); |
1600 EXPECT_EQ("0,0 800x600", | 1603 EXPECT_EQ( |
1601 gfx::Rect( | 1604 "0,0 800x600", |
1602 base::get<0>(params).screen_info.availableRect).ToString()); | 1605 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString()); |
1603 EXPECT_EQ("800x600", base::get<0>(params).new_size.ToString()); | 1606 EXPECT_EQ("800x600", std::get<0>(params).new_size.ToString()); |
1604 // Resizes are blocked until we swapped a frame of the correct size, and | 1607 // Resizes are blocked until we swapped a frame of the correct size, and |
1605 // we've committed it. | 1608 // we've committed it. |
1606 view_->OnSwapCompositorFrame( | 1609 view_->OnSwapCompositorFrame( |
1607 0, | 1610 0, MakeDelegatedFrame(1.f, std::get<0>(params).new_size, |
1608 MakeDelegatedFrame( | 1611 gfx::Rect(std::get<0>(params).new_size))); |
1609 1.f, base::get<0>(params).new_size, | |
1610 gfx::Rect(base::get<0>(params).new_size))); | |
1611 ui::DrawWaiterForTest::WaitForCommit( | 1612 ui::DrawWaiterForTest::WaitForCommit( |
1612 root_window->GetHost()->compositor()); | 1613 root_window->GetHost()->compositor()); |
1613 } | 1614 } |
1614 | 1615 |
1615 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1616 widget_host_->ResetSizeAndRepaintPendingFlags(); |
1616 sink_->ClearMessages(); | 1617 sink_->ClearMessages(); |
1617 | 1618 |
1618 // Make sure the corrent screen size is set along in the resize | 1619 // Make sure the corrent screen size is set along in the resize |
1619 // request when the screen size has changed. | 1620 // request when the screen size has changed. |
1620 aura_test_helper_->test_screen()->SetUIScale(0.5); | 1621 aura_test_helper_->test_screen()->SetUIScale(0.5); |
1621 EXPECT_EQ(1u, sink_->message_count()); | 1622 EXPECT_EQ(1u, sink_->message_count()); |
1622 { | 1623 { |
1623 const IPC::Message* msg = sink_->GetMessageAt(0); | 1624 const IPC::Message* msg = sink_->GetMessageAt(0); |
1624 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1625 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1625 ViewMsg_Resize::Param params; | 1626 ViewMsg_Resize::Param params; |
1626 ViewMsg_Resize::Read(msg, ¶ms); | 1627 ViewMsg_Resize::Read(msg, ¶ms); |
1627 EXPECT_EQ("0,0 1600x1200", | 1628 EXPECT_EQ( |
1628 gfx::Rect( | 1629 "0,0 1600x1200", |
1629 base::get<0>(params).screen_info.availableRect).ToString()); | 1630 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString()); |
1630 EXPECT_EQ("1600x1200", base::get<0>(params).new_size.ToString()); | 1631 EXPECT_EQ("1600x1200", std::get<0>(params).new_size.ToString()); |
1631 view_->OnSwapCompositorFrame( | 1632 view_->OnSwapCompositorFrame( |
1632 0, | 1633 0, MakeDelegatedFrame(1.f, std::get<0>(params).new_size, |
1633 MakeDelegatedFrame( | 1634 gfx::Rect(std::get<0>(params).new_size))); |
1634 1.f, base::get<0>(params).new_size, | |
1635 gfx::Rect(base::get<0>(params).new_size))); | |
1636 ui::DrawWaiterForTest::WaitForCommit( | 1635 ui::DrawWaiterForTest::WaitForCommit( |
1637 root_window->GetHost()->compositor()); | 1636 root_window->GetHost()->compositor()); |
1638 } | 1637 } |
1639 } | 1638 } |
1640 | 1639 |
1641 // Swapping a frame should notify the window. | 1640 // Swapping a frame should notify the window. |
1642 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) { | 1641 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) { |
1643 gfx::Size view_size(100, 100); | 1642 gfx::Size view_size(100, 100); |
1644 gfx::Rect view_rect(view_size); | 1643 gfx::Rect view_rect(view_size); |
1645 | 1644 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 | 1775 |
1777 // Resize renderer, should produce a Resize message | 1776 // Resize renderer, should produce a Resize message |
1778 view_->SetSize(size2); | 1777 view_->SetSize(size2); |
1779 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); | 1778 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); |
1780 EXPECT_EQ(1u, sink_->message_count()); | 1779 EXPECT_EQ(1u, sink_->message_count()); |
1781 { | 1780 { |
1782 const IPC::Message* msg = sink_->GetMessageAt(0); | 1781 const IPC::Message* msg = sink_->GetMessageAt(0); |
1783 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1782 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); |
1784 ViewMsg_Resize::Param params; | 1783 ViewMsg_Resize::Param params; |
1785 ViewMsg_Resize::Read(msg, ¶ms); | 1784 ViewMsg_Resize::Read(msg, ¶ms); |
1786 EXPECT_EQ(size2.ToString(), base::get<0>(params).new_size.ToString()); | 1785 EXPECT_EQ(size2.ToString(), std::get<0>(params).new_size.ToString()); |
1787 } | 1786 } |
1788 // Send resize ack to observe new Resize messages. | 1787 // Send resize ack to observe new Resize messages. |
1789 update_params.view_size = size2; | 1788 update_params.view_size = size2; |
1790 widget_host_->OnMessageReceived( | 1789 widget_host_->OnMessageReceived( |
1791 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); | 1790 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); |
1792 sink_->ClearMessages(); | 1791 sink_->ClearMessages(); |
1793 | 1792 |
1794 // Resize renderer again, before receiving a frame. Should not produce a | 1793 // Resize renderer again, before receiving a frame. Should not produce a |
1795 // Resize message. | 1794 // Resize message. |
1796 view_->SetSize(size3); | 1795 view_->SetSize(size3); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 const IPC::Message* msg = sink_->GetMessageAt(i); | 1830 const IPC::Message* msg = sink_->GetMessageAt(i); |
1832 switch (msg->type()) { | 1831 switch (msg->type()) { |
1833 case InputMsg_HandleInputEvent::ID: { | 1832 case InputMsg_HandleInputEvent::ID: { |
1834 // On some platforms, the call to view_->Show() causes a posted task to | 1833 // On some platforms, the call to view_->Show() causes a posted task to |
1835 // call | 1834 // call |
1836 // ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow, | 1835 // ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow, |
1837 // which the above WaitForCommit may cause to be picked up. Be robust | 1836 // which the above WaitForCommit may cause to be picked up. Be robust |
1838 // to this extra IPC coming in. | 1837 // to this extra IPC coming in. |
1839 InputMsg_HandleInputEvent::Param params; | 1838 InputMsg_HandleInputEvent::Param params; |
1840 InputMsg_HandleInputEvent::Read(msg, ¶ms); | 1839 InputMsg_HandleInputEvent::Read(msg, ¶ms); |
1841 const blink::WebInputEvent* event = base::get<0>(params); | 1840 const blink::WebInputEvent* event = std::get<0>(params); |
1842 EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type); | 1841 EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type); |
1843 break; | 1842 break; |
1844 } | 1843 } |
1845 case ViewMsg_SwapCompositorFrameAck::ID: | 1844 case ViewMsg_SwapCompositorFrameAck::ID: |
1846 break; | 1845 break; |
1847 case ViewMsg_Resize::ID: { | 1846 case ViewMsg_Resize::ID: { |
1848 EXPECT_FALSE(has_resize); | 1847 EXPECT_FALSE(has_resize); |
1849 ViewMsg_Resize::Param params; | 1848 ViewMsg_Resize::Param params; |
1850 ViewMsg_Resize::Read(msg, ¶ms); | 1849 ViewMsg_Resize::Read(msg, ¶ms); |
1851 EXPECT_EQ(size3.ToString(), base::get<0>(params).new_size.ToString()); | 1850 EXPECT_EQ(size3.ToString(), std::get<0>(params).new_size.ToString()); |
1852 has_resize = true; | 1851 has_resize = true; |
1853 break; | 1852 break; |
1854 } | 1853 } |
1855 default: | 1854 default: |
1856 ADD_FAILURE() << "Unexpected message " << msg->type(); | 1855 ADD_FAILURE() << "Unexpected message " << msg->type(); |
1857 break; | 1856 break; |
1858 } | 1857 } |
1859 } | 1858 } |
1860 EXPECT_TRUE(has_resize); | 1859 EXPECT_TRUE(has_resize); |
1861 update_params.view_size = size3; | 1860 update_params.view_size = size3; |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 view_->SetInsets(gfx::Insets(0, 0, 40, 0)); | 2597 view_->SetInsets(gfx::Insets(0, 0, 40, 0)); |
2599 | 2598 |
2600 EXPECT_EQ(60, view_->GetVisibleViewportSize().height()); | 2599 EXPECT_EQ(60, view_->GetVisibleViewportSize().height()); |
2601 | 2600 |
2602 const IPC::Message *message = sink_->GetFirstMessageMatching( | 2601 const IPC::Message *message = sink_->GetFirstMessageMatching( |
2603 ViewMsg_Resize::ID); | 2602 ViewMsg_Resize::ID); |
2604 ASSERT_TRUE(message != NULL); | 2603 ASSERT_TRUE(message != NULL); |
2605 | 2604 |
2606 ViewMsg_Resize::Param params; | 2605 ViewMsg_Resize::Param params; |
2607 ViewMsg_Resize::Read(message, ¶ms); | 2606 ViewMsg_Resize::Read(message, ¶ms); |
2608 EXPECT_EQ(60, base::get<0>(params).visible_viewport_size.height()); | 2607 EXPECT_EQ(60, std::get<0>(params).visible_viewport_size.height()); |
2609 } | 2608 } |
2610 | 2609 |
2611 // Ensures that touch event positions are never truncated to integers. | 2610 // Ensures that touch event positions are never truncated to integers. |
2612 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { | 2611 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { |
2613 const float kX = 30.58f; | 2612 const float kX = 30.58f; |
2614 const float kY = 50.23f; | 2613 const float kY = 50.23f; |
2615 | 2614 |
2616 view_->InitAsChild(NULL); | 2615 view_->InitAsChild(NULL); |
2617 view_->Show(); | 2616 view_->Show(); |
2618 | 2617 |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4326 const IPC::Message* msg = | 4325 const IPC::Message* msg = |
4327 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID); | 4326 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID); |
4328 EXPECT_TRUE(msg); | 4327 EXPECT_TRUE(msg); |
4329 ViewMsg_SetSurfaceIdNamespace::Param params; | 4328 ViewMsg_SetSurfaceIdNamespace::Param params; |
4330 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 4329 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
4331 view_->InitAsChild(NULL); | 4330 view_->InitAsChild(NULL); |
4332 view_->Show(); | 4331 view_->Show(); |
4333 view_->SetSize(size); | 4332 view_->SetSize(size); |
4334 view_->OnSwapCompositorFrame(0, | 4333 view_->OnSwapCompositorFrame(0, |
4335 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 4334 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
4336 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); | 4335 EXPECT_EQ(view_->GetSurfaceIdNamespace(), std::get<0>(params)); |
4337 } | 4336 } |
4338 | 4337 |
4339 // This class provides functionality to test a RenderWidgetHostViewAura | 4338 // This class provides functionality to test a RenderWidgetHostViewAura |
4340 // instance which has been hooked up to a test RenderViewHost instance and | 4339 // instance which has been hooked up to a test RenderViewHost instance and |
4341 // a WebContents instance. | 4340 // a WebContents instance. |
4342 class RenderWidgetHostViewAuraWithViewHarnessTest | 4341 class RenderWidgetHostViewAuraWithViewHarnessTest |
4343 : public RenderViewHostImplTestHarness { | 4342 : public RenderViewHostImplTestHarness { |
4344 public: | 4343 public: |
4345 RenderWidgetHostViewAuraWithViewHarnessTest() | 4344 RenderWidgetHostViewAuraWithViewHarnessTest() |
4346 : view_(nullptr) {} | 4345 : view_(nullptr) {} |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 view()->OnGestureEvent(&gesture_event); | 4484 view()->OnGestureEvent(&gesture_event); |
4486 | 4485 |
4487 EXPECT_TRUE(delegate->context_menu_request_received()); | 4486 EXPECT_TRUE(delegate->context_menu_request_received()); |
4488 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 4487 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
4489 #endif | 4488 #endif |
4490 | 4489 |
4491 RenderViewHostFactory::set_is_real_render_view_host(false); | 4490 RenderViewHostFactory::set_is_real_render_view_host(false); |
4492 } | 4491 } |
4493 | 4492 |
4494 } // namespace content | 4493 } // namespace content |
OLD | NEW |