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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 // scale on it. | 2539 // scale on it. |
2507 view_->OnSwapCompositorFrame( | 2540 view_->OnSwapCompositorFrame( |
2508 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); | 2541 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); |
2509 | 2542 |
2510 // When we get a new frame with the same frame size in physical pixels, but | 2543 // When we get a new frame with the same frame size in physical pixels, but |
2511 // a different scale, we should generate a surface, as the final result will | 2544 // a different scale, we should generate a surface, as the final result will |
2512 // need to be scaled differently to the screen. | 2545 // need to be scaled differently to the screen. |
2513 EXPECT_NE(surface_id, view_->surface_id()); | 2546 EXPECT_NE(surface_id, view_->surface_id()); |
2514 } | 2547 } |
2515 | 2548 |
| 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 |
2516 class RenderWidgetHostViewAuraCopyRequestTest | 2571 class RenderWidgetHostViewAuraCopyRequestTest |
2517 : public RenderWidgetHostViewAuraShutdownTest { | 2572 : public RenderWidgetHostViewAuraShutdownTest { |
2518 public: | 2573 public: |
2519 RenderWidgetHostViewAuraCopyRequestTest() | 2574 RenderWidgetHostViewAuraCopyRequestTest() |
2520 : callback_count_(0), | 2575 : callback_count_(0), |
2521 result_(false), | 2576 result_(false), |
2522 frame_subscriber_(nullptr), | 2577 frame_subscriber_(nullptr), |
2523 tick_clock_(nullptr), | 2578 tick_clock_(nullptr), |
2524 view_rect_(100, 100) {} | 2579 view_rect_(100, 100) {} |
2525 | 2580 |
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4588 | 4643 |
4589 // Retrieve the selected text from clipboard and verify it is as expected. | 4644 // Retrieve the selected text from clipboard and verify it is as expected. |
4590 base::string16 result_text; | 4645 base::string16 result_text; |
4591 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); | 4646 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); |
4592 EXPECT_EQ(expected_text, result_text); | 4647 EXPECT_EQ(expected_text, result_text); |
4593 } | 4648 } |
4594 } | 4649 } |
4595 #endif | 4650 #endif |
4596 | 4651 |
4597 } // namespace content | 4652 } // namespace content |
OLD | NEW |