| 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 <tuple> |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 private: | 426 private: |
| 427 aura::Window* owner_; | 427 aura::Window* owner_; |
| 428 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); | 428 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); |
| 429 }; | 429 }; |
| 430 | 430 |
| 431 class MockWindowObserver : public aura::WindowObserver { | 431 class MockWindowObserver : public aura::WindowObserver { |
| 432 public: | 432 public: |
| 433 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); | 433 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); |
| 434 }; | 434 }; |
| 435 | 435 |
| 436 class MockRenderWidgetHostImpl : public RenderWidgetHostImpl { | |
| 437 public: | |
| 438 MockRenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | |
| 439 RenderProcessHost* process, | |
| 440 int32_t routing_id) | |
| 441 : RenderWidgetHostImpl(delegate, process, routing_id, false) { | |
| 442 set_renderer_initialized(true); | |
| 443 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(); | |
| 444 } | |
| 445 | |
| 446 // Extracts |latency_info| for wheel event, and stores it in | |
| 447 // |lastWheelOrTouchEventLatencyInfo|. | |
| 448 void ForwardWheelEventWithLatencyInfo( | |
| 449 const blink::WebMouseWheelEvent& wheel_event, | |
| 450 const ui::LatencyInfo& ui_latency) override { | |
| 451 RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(wheel_event, | |
| 452 ui_latency); | |
| 453 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency); | |
| 454 } | |
| 455 | |
| 456 // Extracts |latency_info| for touch event, and stores it in | |
| 457 // |lastWheelOrTouchEventLatencyInfo|. | |
| 458 void ForwardTouchEventWithLatencyInfo( | |
| 459 const blink::WebTouchEvent& touch_event, | |
| 460 const ui::LatencyInfo& ui_latency) override { | |
| 461 RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(touch_event, | |
| 462 ui_latency); | |
| 463 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency); | |
| 464 } | |
| 465 | |
| 466 ui::LatencyInfo lastWheelOrTouchEventLatencyInfo; | |
| 467 }; | |
| 468 | |
| 469 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 436 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
| 470 base::PickleIterator iter(message); | 437 base::PickleIterator iter(message); |
| 471 const char* data; | 438 const char* data; |
| 472 int data_length; | 439 int data_length; |
| 473 if (!iter.ReadData(&data, &data_length)) | 440 if (!iter.ReadData(&data, &data_length)) |
| 474 return nullptr; | 441 return nullptr; |
| 475 return reinterpret_cast<const WebInputEvent*>(data); | 442 return reinterpret_cast<const WebInputEvent*>(data); |
| 476 } | 443 } |
| 477 | 444 |
| 478 } // namespace | 445 } // namespace |
| (...skipping 27 matching lines...) Expand all Loading... |
| 506 delegates_.back()->set_widget_host(parent_host_); | 473 delegates_.back()->set_widget_host(parent_host_); |
| 507 parent_view_ = new RenderWidgetHostViewAura(parent_host_, | 474 parent_view_ = new RenderWidgetHostViewAura(parent_host_, |
| 508 is_guest_view_hack_); | 475 is_guest_view_hack_); |
| 509 parent_view_->InitAsChild(nullptr); | 476 parent_view_->InitAsChild(nullptr); |
| 510 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), | 477 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), |
| 511 aura_test_helper_->root_window(), | 478 aura_test_helper_->root_window(), |
| 512 gfx::Rect()); | 479 gfx::Rect()); |
| 513 | 480 |
| 514 routing_id = process_host_->GetNextRoutingID(); | 481 routing_id = process_host_->GetNextRoutingID(); |
| 515 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 482 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 516 widget_host_ = new MockRenderWidgetHostImpl(delegates_.back().get(), | 483 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), |
| 517 process_host_, routing_id); | 484 process_host_, routing_id, false); |
| 518 delegates_.back()->set_widget_host(widget_host_); | 485 delegates_.back()->set_widget_host(widget_host_); |
| 519 widget_host_->Init(); | 486 widget_host_->Init(); |
| 520 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); | 487 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); |
| 521 } | 488 } |
| 522 | 489 |
| 523 void TearDownEnvironment() { | 490 void TearDownEnvironment() { |
| 524 sink_ = nullptr; | 491 sink_ = nullptr; |
| 525 process_host_ = nullptr; | 492 process_host_ = nullptr; |
| 526 if (view_) { | 493 if (view_) { |
| 527 // For guest-views, |view_| is not the view used by |widget_host_|. | 494 // For guest-views, |view_| is not the view used by |widget_host_|. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; | 634 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; |
| 668 MockRenderProcessHost* process_host_; | 635 MockRenderProcessHost* process_host_; |
| 669 | 636 |
| 670 // Tests should set these to nullptr if they've already triggered their | 637 // Tests should set these to nullptr if they've already triggered their |
| 671 // destruction. | 638 // destruction. |
| 672 RenderWidgetHostImpl* parent_host_; | 639 RenderWidgetHostImpl* parent_host_; |
| 673 RenderWidgetHostViewAura* parent_view_; | 640 RenderWidgetHostViewAura* parent_view_; |
| 674 | 641 |
| 675 // Tests should set these to nullptr if they've already triggered their | 642 // Tests should set these to nullptr if they've already triggered their |
| 676 // destruction. | 643 // destruction. |
| 677 MockRenderWidgetHostImpl* widget_host_; | 644 RenderWidgetHostImpl* widget_host_; |
| 678 FakeRenderWidgetHostViewAura* view_; | 645 FakeRenderWidgetHostViewAura* view_; |
| 679 | 646 |
| 680 IPC::TestSink* sink_; | 647 IPC::TestSink* sink_; |
| 681 | 648 |
| 682 private: | 649 private: |
| 683 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); | 650 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); |
| 684 }; | 651 }; |
| 685 | 652 |
| 686 // Helper class to instantiate RenderWidgetHostViewGuest which is backed | 653 // Helper class to instantiate RenderWidgetHostViewGuest which is backed |
| 687 // by an aura platform view. | 654 // by an aura platform view. |
| (...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2539 // scale on it. | 2506 // scale on it. |
| 2540 view_->OnSwapCompositorFrame( | 2507 view_->OnSwapCompositorFrame( |
| 2541 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); | 2508 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); |
| 2542 | 2509 |
| 2543 // When we get a new frame with the same frame size in physical pixels, but | 2510 // When we get a new frame with the same frame size in physical pixels, but |
| 2544 // a different scale, we should generate a surface, as the final result will | 2511 // a different scale, we should generate a surface, as the final result will |
| 2545 // need to be scaled differently to the screen. | 2512 // need to be scaled differently to the screen. |
| 2546 EXPECT_NE(surface_id, view_->surface_id()); | 2513 EXPECT_NE(surface_id, view_->surface_id()); |
| 2547 } | 2514 } |
| 2548 | 2515 |
| 2549 TEST_F(RenderWidgetHostViewAuraTest, SourceEventTypeExistsInLatencyInfo) { | |
| 2550 // WHEEL source exists. | |
| 2551 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(), | |
| 2552 0, 0, 0, 0, 0, 2); | |
| 2553 view_->OnScrollEvent(&scroll); | |
| 2554 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(), | |
| 2555 ui::SourceEventType::WHEEL); | |
| 2556 | |
| 2557 // TOUCH source exists. | |
| 2558 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | |
| 2559 ui::EventTimeForNow()); | |
| 2560 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | |
| 2561 ui::EventTimeForNow()); | |
| 2562 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | |
| 2563 ui::EventTimeForNow()); | |
| 2564 view_->OnTouchEvent(&press); | |
| 2565 view_->OnTouchEvent(&move); | |
| 2566 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(), | |
| 2567 ui::SourceEventType::TOUCH); | |
| 2568 view_->OnTouchEvent(&release); | |
| 2569 } | |
| 2570 | |
| 2571 class RenderWidgetHostViewAuraCopyRequestTest | 2516 class RenderWidgetHostViewAuraCopyRequestTest |
| 2572 : public RenderWidgetHostViewAuraShutdownTest { | 2517 : public RenderWidgetHostViewAuraShutdownTest { |
| 2573 public: | 2518 public: |
| 2574 RenderWidgetHostViewAuraCopyRequestTest() | 2519 RenderWidgetHostViewAuraCopyRequestTest() |
| 2575 : callback_count_(0), | 2520 : callback_count_(0), |
| 2576 result_(false), | 2521 result_(false), |
| 2577 frame_subscriber_(nullptr), | 2522 frame_subscriber_(nullptr), |
| 2578 tick_clock_(nullptr), | 2523 tick_clock_(nullptr), |
| 2579 view_rect_(100, 100) {} | 2524 view_rect_(100, 100) {} |
| 2580 | 2525 |
| (...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4675 | 4620 |
| 4676 // Retrieve the selected text from clipboard and verify it is as expected. | 4621 // Retrieve the selected text from clipboard and verify it is as expected. |
| 4677 base::string16 result_text; | 4622 base::string16 result_text; |
| 4678 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); | 4623 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); |
| 4679 EXPECT_EQ(expected_text, result_text); | 4624 EXPECT_EQ(expected_text, result_text); |
| 4680 } | 4625 } |
| 4681 } | 4626 } |
| 4682 #endif | 4627 #endif |
| 4683 | 4628 |
| 4684 } // namespace content | 4629 } // namespace content |
| OLD | NEW |