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 |
436 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 469 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
437 base::PickleIterator iter(message); | 470 base::PickleIterator iter(message); |
438 const char* data; | 471 const char* data; |
439 int data_length; | 472 int data_length; |
440 if (!iter.ReadData(&data, &data_length)) | 473 if (!iter.ReadData(&data, &data_length)) |
441 return nullptr; | 474 return nullptr; |
442 return reinterpret_cast<const WebInputEvent*>(data); | 475 return reinterpret_cast<const WebInputEvent*>(data); |
443 } | 476 } |
444 | 477 |
445 } // namespace | 478 } // namespace |
(...skipping 27 matching lines...) Expand all Loading... |
473 delegates_.back()->set_widget_host(parent_host_); | 506 delegates_.back()->set_widget_host(parent_host_); |
474 parent_view_ = new RenderWidgetHostViewAura(parent_host_, | 507 parent_view_ = new RenderWidgetHostViewAura(parent_host_, |
475 is_guest_view_hack_); | 508 is_guest_view_hack_); |
476 parent_view_->InitAsChild(nullptr); | 509 parent_view_->InitAsChild(nullptr); |
477 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), | 510 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), |
478 aura_test_helper_->root_window(), | 511 aura_test_helper_->root_window(), |
479 gfx::Rect()); | 512 gfx::Rect()); |
480 | 513 |
481 routing_id = process_host_->GetNextRoutingID(); | 514 routing_id = process_host_->GetNextRoutingID(); |
482 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 515 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
483 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), | 516 widget_host_ = new MockRenderWidgetHostImpl(delegates_.back().get(), |
484 process_host_, routing_id, false); | 517 process_host_, routing_id); |
485 delegates_.back()->set_widget_host(widget_host_); | 518 delegates_.back()->set_widget_host(widget_host_); |
486 widget_host_->Init(); | 519 widget_host_->Init(); |
487 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); | 520 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); |
488 } | 521 } |
489 | 522 |
490 void TearDownEnvironment() { | 523 void TearDownEnvironment() { |
491 sink_ = nullptr; | 524 sink_ = nullptr; |
492 process_host_ = nullptr; | 525 process_host_ = nullptr; |
493 if (view_) { | 526 if (view_) { |
494 // For guest-views, |view_| is not the view used by |widget_host_|. | 527 // 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... |
634 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; | 667 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; |
635 MockRenderProcessHost* process_host_; | 668 MockRenderProcessHost* process_host_; |
636 | 669 |
637 // Tests should set these to nullptr if they've already triggered their | 670 // Tests should set these to nullptr if they've already triggered their |
638 // destruction. | 671 // destruction. |
639 RenderWidgetHostImpl* parent_host_; | 672 RenderWidgetHostImpl* parent_host_; |
640 RenderWidgetHostViewAura* parent_view_; | 673 RenderWidgetHostViewAura* parent_view_; |
641 | 674 |
642 // Tests should set these to nullptr if they've already triggered their | 675 // Tests should set these to nullptr if they've already triggered their |
643 // destruction. | 676 // destruction. |
644 RenderWidgetHostImpl* widget_host_; | 677 MockRenderWidgetHostImpl* widget_host_; |
645 FakeRenderWidgetHostViewAura* view_; | 678 FakeRenderWidgetHostViewAura* view_; |
646 | 679 |
647 IPC::TestSink* sink_; | 680 IPC::TestSink* sink_; |
648 | 681 |
649 private: | 682 private: |
650 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); | 683 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); |
651 }; | 684 }; |
652 | 685 |
653 // Helper class to instantiate RenderWidgetHostViewGuest which is backed | 686 // Helper class to instantiate RenderWidgetHostViewGuest which is backed |
654 // by an aura platform view. | 687 // by an aura platform view. |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 // scale on it. | 2538 // scale on it. |
2506 view_->OnSwapCompositorFrame( | 2539 view_->OnSwapCompositorFrame( |
2507 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); | 2540 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); |
2508 | 2541 |
2509 // When we get a new frame with the same frame size in physical pixels, but | 2542 // When we get a new frame with the same frame size in physical pixels, but |
2510 // a different scale, we should generate a surface, as the final result will | 2543 // a different scale, we should generate a surface, as the final result will |
2511 // need to be scaled differently to the screen. | 2544 // need to be scaled differently to the screen. |
2512 EXPECT_NE(surface_id, view_->surface_id()); | 2545 EXPECT_NE(surface_id, view_->surface_id()); |
2513 } | 2546 } |
2514 | 2547 |
| 2548 TEST_F(RenderWidgetHostViewAuraTest, SourceEventTypeExistsInLatencyInfo) { |
| 2549 // WHEEL source exists. |
| 2550 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(), |
| 2551 0, 0, 0, 0, 0, 2); |
| 2552 view_->OnScrollEvent(&scroll); |
| 2553 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(), |
| 2554 ui::SourceEventType::WHEEL); |
| 2555 |
| 2556 // TOUCH source exists. |
| 2557 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 2558 ui::EventTimeForNow()); |
| 2559 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 2560 ui::EventTimeForNow()); |
| 2561 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
| 2562 ui::EventTimeForNow()); |
| 2563 view_->OnTouchEvent(&press); |
| 2564 view_->OnTouchEvent(&move); |
| 2565 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(), |
| 2566 ui::SourceEventType::TOUCH); |
| 2567 view_->OnTouchEvent(&release); |
| 2568 } |
| 2569 |
2515 class RenderWidgetHostViewAuraCopyRequestTest | 2570 class RenderWidgetHostViewAuraCopyRequestTest |
2516 : public RenderWidgetHostViewAuraShutdownTest { | 2571 : public RenderWidgetHostViewAuraShutdownTest { |
2517 public: | 2572 public: |
2518 RenderWidgetHostViewAuraCopyRequestTest() | 2573 RenderWidgetHostViewAuraCopyRequestTest() |
2519 : callback_count_(0), | 2574 : callback_count_(0), |
2520 result_(false), | 2575 result_(false), |
2521 frame_subscriber_(nullptr), | 2576 frame_subscriber_(nullptr), |
2522 tick_clock_(nullptr), | 2577 tick_clock_(nullptr), |
2523 view_rect_(100, 100) {} | 2578 view_rect_(100, 100) {} |
2524 | 2579 |
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4574 | 4629 |
4575 // Retrieve the selected text from clipboard and verify it is as expected. | 4630 // Retrieve the selected text from clipboard and verify it is as expected. |
4576 base::string16 result_text; | 4631 base::string16 result_text; |
4577 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); | 4632 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); |
4578 EXPECT_EQ(expected_text, result_text); | 4633 EXPECT_EQ(expected_text, result_text); |
4579 } | 4634 } |
4580 } | 4635 } |
4581 #endif | 4636 #endif |
4582 | 4637 |
4583 } // namespace content | 4638 } // namespace content |
OLD | NEW |