Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2317253005: SourceEventType added to LatencyInfo (Closed)
Patch Set: Changed the patch to only contain source event type plumbing. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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| and stores it in
447 // |lastWheelOrTouchEventLatencyInfo|.
448
tdresser 2016/09/12 14:23:08 I think this would be clearer if you removed the s
sahel 2016/09/12 17:02:26 Done.
449 void ForwardWheelEventWithLatencyInfo(
450 const blink::WebMouseWheelEvent& wheel_event,
451 const ui::LatencyInfo& ui_latency) override {
452 RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(wheel_event,
453 ui_latency);
454 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency);
455 }
456
457 void ForwardTouchEventWithLatencyInfo(
458 const blink::WebTouchEvent& touch_event,
459 const ui::LatencyInfo& ui_latency) override {
460 RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(touch_event,
461 ui_latency);
462 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency);
463 }
464
465 ui::LatencyInfo lastWheelOrTouchEventLatencyInfo;
466 };
467
436 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { 468 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) {
437 base::PickleIterator iter(message); 469 base::PickleIterator iter(message);
438 const char* data; 470 const char* data;
439 int data_length; 471 int data_length;
440 if (!iter.ReadData(&data, &data_length)) 472 if (!iter.ReadData(&data, &data_length))
441 return nullptr; 473 return nullptr;
442 return reinterpret_cast<const WebInputEvent*>(data); 474 return reinterpret_cast<const WebInputEvent*>(data);
443 } 475 }
444 476
445 } // namespace 477 } // namespace
(...skipping 27 matching lines...) Expand all
473 delegates_.back()->set_widget_host(parent_host_); 505 delegates_.back()->set_widget_host(parent_host_);
474 parent_view_ = new RenderWidgetHostViewAura(parent_host_, 506 parent_view_ = new RenderWidgetHostViewAura(parent_host_,
475 is_guest_view_hack_); 507 is_guest_view_hack_);
476 parent_view_->InitAsChild(nullptr); 508 parent_view_->InitAsChild(nullptr);
477 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), 509 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(),
478 aura_test_helper_->root_window(), 510 aura_test_helper_->root_window(),
479 gfx::Rect()); 511 gfx::Rect());
480 512
481 routing_id = process_host_->GetNextRoutingID(); 513 routing_id = process_host_->GetNextRoutingID();
482 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); 514 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate));
483 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), 515 widget_host_ = new MockRenderWidgetHostImpl(delegates_.back().get(),
484 process_host_, routing_id, false); 516 process_host_, routing_id);
485 delegates_.back()->set_widget_host(widget_host_); 517 delegates_.back()->set_widget_host(widget_host_);
486 widget_host_->Init(); 518 widget_host_->Init();
487 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); 519 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_);
488 } 520 }
489 521
490 void TearDownEnvironment() { 522 void TearDownEnvironment() {
491 sink_ = nullptr; 523 sink_ = nullptr;
492 process_host_ = nullptr; 524 process_host_ = nullptr;
493 if (view_) { 525 if (view_) {
494 // For guest-views, |view_| is not the view used by |widget_host_|. 526 // For guest-views, |view_| is not the view used by |widget_host_|.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; 666 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_;
635 MockRenderProcessHost* process_host_; 667 MockRenderProcessHost* process_host_;
636 668
637 // Tests should set these to nullptr if they've already triggered their 669 // Tests should set these to nullptr if they've already triggered their
638 // destruction. 670 // destruction.
639 RenderWidgetHostImpl* parent_host_; 671 RenderWidgetHostImpl* parent_host_;
640 RenderWidgetHostViewAura* parent_view_; 672 RenderWidgetHostViewAura* parent_view_;
641 673
642 // Tests should set these to nullptr if they've already triggered their 674 // Tests should set these to nullptr if they've already triggered their
643 // destruction. 675 // destruction.
644 RenderWidgetHostImpl* widget_host_; 676 MockRenderWidgetHostImpl* widget_host_;
645 FakeRenderWidgetHostViewAura* view_; 677 FakeRenderWidgetHostViewAura* view_;
646 678
647 IPC::TestSink* sink_; 679 IPC::TestSink* sink_;
648 680
649 private: 681 private:
650 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); 682 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest);
651 }; 683 };
652 684
653 // Helper class to instantiate RenderWidgetHostViewGuest which is backed 685 // Helper class to instantiate RenderWidgetHostViewGuest which is backed
654 // by an aura platform view. 686 // by an aura platform view.
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 // scale on it. 2537 // scale on it.
2506 view_->OnSwapCompositorFrame( 2538 view_->OnSwapCompositorFrame(
2507 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); 2539 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size)));
2508 2540
2509 // When we get a new frame with the same frame size in physical pixels, but 2541 // 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 2542 // a different scale, we should generate a surface, as the final result will
2511 // need to be scaled differently to the screen. 2543 // need to be scaled differently to the screen.
2512 EXPECT_NE(surface_id, view_->surface_id()); 2544 EXPECT_NE(surface_id, view_->surface_id());
2513 } 2545 }
2514 2546
2547 TEST_F(RenderWidgetHostViewAuraTest, SourceEventTypeExistsInLatencyInfo) {
2548 // WHEEL source exists.
2549 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(),
2550 0, 0, 0, 0, 0, 2);
2551 view_->OnScrollEvent(&scroll);
2552 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(),
2553 ui::SourceEventType::WHEEL);
2554
2555 // TOUCH source exists.
2556 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
2557 ui::EventTimeForNow());
2558 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
2559 ui::EventTimeForNow());
2560 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0,
2561 ui::EventTimeForNow());
2562 view_->OnTouchEvent(&press);
2563 view_->OnTouchEvent(&move);
2564 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(),
2565 ui::SourceEventType::TOUCH);
2566 view_->OnTouchEvent(&release);
2567 }
2568
2515 class RenderWidgetHostViewAuraCopyRequestTest 2569 class RenderWidgetHostViewAuraCopyRequestTest
2516 : public RenderWidgetHostViewAuraShutdownTest { 2570 : public RenderWidgetHostViewAuraShutdownTest {
2517 public: 2571 public:
2518 RenderWidgetHostViewAuraCopyRequestTest() 2572 RenderWidgetHostViewAuraCopyRequestTest()
2519 : callback_count_(0), 2573 : callback_count_(0),
2520 result_(false), 2574 result_(false),
2521 frame_subscriber_(nullptr), 2575 frame_subscriber_(nullptr),
2522 tick_clock_(nullptr), 2576 tick_clock_(nullptr),
2523 view_rect_(100, 100) {} 2577 view_rect_(100, 100) {}
2524 2578
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
4574 4628
4575 // Retrieve the selected text from clipboard and verify it is as expected. 4629 // Retrieve the selected text from clipboard and verify it is as expected.
4576 base::string16 result_text; 4630 base::string16 result_text;
4577 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); 4631 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text);
4578 EXPECT_EQ(expected_text, result_text); 4632 EXPECT_EQ(expected_text, result_text);
4579 } 4633 }
4580 } 4634 }
4581 #endif 4635 #endif
4582 4636
4583 } // namespace content 4637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698